Permalink
Browse files

Add identity objects for comparisons of object types internally, and …

…make the tail recursive installation of fast paths work
  • Loading branch information...
1 parent 45cfd3e commit 916cfd0560bc8f2e014ba65f243be3785fec6924 @olabini olabini committed Mar 7, 2011
View
@@ -4,8 +4,14 @@ Current compilation is missing several pieces:
- Make toplevel also use the compiler
- Possibly have a few shortcircuited things like if, + etc. Make that use a SwitchPoint that invalidates if something with that name is redefined
specifically inline things like "nil", "true", "false", etc
+ See if it's possible to implement if-statements using GWT
- Invoking things that create abstractions doesn't work... (should be very easy to sort out)
- Invoking things with arguments cannot handle keyword arguments (important for the "with" method)
- Compile assignments
- Check the performance of tail recursive odd/even, and larger fib...
+
+
+
+- Lexical scopes - compile based on what variables the compiler can see. Do things as a message send if it can't be seen in a static scope.
+ Or consider it at least
@@ -14,6 +14,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.NumberBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.NumberBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -21,6 +21,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.BaseBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.BaseBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -60,6 +60,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.ControlDefaultBehaviorBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.ControlDefaultBehaviorBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -22,6 +22,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.DefaultBehaviorBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.DefaultBehaviorBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -53,6 +53,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.GroundBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.GroundBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -25,6 +25,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.IODefaultBehaviorBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.IODefaultBehaviorBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -45,6 +45,10 @@ public SephObject get(String cellName) {
return null;
}
+ public Object identity() {
+ return this;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -22,6 +22,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.SephGroundBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.SephGroundBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -34,6 +34,10 @@ public SephObject get(String cellName) {
return null;
}
+ public Object identity() {
+ return this;
+ }
+
public boolean isActivatable() {
return meta.valueAt(activatable) == Runtime.TRUE;
}
@@ -26,4 +26,6 @@
SephObject activateWith(SephObject receiver, SThread thread, LexicalScope scope, MethodHandle arg0, MethodHandle arg1, MethodHandle arg2, MethodHandle arg3);
SephObject activateWith(SephObject receiver, SThread thread, LexicalScope scope, MethodHandle arg0, MethodHandle arg1, MethodHandle arg2, MethodHandle arg3, MethodHandle arg4);
boolean isTrue();
+
+ Object identity();
}// SephObject
@@ -94,4 +94,8 @@ public SephObject activateWith(SephObject receiver, SThread thread, LexicalScope
public SephObject activateWith(SephObject receiver, SThread thread, LexicalScope scope, MethodHandle arg0, MethodHandle arg1, MethodHandle arg2, MethodHandle arg3, MethodHandle arg4) {
throw new RuntimeException(" *** couldn't activate: " + this);
}
+
+ public Object identity() {
+ return this;
+ }
}// SimpleSephObject
@@ -20,6 +20,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.SomethingBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.SomethingBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -19,6 +19,10 @@ public SephObject get(String cellName) {
return null;
}
+ public Object identity() {
+ return this;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -32,6 +32,10 @@ public SephObject get(String cellName) {
return seph.lang.bim.TextBase.get(cellName);
}
+ public Object identity() {
+ return seph.lang.bim.TextBase.IDENTITY;
+ }
+
public boolean isActivatable() {
return false;
}
@@ -170,7 +170,8 @@ public void visitClassDeclaration(ClassDeclaration cd) {
out.println(" public final static SephObject cell_" + cell + " = " + cell + ".instance;");
}
out.println();
-
+ out.println(" public final static Object IDENTITY = new Object();");
+ out.println();
out.println(" public static SephObject get(String name) {");
out.println(" name = name.intern();");
for(Map.Entry<String,MethodDeclaration> entry : methods.entrySet()) {
@@ -151,4 +151,8 @@ public SephObject activateWith(SephObject receiver, SThread thread, LexicalScope
public SephObject activateWith(SephObject receiver, SThread thread, LexicalScope scope, MethodHandle arg0, MethodHandle arg1, MethodHandle arg2, MethodHandle arg3, MethodHandle arg4) {
throw new RuntimeException(" *** couldn't activate: " + this);
}
+
+ public Object identity() {
+ return this;
+ }
}// LiteralMessage
@@ -218,4 +218,8 @@ public SephObject activateWith(SephObject receiver, SThread thread, LexicalScope
public SephObject activateWith(SephObject receiver, SThread thread, LexicalScope scope, MethodHandle arg0, MethodHandle arg1, MethodHandle arg2, MethodHandle arg3, MethodHandle arg4) {
throw new RuntimeException(" *** couldn't activate: " + this);
}
+
+ public Object identity() {
+ return this;
+ }
}// NamedMessage
@@ -279,8 +279,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARGS, 0, value, receiver, thread, scope, args);
+ MethodHandle h = ACTIVATE_WITH_ARGS.bindTo(value);
site.installActivatableEntry(receiver, null, h, -1);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, args);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -295,8 +296,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG0, 0, value, receiver, thread, scope);
+ MethodHandle h = ACTIVATE_WITH_ARG0.bindTo(value);
site.installActivatableEntry(receiver, null, h, 0);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -311,8 +313,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG1, 0, value, receiver, thread, scope, arg0);
+ MethodHandle h = ACTIVATE_WITH_ARG1.bindTo(value);
site.installActivatableEntry(receiver, null, h, 1);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -327,8 +330,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG2, 0, value, receiver, thread, scope, arg0, arg1);
+ MethodHandle h = ACTIVATE_WITH_ARG2.bindTo(value);
site.installActivatableEntry(receiver, null, h, 2);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -343,8 +347,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG3, 0, value, receiver, thread, scope, arg0, arg1, arg2);
+ MethodHandle h = ACTIVATE_WITH_ARG3.bindTo(value);
site.installActivatableEntry(receiver, null, h, 3);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1, arg2);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -359,8 +364,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG4, 0, value, receiver, thread, scope, arg0, arg1, arg2, arg3);
+ MethodHandle h = ACTIVATE_WITH_ARG4.bindTo(value);
site.installActivatableEntry(receiver, null, h, 4);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1, arg2, arg3);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -375,8 +381,9 @@ public static SephObject tailCallFallback(SephCallSite site, String name, SephOb
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG4, 0, value, receiver, thread, scope, arg0, arg1, arg2, arg3, arg4);
+ MethodHandle h = ACTIVATE_WITH_ARG5.bindTo(value);
site.installActivatableEntry(receiver, null, h, 5);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1, arg2, arg3, arg4);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -395,8 +402,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARGS, 0, value, receiver, thread, scope, args);
+ MethodHandle h = ACTIVATE_WITH_ARGS.bindTo(value);
site.installActivatableEntry(receiver, scope, h, -1);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, args);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -414,8 +422,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG0, 0, value, receiver, thread, scope);
+ MethodHandle h = ACTIVATE_WITH_ARG0.bindTo(value);
site.installActivatableEntry(receiver, scope, h, 0);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -433,8 +442,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG1, 0, value, receiver, thread, scope, arg0);
+ MethodHandle h = ACTIVATE_WITH_ARG1.bindTo(value);
site.installActivatableEntry(receiver, scope, h, 1);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -452,8 +462,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG2, 0, value, receiver, thread, scope, arg0, arg1);
+ MethodHandle h = ACTIVATE_WITH_ARG2.bindTo(value);
site.installActivatableEntry(receiver, scope, h, 2);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -471,8 +482,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG3, 0, value, receiver, thread, scope, arg0, arg1, arg2);
+ MethodHandle h = ACTIVATE_WITH_ARG3.bindTo(value);
site.installActivatableEntry(receiver, scope, h, 3);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1, arg2);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -490,8 +502,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG4, 0, value, receiver, thread, scope, arg0, arg1, arg2, arg3);
+ MethodHandle h = ACTIVATE_WITH_ARG4.bindTo(value);
site.installActivatableEntry(receiver, scope, h, 4);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1, arg2, arg3);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
@@ -509,8 +522,9 @@ public static SephObject noReceiverTailCallFallback(SephCallSite site, String na
throw new RuntimeException(" *** couldn't find: " + name + " on " + receiver);
}
if(value.isActivatable()) {
- MethodHandle h = MethodHandles.insertArguments(ACTIVATE_WITH_ARG5, 0, value, receiver, thread, scope, arg0, arg1, arg2, arg3, arg4);
+ MethodHandle h = ACTIVATE_WITH_ARG5.bindTo(value);
site.installActivatableEntry(receiver, scope, h, 5);
+ h = MethodHandles.insertArguments(h, 0, receiver, thread, scope, arg0, arg1, arg2, arg3, arg4);
thread.tail = h;
return SThread.TAIL_MARKER;
} else {
Oops, something went wrong.

0 comments on commit 916cfd0

Please sign in to comment.