diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java @ 18161:94f16a759646

Truffle: remove FrameTypeConversion interface
author Andreas Woess <andreas.woess@jku.at>
date Thu, 23 Oct 2014 13:45:59 +0200
parents 9d55732d0880
children 79d212bfee22
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java	Thu Oct 23 12:02:02 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java	Thu Oct 23 13:45:59 2014 +0200
@@ -27,7 +27,6 @@
 import java.util.*;
 
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.impl.*;
 
 /**
  * Descriptor of the slots of frame objects. Multiple frame instances are associated with one such
@@ -35,23 +34,31 @@
  */
 public final class FrameDescriptor implements Cloneable {
 
-    private final FrameTypeConversion typeConversion;
+    private final Object defaultValue;
     private final ArrayList<FrameSlot> slots;
     private final HashMap<Object, FrameSlot> identifierToSlotMap;
     private Assumption version;
     private HashMap<Object, Assumption> identifierToNotInFrameAssumptionMap;
 
     public FrameDescriptor() {
-        this(DefaultFrameTypeConversion.getInstance());
+        this(null);
     }
 
-    public FrameDescriptor(FrameTypeConversion typeConversion) {
-        this.typeConversion = typeConversion;
+    public FrameDescriptor(Object defaultValue) {
+        this.defaultValue = defaultValue;
         slots = new ArrayList<>();
         identifierToSlotMap = new HashMap<>();
         version = createVersion();
     }
 
+    public static FrameDescriptor create() {
+        return new FrameDescriptor();
+    }
+
+    public static FrameDescriptor create(Object defaultValue) {
+        return new FrameDescriptor(defaultValue);
+    }
+
     public FrameSlot addFrameSlot(Object identifier) {
         return addFrameSlot(identifier, null, FrameSlotKind.Illegal);
     }
@@ -91,6 +98,14 @@
         return addFrameSlot(identifier, kind);
     }
 
+    public FrameSlot findOrAddFrameSlot(Object identifier, Object info, FrameSlotKind kind) {
+        FrameSlot result = findFrameSlot(identifier);
+        if (result != null) {
+            return result;
+        }
+        return addFrameSlot(identifier, info, kind);
+    }
+
     public void removeFrameSlot(Object identifier) {
         CompilerAsserts.neverPartOfCompilation("interpreter-only.  includes hashmap operations.");
         assert identifierToSlotMap.containsKey(identifier);
@@ -118,7 +133,7 @@
     }
 
     public FrameDescriptor copy() {
-        FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.typeConversion);
+        FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue);
         for (int i = 0; i < this.getSlots().size(); i++) {
             Object identifier = this.getSlots().get(i).getIdentifier();
             clonedFrameDescriptor.addFrameSlot(identifier);
@@ -127,7 +142,7 @@
     }
 
     public FrameDescriptor shallowCopy() {
-        FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.typeConversion);
+        FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue);
         clonedFrameDescriptor.slots.addAll(slots);
         clonedFrameDescriptor.identifierToSlotMap.putAll(identifierToSlotMap);
         return clonedFrameDescriptor;
@@ -146,8 +161,8 @@
         return Truffle.getRuntime().createAssumption("frame version");
     }
 
-    public FrameTypeConversion getTypeConversion() {
-        return typeConversion;
+    public Object getDefaultValue() {
+        return defaultValue;
     }
 
     public Assumption getNotInFrameAssumption(Object identifier) {