Mercurial > hg > graal-compiler
changeset 7722:f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 05 Feb 2013 17:18:57 +0100 |
parents | 1a2d258d481a |
children | fad3f591580c |
files | graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java |
diffstat | 3 files changed, 21 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Tue Feb 05 17:03:51 2013 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Tue Feb 05 17:18:57 2013 +0100 @@ -35,7 +35,7 @@ * The frame is the preferred data structure for passing values between nodes. It can in particular * be used for storing the values of local variables of the guest language. The * {@link FrameDescriptor} represents the current structure of the frame. The method - * {@link FrameDescriptor#addFrameSlot(String, Class)} can be used to create predefined frame slots. + * {@link FrameDescriptor#addFrameSlot(Object, Class)} can be used to create predefined frame slots. * The setter and getter methods in the {@link Frame} class can be used to access the current value * of a particular frame slot. * </p>
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java Tue Feb 05 17:03:51 2013 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java Tue Feb 05 17:18:57 2013 +0100 @@ -33,7 +33,7 @@ protected final TypeConversion typeConversion; private final ArrayList<FrameSlotImpl> slots; private FrameVersionImpl lastVersion; - private final HashMap<String, FrameSlotImpl> nameToSlotMap; + private final HashMap<Object, FrameSlotImpl> identifierToSlotMap; public FrameDescriptor() { this(DefaultTypeConversion.getInstance()); @@ -42,32 +42,32 @@ public FrameDescriptor(TypeConversion typeConversion) { this.typeConversion = typeConversion; slots = new ArrayList<>(); - nameToSlotMap = new HashMap<>(); + identifierToSlotMap = new HashMap<>(); lastVersion = new FrameVersionImpl(); } - public FrameSlot addFrameSlot(String name) { - return addFrameSlot(name, typeConversion.getTopType()); + public FrameSlot addFrameSlot(Object identifier) { + return addFrameSlot(identifier, typeConversion.getTopType()); } - public FrameSlot addFrameSlot(String name, Class<?> type) { - assert !nameToSlotMap.containsKey(name); - FrameSlotImpl slot = new FrameSlotImpl(this, name, slots.size(), type); + public FrameSlot addFrameSlot(Object identifier, Class<?> type) { + assert !identifierToSlotMap.containsKey(identifier); + FrameSlotImpl slot = new FrameSlotImpl(this, identifier, slots.size(), type); slots.add(slot); - nameToSlotMap.put(name, slot); + identifierToSlotMap.put(identifier, slot); return slot; } - public FrameSlot findFrameSlot(String name) { - return nameToSlotMap.get(name); + public FrameSlot findFrameSlot(Object identifier) { + return identifierToSlotMap.get(identifier); } - public FrameSlot findOrAddFrameSlot(String name) { - FrameSlot result = findFrameSlot(name); + public FrameSlot findOrAddFrameSlot(Object identifier) { + FrameSlot result = findFrameSlot(identifier); if (result != null) { return result; } - return addFrameSlot(name); + return addFrameSlot(identifier); } public FrameVersion getCurrentVersion() { @@ -120,21 +120,21 @@ class FrameSlotImpl implements FrameSlot { private final FrameDescriptor descriptor; - private final String name; + private final Object identifier; private final int index; private Class<?> type; private ArrayList<FrameSlotTypeListener> listeners; - protected FrameSlotImpl(FrameDescriptor descriptor, String name, int index, Class<?> type) { + protected FrameSlotImpl(FrameDescriptor descriptor, Object identifier, int index, Class<?> type) { this.descriptor = descriptor; - this.name = name; + this.identifier = identifier; this.index = index; this.type = type; assert type != null; } - public String getName() { - return name; + public Object getIdentifier() { + return identifier; } public int getIndex() { @@ -189,7 +189,7 @@ @Override public String toString() { - return "[" + index + "," + name + "]"; + return "[" + index + "," + identifier + "]"; } @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java Tue Feb 05 17:03:51 2013 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java Tue Feb 05 17:18:57 2013 +0100 @@ -27,7 +27,7 @@ */ public interface FrameSlot { - String getName(); + Object getIdentifier(); int getIndex();