diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java @ 12644:e122dc0436be

convert FrameSlot interface to a final class.
author Andreas Woess <andreas.woess@jku.at>
date Wed, 30 Oct 2013 19:05:29 +0100
parents 494b818b527c
children 80b0bd9e29c8
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java	Wed Oct 30 20:01:50 2013 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java	Wed Oct 30 19:05:29 2013 +0100
@@ -24,18 +24,51 @@
  */
 package com.oracle.truffle.api.frame;
 
+import com.oracle.truffle.api.*;
+
 /**
  * A slot in a frame that can store a value of a given type.
  */
-public interface FrameSlot extends Cloneable {
+public final class FrameSlot implements Cloneable {
+
+    private final FrameDescriptor descriptor;
+    private final Object identifier;
+    private final int index;
+    @com.oracle.truffle.api.CompilerDirectives.CompilationFinal private FrameSlotKind kind;
 
-    Object getIdentifier();
+    public FrameSlot(FrameDescriptor descriptor, Object identifier, int index, FrameSlotKind kind) {
+        this.descriptor = descriptor;
+        this.identifier = identifier;
+        this.index = index;
+        this.kind = kind;
+    }
 
-    int getIndex();
+    public Object getIdentifier() {
+        return identifier;
+    }
+
+    public int getIndex() {
+        return index;
+    }
 
-    FrameSlotKind getKind();
+    public FrameSlotKind getKind() {
+        return kind;
+    }
 
-    void setKind(FrameSlotKind kind);
+    public void setKind(final FrameSlotKind kind) {
+        if (this.kind != kind) {
+            CompilerDirectives.transferToInterpreter();
+            this.kind = kind;
+            this.descriptor.updateVersion();
+        }
+    }
 
-    FrameDescriptor getFrameDescriptor();
+    @Override
+    public String toString() {
+        return "[" + index + "," + identifier + "," + kind + "]";
+    }
+
+    public FrameDescriptor getFrameDescriptor() {
+        return this.descriptor;
+    }
 }