changeset 13761:7c418666c6c9

Refactoring and cleanup of Simple Language (more to come soon)
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 24 Jan 2014 18:16:24 -0800
parents a12017c18d5d
children e34d5cca7496
files graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNodeFactory.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLScript.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLTypes.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SimpleLanguage.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/BuiltinNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/DefaultBuiltins.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/PrintBuiltin.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLDefineFunctionBuiltin.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLPrintBuiltin.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLTimeBuiltin.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/TimeBuiltin.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ArgumentsNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ArithmeticNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BigIntegerLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BinaryNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BlockNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BreakException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BreakNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/CallNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ConditionNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ContinueException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ContinueNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FrameSlotNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionBodyNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionRootNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/IfNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/IntegerLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/LessThanNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/LogicalAndNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/NullLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadArgumentNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadFunctionNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadLocalNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadUninitializedNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReturnException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReturnNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLBinaryNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLTypes.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/StatementNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/StringLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TernaryNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TypedNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WhileNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLAbstractDispatchNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLArgumentsNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLGenericDispatchNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInlinableDirectDispatchNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInlinedDirectDispatchNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLUninitializedCallNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBreakException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBreakNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLContinueException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLContinueNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnException.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLBigIntegerLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalAndNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalOrNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLongLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLNotEqualNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLStringLiteralNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/ReadLocalNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/WriteLocalNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.frame graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLArguments.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunction.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java mx/mx_graal.py
diffstat 96 files changed, 3006 insertions(+), 2766 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl;
+
+public class SLException extends RuntimeException {
+    private static final long serialVersionUID = -6799734410727348507L;
+
+    public SLException(String message) {
+        super(message);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl;
+
+import java.io.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.source.*;
+import com.oracle.truffle.sl.parser.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public class SLMain {
+
+    private static final Object[] NO_ARGUMENTS = new Object[0];
+
+    public static void main(String[] args) {
+        SourceManager sourceManager = new SourceManager();
+        Source source = sourceManager.get(args[0]);
+        SLContext context = new SLContext(sourceManager, System.err);
+        run(context, source, System.out, 1);
+    }
+
+    public static void run(SLContext context, Source source, PrintStream logOutput, int repeats) {
+        if (logOutput != null) {
+            logOutput.println("== running on " + Truffle.getRuntime().getName());
+        }
+
+        Parser.parseSL(context, source);
+        SLFunction main = context.getFunctionRegistry().lookup("main");
+        if (main.getCallTarget() == null) {
+            throw new SLException("No function main() found.");
+        }
+
+        if (logOutput != null) {
+            printScript(context, logOutput);
+        }
+        try {
+            for (int i = 0; i < repeats; i++) {
+                long start = System.nanoTime();
+                Object result = main.getCallTarget().call(null, new SLArguments(NO_ARGUMENTS));
+                long end = System.nanoTime();
+
+                if (result != SLNull.INSTANCE) {
+                    context.getPrintOutput().println(result);
+                }
+                if (logOutput != null) {
+                    logOutput.printf("== iteration %d: %.3f ms\n", (i + 1), (end - start) / 1000000.0);
+                }
+            }
+
+        } finally {
+            if (logOutput != null) {
+                printScript(context, logOutput);
+            }
+        }
+    }
+
+    private static void printScript(SLContext context, PrintStream logOutput) {
+        for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
+            if (function.getCallTarget() != null) {
+                logOutput.println("=== function " + function.getName());
+                NodeUtil.printTree(logOutput, function.getCallTarget().getRootNode());
+            }
+        }
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl;
-
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.api.nodes.*;
-
-@TypeSystemReference(SLTypes.class)
-public class SLNode extends Node {
-
-    public SLNode() {
-        // No source attribution
-        super(null);
-    }
-
-    @Override
-    public String toString() {
-        return getEncapsulatingSourceSection() != null ? getEncapsulatingSourceSection().toString() : super.toString();
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNodeFactory.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl;
-
-import java.math.*;
-import java.util.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.sl.nodes.ArithmeticNodeFactory.AddNodeFactory;
-import com.oracle.truffle.sl.nodes.ArithmeticNodeFactory.DivNodeFactory;
-import com.oracle.truffle.sl.nodes.ArithmeticNodeFactory.MulNodeFactory;
-import com.oracle.truffle.sl.nodes.ArithmeticNodeFactory.SubNodeFactory;
-import com.oracle.truffle.sl.nodes.*;
-import com.oracle.truffle.sl.parser.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public class SLNodeFactory {
-
-    private final SLContext context;
-
-    private Parser parser;
-    private FrameDescriptor frameDescriptor;
-    private TypedNode returnValue;
-
-    private Source source;
-    private String currentFunctionName;
-
-    public SLNodeFactory(SLContext context) {
-        this.context = context;
-    }
-
-    public void setSource(Source source) {
-        this.source = source;
-    }
-
-    public void setParser(Parser parser) {
-        this.parser = parser;
-    }
-
-    public void startFunction() {
-        frameDescriptor = new FrameDescriptor();
-    }
-
-    public void createFunction(StatementNode body, String name, String[] parameterNames) {
-        context.getFunctionRegistry().register(name, FunctionRootNode.createFunction(body, frameDescriptor, name, returnValue, parameterNames));
-        this.currentFunctionName = name;
-        this.returnValue = null;
-    }
-
-    private <T extends Node> T assignSource(T node) {
-        node.assignSourceSection(ParserUtils.createSourceSection(source, currentFunctionName, parser));
-        return node;
-    }
-
-    public TypedNode createLocal(String name) {
-        return assignSource(new ReadUninitializedNode(context, frameDescriptor.findOrAddFrameSlot(name, FrameSlotKind.Int)));
-    }
-
-    public TypedNode createStringLiteral(String value) {
-        return assignSource(new StringLiteralNode(value));
-    }
-
-    public TypedNode createAssignment(TypedNode read, TypedNode assignment) {
-        FrameSlot slot = ((ReadUninitializedNode) read).getSlot();
-        return assignSource(WriteLocalNodeFactory.create(slot, assignment));
-    }
-
-    public StatementNode createWhile(ConditionNode condition, StatementNode body) {
-        return assignSource(new WhileNode(condition, body));
-    }
-
-    public StatementNode createBlock(List<StatementNode> statements) {
-        return assignSource(new BlockNode(statements.toArray(new StatementNode[statements.size()])));
-    }
-
-    public TypedNode createCall(TypedNode function, TypedNode[] parameters) {
-        return assignSource(CallNode.create(function, parameters));
-    }
-
-    public TypedNode createBinary(String operation, TypedNode left, TypedNode right) {
-        TypedNode binary;
-        switch (operation) {
-            case "+":
-                binary = AddNodeFactory.create(left, right);
-                break;
-            case "*":
-                binary = MulNodeFactory.create(left, right);
-                break;
-            case "/":
-                binary = DivNodeFactory.create(left, right);
-                break;
-            case "-":
-                binary = SubNodeFactory.create(left, right);
-                break;
-            case "<":
-                binary = LessThanNodeFactory.create(left, right);
-                break;
-            case "&&":
-                binary = LogicalAndNodeFactory.create(left, right);
-                break;
-            default:
-                throw new RuntimeException("unexpected operation: " + operation);
-        }
-        return assignSource(binary);
-    }
-
-    public TypedNode createNumericLiteral(String value) {
-        try {
-            return assignSource(new IntegerLiteralNode(Integer.parseInt(value)));
-        } catch (NumberFormatException ex) {
-            return assignSource(new BigIntegerLiteralNode(new BigInteger(value)));
-        }
-    }
-
-    public StatementNode createReturn(TypedNode value) {
-        FrameSlot slot = frameDescriptor.findOrAddFrameSlot("<retval>", FrameSlotKind.Int);
-        if (returnValue == null) {
-            returnValue = ReadLocalNodeFactory.create(slot);
-        }
-        StatementNode write = WriteLocalNodeFactory.create(slot, value);
-        return assignSource(new ReturnNode(write));
-    }
-
-    public TypedNode createTernary(TypedNode condition, TypedNode thenPart, TypedNode elsePart) {
-        return assignSource(TernaryNodeFactory.create(condition, thenPart, elsePart));
-    }
-
-    public StatementNode createIf(ConditionNode condition, StatementNode then, StatementNode elseNode) {
-        return assignSource(IfNodeFactory.create(then, elseNode, condition));
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLScript.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl;
-
-import javax.script.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.sl.parser.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public final class SLScript {
-
-    private final SLContext context;
-    private final CallTarget main;
-
-    private SLScript(SLContext context, CallTarget mainFunction) {
-        this.context = context;
-        this.main = mainFunction;
-    }
-
-    public SLContext getContext() {
-        return context;
-    }
-
-    public CallTarget getMain() {
-        return main;
-    }
-
-    public Object run(Object... arguments) {
-        return main.call(null, new SLArguments(arguments));
-    }
-
-    @Override
-    public String toString() {
-        return main.toString();
-    }
-
-    public static SLScript create(SLContext context, Source source) throws ScriptException {
-        SLNodeFactory factory = new SLNodeFactory(context);
-        Parser parser = new Parser(new Scanner(source.getInputStream()), factory);
-        factory.setParser(parser);
-        factory.setSource(source);
-        String error = parser.ParseErrors();
-        if (!error.isEmpty()) {
-            throw new ScriptException(String.format("Error(s) parsing script: %s", error));
-        }
-
-        CallTarget main = context.getFunctionRegistry().lookup("main");
-        if (main == null) {
-            throw new ScriptException("No main function found.");
-        }
-        return new SLScript(context, main);
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLTypes.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl;
-
-import java.math.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.sl.runtime.*;
-
-@TypeSystem({int.class, BigInteger.class, boolean.class, String.class, CallTarget.class, SLNull.class, Object[].class})
-public class SLTypes {
-
-    @TypeCheck
-    public boolean isSLNull(Object value) {
-        return SLNull.INSTANCE == value;
-    }
-
-    @TypeCast
-    public SLNull asSLNull(Object value) {
-        assert isSLNull(value);
-        return SLNull.INSTANCE;
-    }
-
-    @ImplicitCast
-    public BigInteger castBigInteger(int integer) {
-        return BigInteger.valueOf(integer);
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SimpleLanguage.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl;
-
-import java.io.*;
-
-import javax.script.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.impl.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public class SimpleLanguage {
-
-    private static final Object[] NO_ARGUMENTS = new Object[0];
-
-    public static void main(String[] args) {
-        run(args[0], System.out, 10, true);
-    }
-
-    public static void run(String name, String input, PrintStream printOutput, int repeats, boolean log) {
-        if (log) {
-            // CheckStyle: stop system..print check
-            System.out.printf("== running on %s\n", Truffle.getRuntime().getName());
-            // CheckStyle: resume system..print check
-        }
-
-        final SLContext context = new SLContext(printOutput);
-        final Source source = context.getSourceManager().get(name, input);
-
-        run(context, source, printOutput, repeats, log);
-    }
-
-    public static void run(String fileName, PrintStream printOutput, int repeats, boolean log) {
-        if (log) {
-            // CheckStyle: stop system..print check
-            System.out.printf("== running on %s\n", Truffle.getRuntime().getName());
-            // CheckStyle: resume system..print check
-        }
-
-        final SLContext context = new SLContext(printOutput);
-        final Source source = context.getSourceManager().get(fileName);
-
-        run(context, source, printOutput, repeats, log);
-    }
-
-    public static void run(SLContext context, Source source, PrintStream printOutput, int repeats, boolean log) {
-
-        SLScript script;
-        try {
-            script = SLScript.create(context, source);
-        } catch (ScriptException e) {
-            // TODO temporary hack
-            throw new RuntimeException(e);
-        }
-
-        if (log) {
-            printScript(script);
-        }
-        try {
-            for (int i = 0; i < repeats; i++) {
-                long start = System.nanoTime();
-                Object result = script.run(NO_ARGUMENTS);
-                long end = System.nanoTime();
-
-                if (result != null) {
-                    printOutput.println(result);
-                }
-                if (log) {
-                    // CheckStyle: stop system..print check
-                    System.out.printf("== iteration %d: %.3f ms\n", (i + 1), (end - start) / 1000000.0);
-                    // CheckStyle: resume system..print check
-                }
-            }
-
-        } finally {
-            if (log) {
-                printScript(script);
-            }
-        }
-    }
-
-    private static void printScript(SLScript script) {
-        NodeUtil.printTree(System.out, ((DefaultCallTarget) script.getMain()).getRootNode());
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/BuiltinNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.builtins;
-
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.sl.nodes.*;
-import com.oracle.truffle.sl.runtime.*;
-
-@NodeField(name = "context", type = SLContext.class)
-@NodeChild(value = "arguments", type = TypedNode[].class)
-public abstract class BuiltinNode extends TypedNode {
-
-    public abstract SLContext getContext();
-
-    public abstract TypedNode[] getArguments();
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/DefaultBuiltins.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.builtins;
-
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.sl.nodes.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public abstract class DefaultBuiltins {
-
-    public static void install(SLContext c) {
-        installBuiltin(c, PrintBuiltinFactory.getInstance(), "print");
-        installBuiltin(c, TimeBuiltinFactory.getInstance(), "time");
-    }
-
-    private static void installBuiltin(SLContext context, NodeFactory<? extends BuiltinNode> factory, String name) {
-        context.getFunctionRegistry().register(name, FunctionRootNode.createBuiltin(context, factory, name));
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/PrintBuiltin.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.builtins;
-
-import com.oracle.truffle.api.dsl.*;
-
-public abstract class PrintBuiltin extends BuiltinNode {
-
-    @Specialization
-    public int doInt(int value) {
-        getContext().getPrintOutput().println(value);
-        return value;
-    }
-
-    @Specialization
-    public boolean doBoolean(boolean value) {
-        getContext().getPrintOutput().println(value);
-        return value;
-    }
-
-    @Specialization
-    public String doString(String value) {
-        getContext().getPrintOutput().println(value);
-        return value;
-    }
-
-    @Specialization
-    public Object doGeneric(Object value) {
-        getContext().getPrintOutput().println(value.toString());
-        return value;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.builtins;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+@NodeField(name = "context", type = SLContext.class)
+@NodeChild(value = "arguments", type = SLExpressionNode[].class)
+public abstract class SLBuiltinNode extends SLExpressionNode {
+
+    public abstract SLContext getContext();
+
+    public abstract SLExpressionNode[] getArguments();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLDefineFunctionBuiltin.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.builtins;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.parser.*;
+
+public abstract class SLDefineFunctionBuiltin extends SLBuiltinNode {
+
+    @Specialization
+    public String defineFunction(String code) {
+        Source source = getContext().getSourceManager().get("dynamic", code);
+        Parser.parseSL(getContext(), source);
+        return code;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLPrintBuiltin.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.builtins;
+
+import com.oracle.truffle.api.dsl.*;
+
+public abstract class SLPrintBuiltin extends SLBuiltinNode {
+
+    @Specialization
+    public long print(long value) {
+        getContext().getPrintOutput().println(value);
+        return value;
+    }
+
+    @Specialization
+    public boolean print(boolean value) {
+        getContext().getPrintOutput().println(value);
+        return value;
+    }
+
+    @Specialization
+    public String print(String value) {
+        getContext().getPrintOutput().println(value);
+        return value;
+    }
+
+    @Specialization
+    public Object print(Object value) {
+        getContext().getPrintOutput().println(value.toString());
+        return value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLTimeBuiltin.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.builtins;
+
+import com.oracle.truffle.api.dsl.*;
+
+public abstract class SLTimeBuiltin extends SLBuiltinNode {
+
+    public static final long START_TIME = System.currentTimeMillis();
+
+    @Specialization
+    public long time() {
+        return System.nanoTime();
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/TimeBuiltin.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.builtins;
-
-import com.oracle.truffle.api.dsl.*;
-
-public abstract class TimeBuiltin extends BuiltinNode {
-
-    public static final long START_TIME = System.currentTimeMillis();
-
-    @Specialization
-    public int doInt() {
-        return (int) (System.currentTimeMillis() - START_TIME);
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ArgumentsNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-public final class ArgumentsNode extends TypedNode {
-
-    @Children private final TypedNode[] arguments;
-
-    public ArgumentsNode(TypedNode[] arguments) {
-        this.arguments = adoptChildren(arguments);
-    }
-
-    public TypedNode[] getArguments() {
-        return arguments;
-    }
-
-    @Override
-    public Object[] executeGeneric(VirtualFrame frame) {
-        return executeArray(frame);
-    }
-
-    @Override
-    @ExplodeLoop
-    public Object[] executeArray(VirtualFrame frame) {
-        Object[] argumentValues = new Object[arguments.length];
-        for (int i = 0; i < arguments.length; i++) {
-            argumentValues[i] = arguments[i].executeGeneric(frame);
-        }
-        return argumentValues;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ArithmeticNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import java.math.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.dsl.*;
-
-public abstract class ArithmeticNode extends BinaryNode {
-
-    public abstract static class AddNode extends ArithmeticNode {
-
-        @Specialization(rewriteOn = ArithmeticException.class)
-        int doInt(int left, int right) {
-            return ExactMath.addExact(left, right);
-        }
-
-        @Specialization
-        BigInteger doBigInteger(BigInteger left, BigInteger right) {
-            return left.add(right);
-        }
-
-        @Specialization
-        String doString(String left, String right) {
-            return left + right;
-        }
-
-        @Specialization(guards = "isString")
-        String add(Object left, Object right) {
-            return left.toString() + right.toString();
-        }
-    }
-
-    public abstract static class SubNode extends ArithmeticNode {
-
-        @Specialization(rewriteOn = ArithmeticException.class)
-        int sub(int left, int right) {
-            return ExactMath.subtractExact(left, right);
-        }
-
-        @Specialization
-        BigInteger sub(BigInteger left, BigInteger right) {
-            return left.subtract(right);
-        }
-
-    }
-
-    public abstract static class DivNode extends ArithmeticNode {
-
-        @Specialization(rewriteOn = ArithmeticException.class)
-        int div(int left, int right) {
-            return left / right;
-        }
-
-        @Specialization
-        BigInteger div(BigInteger left, BigInteger right) {
-            return left.divide(right);
-        }
-    }
-
-    public abstract static class MulNode extends ArithmeticNode {
-
-        @Specialization(rewriteOn = ArithmeticException.class)
-        int mul(int left, int right) {
-            return ExactMath.multiplyExact(left, right);
-        }
-
-        @Specialization
-        BigInteger mul(BigInteger left, BigInteger right) {
-            return left.multiply(right);
-        }
-
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BigIntegerLiteralNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import java.math.*;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-public final class BigIntegerLiteralNode extends TypedNode {
-
-    private final BigInteger value;
-
-    public BigIntegerLiteralNode(BigInteger value) {
-        this.value = value;
-    }
-
-    @Override
-    public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException {
-        return value;
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        return value;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BinaryNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.dsl.*;
-
-@NodeChildren({@NodeChild("leftNode"), @NodeChild("rightNode")})
-public abstract class BinaryNode extends TypedNode {
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BlockNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-public class BlockNode extends StatementNode {
-
-    @Children private final StatementNode[] statements;
-
-    public BlockNode(StatementNode[] statements) {
-        this.statements = adoptChildren(statements);
-    }
-
-    @Override
-    @ExplodeLoop
-    public void executeVoid(VirtualFrame frame) {
-        for (StatementNode statement : statements) {
-            statement.executeVoid(frame);
-        }
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BreakException.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.nodes.*;
-
-public final class BreakException extends ControlFlowException {
-
-    private static final long serialVersionUID = -91013036379258890L;
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/BreakNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-
-public final class BreakNode extends StatementNode {
-
-    private final BreakException target;
-
-    public BreakNode(BreakException target) {
-        this.target = target;
-    }
-
-    @Override
-    public void executeVoid(VirtualFrame frame) {
-        throw target;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/CallNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.impl.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public abstract class CallNode extends TypedNode {
-
-    private static final int INLINE_CACHE_SIZE = 2;
-
-    @Child protected TypedNode functionNode;
-    @Child protected ArgumentsNode argumentsNode;
-
-    public CallNode(TypedNode functionNode, ArgumentsNode argumentsNode) {
-        this.functionNode = adoptChild(functionNode);
-        this.argumentsNode = adoptChild(argumentsNode);
-    }
-
-    @Override
-    public final Object executeGeneric(VirtualFrame frame) {
-        CallTarget function;
-        try {
-            function = functionNode.executeCallTarget(frame);
-        } catch (UnexpectedResultException e) {
-            throw new UnsupportedOperationException("Call to " + e.getMessage() + " not supported.");
-        }
-        Object[] arguments = argumentsNode.executeArray(frame);
-        return executeCall(frame, function, arguments);
-    }
-
-    public abstract Object executeCall(VirtualFrame frame, CallTarget function, Object[] arguments);
-
-    public static CallNode create(TypedNode function, TypedNode[] arguments) {
-        return new UninitializedCallNode(function, new ArgumentsNode(arguments), 0);
-    }
-
-    private static final class UninitializedCallNode extends CallNode {
-
-        protected final int depth;
-
-        UninitializedCallNode(TypedNode function, ArgumentsNode args, int depth) {
-            super(function, args);
-            this.depth = depth;
-        }
-
-        UninitializedCallNode(UninitializedCallNode copy) {
-            super(null, null);
-            this.depth = copy.depth + 1;
-        }
-
-        @Override
-        public Object executeCall(VirtualFrame frame, CallTarget function, Object[] arguments) {
-            CompilerDirectives.transferToInterpreter();
-            return specialize(function).executeCall(frame, function, arguments);
-        }
-
-        private CallNode specialize(CallTarget function) {
-            CompilerAsserts.neverPartOfCompilation();
-
-            if (depth < INLINE_CACHE_SIZE) {
-                DefaultCallTarget callTarget = (DefaultCallTarget) function;
-                FunctionRootNode root = (FunctionRootNode) callTarget.getRootNode();
-                CallNode next = new UninitializedCallNode(this);
-                InlinableDirectCallNode directCall = new InlinableDirectCallNode(functionNode, argumentsNode, next, callTarget);
-                replace(directCall);
-                if (root.isInlineImmediatly()) {
-                    return directCall.inlineImpl();
-                } else {
-                    return directCall;
-                }
-            } else {
-                CallNode topMost = (CallNode) NodeUtil.getNthParent(this, depth);
-                return topMost.replace(new GenericCallNode(topMost.functionNode, topMost.argumentsNode));
-            }
-        }
-
-    }
-
-    private abstract static class DirectCallNode extends CallNode {
-
-        protected final DefaultCallTarget cachedFunction;
-
-        @Child protected CallNode nextNode;
-
-        public DirectCallNode(TypedNode function, ArgumentsNode arguments, DefaultCallTarget cachedFunction, CallNode next) {
-            super(function, arguments);
-            this.cachedFunction = cachedFunction;
-            this.nextNode = adoptChild(next);
-        }
-
-        @Override
-        public Object executeCall(VirtualFrame frame, CallTarget function, Object[] arguments) {
-            if (this.cachedFunction == function) {
-                return executeCurrent(frame, arguments);
-            }
-            return nextNode.executeCall(frame, function, arguments);
-        }
-
-        protected abstract Object executeCurrent(VirtualFrame frame, Object[] arguments);
-
-    }
-
-    private static final class InlinableDirectCallNode extends DirectCallNode implements InlinableCallSite {
-
-        @CompilationFinal private int callCount;
-
-        InlinableDirectCallNode(TypedNode function, ArgumentsNode arguments, CallNode next, DefaultCallTarget cachedFunction) {
-            super(function, arguments, cachedFunction, next);
-        }
-
-        @Override
-        public Object executeCurrent(VirtualFrame frame, Object[] arguments) {
-            if (CompilerDirectives.inInterpreter()) {
-                callCount++;
-            }
-            return cachedFunction.call(frame.pack(), new SLArguments(arguments));
-        }
-
-        InlinedDirectCallNode inlineImpl() {
-            CompilerAsserts.neverPartOfCompilation();
-            RootNode root = cachedFunction.getRootNode();
-            TypedNode inlinedNode = ((FunctionRootNode) root).inline();
-            assert inlinedNode != null;
-            return replace(new InlinedDirectCallNode(this, inlinedNode), "Inlined " + root);
-        }
-
-        @Override
-        public boolean inline(FrameFactory factory) {
-            inlineImpl();
-            /* SL is always able to inline if required. */
-            return true;
-        }
-
-        @Override
-        public int getCallCount() {
-            return callCount;
-        }
-
-        @Override
-        public void resetCallCount() {
-            callCount = 0;
-        }
-
-        @Override
-        public Node getInlineTree() {
-            RootNode root = cachedFunction.getRootNode();
-            if (root instanceof FunctionRootNode) {
-                return ((FunctionRootNode) root).getUninitializedBody();
-            }
-            return null;
-        }
-
-        @Override
-        public CallTarget getCallTarget() {
-            return cachedFunction;
-        }
-
-    }
-
-    private static class InlinedDirectCallNode extends DirectCallNode implements InlinedCallSite {
-
-        private final FrameDescriptor descriptor;
-        @Child private TypedNode inlinedBody;
-
-        InlinedDirectCallNode(InlinableDirectCallNode prev, TypedNode inlinedBody) {
-            super(prev.functionNode, prev.argumentsNode, prev.cachedFunction, prev.nextNode);
-            this.descriptor = cachedFunction.getRootNode().getFrameDescriptor();
-            this.inlinedBody = adoptChild(inlinedBody);
-        }
-
-        @Override
-        public Object executeCurrent(VirtualFrame frame, Object[] arguments) {
-            SLArguments slArguments = new SLArguments(arguments);
-            VirtualFrame newFrame = Truffle.getRuntime().createVirtualFrame(frame.pack(), slArguments, descriptor);
-            return inlinedBody.executeGeneric(newFrame);
-        }
-
-        @Override
-        public CallTarget getCallTarget() {
-            return cachedFunction;
-        }
-
-    }
-
-    private static final class GenericCallNode extends CallNode {
-
-        GenericCallNode(TypedNode functionNode, ArgumentsNode arguments) {
-            super(functionNode, arguments);
-        }
-
-        @Override
-        public Object executeCall(VirtualFrame frame, CallTarget function, Object[] arguments) {
-            return function.call(frame.pack(), new SLArguments(arguments));
-        }
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ConditionNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-
-public abstract class ConditionNode extends StatementNode {
-
-    public abstract boolean executeCondition(VirtualFrame frame);
-
-    @Override
-    public void executeVoid(VirtualFrame frame) {
-        executeCondition(frame);
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ContinueException.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.nodes.*;
-
-public final class ContinueException extends ControlFlowException {
-
-    private static final long serialVersionUID = 5329687983726237188L;
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ContinueNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-
-public final class ContinueNode extends StatementNode {
-
-    private final ContinueException target;
-
-    public ContinueNode(ContinueException target) {
-        this.target = target;
-    }
-
-    @Override
-    public void executeVoid(VirtualFrame frame) {
-        throw target;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FrameSlotNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-
-public abstract class FrameSlotNode extends TypedNode {
-
-    protected final FrameSlot slot;
-
-    public FrameSlotNode(FrameSlot slot) {
-        this.slot = slot;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionBodyNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-public class FunctionBodyNode extends TypedNode {
-
-    @Child private StatementNode body;
-    @Child private TypedNode returnValue;
-    @Child private StatementNode writeArguments;
-
-    private FrameDescriptor frameDescriptor;
-
-    public FunctionBodyNode(FrameDescriptor frameDescriptor, StatementNode body, TypedNode returnValue, String[] parameterNames) {
-        this.frameDescriptor = frameDescriptor;
-        this.body = adoptChild(body);
-        this.returnValue = adoptChild(returnValue);
-        this.writeArguments = adoptChild(new BlockNode(createWriteArguments(parameterNames)));
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        writeArguments.executeVoid(frame);
-        try {
-            body.executeVoid(frame);
-        } catch (ReturnException ex) {
-            // Nothing to do, we just need to return.
-        }
-        if (returnValue != null) {
-            return returnValue.executeGeneric(frame);
-        } else {
-            return null;
-        }
-    }
-
-    @Override
-    public Node copy() {
-        FunctionBodyNode copy = (FunctionBodyNode) super.copy();
-        copy.frameDescriptor = frameDescriptor.shallowCopy();
-        return copy;
-    }
-
-    private StatementNode[] createWriteArguments(String[] parameterNames) {
-        StatementNode[] writeNodes = new StatementNode[parameterNames.length];
-        for (int i = 0; i < parameterNames.length; i++) {
-            FrameSlot frameSlot = frameDescriptor.findOrAddFrameSlot(parameterNames[i]);
-            writeNodes[i] = WriteLocalNodeFactory.create(frameSlot, new ReadArgumentNode(i));
-        }
-        return writeNodes;
-    }
-
-    public FrameDescriptor getFrameDescriptor() {
-        return frameDescriptor;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionRootNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.sl.builtins.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public final class FunctionRootNode extends RootNode {
-
-    @Child private TypedNode body;
-
-    private final TypedNode uninitializedBody;
-    private final String name;
-    private final boolean inlineImmediatly;
-
-    private FunctionRootNode(FrameDescriptor frameDescriptor, TypedNode body, String name, boolean inlineImmediatly) {
-        super(null, frameDescriptor);
-        this.uninitializedBody = NodeUtil.cloneNode(body);
-        this.body = adoptChild(body);
-        this.name = name;
-        this.inlineImmediatly = inlineImmediatly;
-    }
-
-    public static CallTarget createBuiltin(SLContext context, NodeFactory<? extends BuiltinNode> factory, String name) {
-        int argumentCount = factory.getExecutionSignature().size();
-        TypedNode[] arguments = new TypedNode[argumentCount];
-        for (int i = 0; i < arguments.length; i++) {
-            arguments[i] = new ReadArgumentNode(i);
-        }
-        BuiltinNode buitinBody = factory.createNode(arguments, context);
-        FunctionRootNode root = new FunctionRootNode(new FrameDescriptor(), buitinBody, name, true);
-        return Truffle.getRuntime().createCallTarget(root);
-    }
-
-    public static CallTarget createFunction(StatementNode body, FrameDescriptor frameDescriptor, String name, TypedNode returnValue, String[] parameterNames) {
-        FunctionBodyNode bodyContainer = new FunctionBodyNode(frameDescriptor, body, returnValue, parameterNames);
-        FunctionRootNode root = new FunctionRootNode(frameDescriptor, bodyContainer, name, false);
-        return Truffle.getRuntime().createCallTarget(root);
-    }
-
-    @Override
-    public Object execute(VirtualFrame frame) {
-        return body.executeGeneric(frame);
-    }
-
-    public boolean isInlineImmediatly() {
-        return inlineImmediatly;
-    }
-
-    public TypedNode inline() {
-        return NodeUtil.cloneNode(uninitializedBody);
-    }
-
-    public Node getUninitializedBody() {
-        return uninitializedBody;
-    }
-
-    @Override
-    public String toString() {
-        return "function " + name;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/IfNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.utilities.*;
-
-@NodeChild(value = "conditionNode", type = ConditionNode.class)
-public abstract class IfNode extends StatementNode {
-
-    @Child private StatementNode thenPartNode;
-    @Child private StatementNode elsePartNode;
-
-    private final BranchProfile ifBranch = new BranchProfile();
-    private final BranchProfile elseBranch = new BranchProfile();
-
-    public IfNode(StatementNode thenPart, StatementNode elsePart) {
-        this.thenPartNode = adoptChild(thenPart);
-        this.elsePartNode = adoptChild(elsePart);
-    }
-
-    protected IfNode(IfNode node) {
-        this(node.thenPartNode, node.elsePartNode);
-    }
-
-    @Specialization
-    public void doVoid(VirtualFrame frame, boolean condition) {
-        if (condition) {
-            ifBranch.enter();
-            thenPartNode.executeVoid(frame);
-        } else {
-            if (elsePartNode != null) {
-                elseBranch.enter();
-                elsePartNode.executeVoid(frame);
-            }
-        }
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/IntegerLiteralNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-public final class IntegerLiteralNode extends TypedNode {
-
-    private final int value;
-
-    public IntegerLiteralNode(int value) {
-        this.value = value;
-    }
-
-    @Override
-    public int executeInteger(VirtualFrame frame) throws UnexpectedResultException {
-        return value;
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        return value;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/LessThanNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import java.math.*;
-
-import com.oracle.truffle.api.dsl.*;
-
-public abstract class LessThanNode extends BinaryNode {
-
-    @Specialization
-    public boolean doInteger(int left, int right) {
-        return left < right;
-    }
-
-    @Specialization
-    public boolean doBigInteger(BigInteger left, BigInteger right) {
-        return left.compareTo(right) < 0;
-    }
-
-    @Specialization(guards = "isString")
-    public boolean doString(Object left, Object right) {
-        return left.toString().compareTo(right.toString()) < 0;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/LogicalAndNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.dsl.*;
-
-@SuppressWarnings("unused")
-public abstract class LogicalAndNode extends BinaryNode {
-
-    @ShortCircuit("rightNode")
-    public boolean needsRightNode(boolean left) {
-        return left;
-    }
-
-    @ShortCircuit("rightNode")
-    public boolean needsRightNode(Object left) {
-        return left instanceof Boolean && (Boolean) left;
-    }
-
-    @Specialization
-    public boolean doBoolean(boolean left, boolean hasRight, boolean right) {
-        return hasRight && right;
-    }
-
-    @Generic
-    public Object doGeneric(Object left, boolean hasRight, Object right) {
-        throw new RuntimeException("operation not defined for type " + left.getClass().getSimpleName());
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/NullLiteralNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public final class NullLiteralNode extends TypedNode {
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        return executeNull(frame);
-    }
-
-    @Override
-    public SLNull executeNull(VirtualFrame frame) {
-        return SLNull.INSTANCE;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadArgumentNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.utilities.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public class ReadArgumentNode extends TypedNode {
-
-    private final int index;
-
-    private final BranchProfile outOfBounds = new BranchProfile();
-    private final BranchProfile inBounds = new BranchProfile();
-
-    public ReadArgumentNode(int index) {
-        this.index = index;
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        Object[] args = SLArguments.get(frame).arguments;
-        if (index < args.length) {
-            inBounds.enter();
-            return args[index];
-        } else {
-            outOfBounds.enter();
-            return SLNull.INSTANCE;
-        }
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadFunctionNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.utilities.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public final class ReadFunctionNode extends TypedNode {
-
-    private final SLFunctionRegistry registry;
-    private final String name;
-    private final BranchProfile invalidFunction = new BranchProfile();
-
-    public ReadFunctionNode(SLFunctionRegistry registry, String name) {
-        this.registry = registry;
-        this.name = name;
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        return executeCallTarget(frame);
-    }
-
-    @Override
-    public CallTarget executeCallTarget(VirtualFrame frame) {
-        CallTarget target = registry.lookup(name);
-        if (target != null) {
-            return target;
-        }
-        invalidFunction.enter();
-        throw new RuntimeException("Function with name '" + name + "' not found.");
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadLocalNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.api.frame.*;
-
-@PolymorphicLimit(1)
-public abstract class ReadLocalNode extends FrameSlotNode {
-
-    public ReadLocalNode(FrameSlot slot) {
-        super(slot);
-    }
-
-    public ReadLocalNode(ReadLocalNode specialized) {
-        this(specialized.slot);
-    }
-
-    @Specialization(rewriteOn = {FrameSlotTypeException.class})
-    public int doInteger(VirtualFrame frame) throws FrameSlotTypeException {
-        return frame.getInt(slot);
-    }
-
-    @Specialization(rewriteOn = {FrameSlotTypeException.class})
-    public boolean doBoolean(VirtualFrame frame) throws FrameSlotTypeException {
-        return frame.getBoolean(slot);
-    }
-
-    @Specialization(rewriteOn = {FrameSlotTypeException.class})
-    public Object doObject(VirtualFrame frame) throws FrameSlotTypeException {
-        return frame.getObject(slot);
-    }
-
-    @Generic
-    public Object doGeneric(VirtualFrame frame) {
-        return frame.getValue(slot);
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadUninitializedNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public class ReadUninitializedNode extends TypedNode {
-
-    private final SLContext context;
-    private final FrameSlot slot;
-
-    public ReadUninitializedNode(SLContext context, FrameSlot slot) {
-        this.context = context;
-        this.slot = slot;
-    }
-
-    public FrameSlot getSlot() {
-        return slot;
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        CompilerDirectives.transferToInterpreter();
-        Object result = frame.getValue(slot);
-        String identifier = (String) slot.getIdentifier();
-        if (result == null) {
-            // function access
-            return replace(new ReadFunctionNode(context.getFunctionRegistry(), identifier)).executeGeneric(frame);
-        } else {
-            // local variable access
-            return replace(ReadLocalNodeFactory.create(slot)).executeGeneric(frame);
-        }
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReturnException.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.nodes.*;
-
-public final class ReturnException extends ControlFlowException {
-
-    private static final long serialVersionUID = 4073191346281369231L;
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReturnNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-
-public class ReturnNode extends StatementNode {
-
-    private static final ReturnException EXCEPTION = new ReturnException();
-
-    @Child private StatementNode expr;
-
-    public ReturnNode(StatementNode expr) {
-        this.expr = adoptChild(expr);
-    }
-
-    @Override
-    public void executeVoid(VirtualFrame frame) {
-        expr.executeVoid(frame);
-        throw EXCEPTION;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLBinaryNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes;
+
+import com.oracle.truffle.api.dsl.*;
+
+@NodeChildren({@NodeChild("leftNode"), @NodeChild("rightNode")})
+public abstract class SLBinaryNode extends SLExpressionNode {
+
+    public boolean isString(Object a, Object b) {
+        return a instanceof String || b instanceof String;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes;
+
+import java.math.*;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public abstract class SLExpressionNode extends SLStatementNode {
+
+    public abstract Object executeGeneric(VirtualFrame frame);
+
+    public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectBoolean(executeGeneric(frame));
+    }
+
+    public long executeLong(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectLong(executeGeneric(frame));
+    }
+
+    public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectBigInteger(executeGeneric(frame));
+    }
+
+    public String executeString(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectString(executeGeneric(frame));
+    }
+
+    public SLFunction executeFunction(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectSLFunction(executeGeneric(frame));
+    }
+
+    public Object[] executeArray(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectObjectArray(executeGeneric(frame));
+    }
+
+    public SLNull executeNull(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectSLNull(executeGeneric(frame));
+    }
+
+    public final boolean executeCondition(VirtualFrame frame) {
+        try {
+            return executeBoolean(frame);
+        } catch (UnexpectedResultException ex) {
+            throw new RuntimeException("Illegal type for condition: " + ex.getResult().getClass().getSimpleName());
+        }
+    }
+
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        executeGeneric(frame);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.builtins.*;
+import com.oracle.truffle.sl.nodes.controlflow.*;
+import com.oracle.truffle.sl.nodes.local.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public final class SLRootNode extends RootNode {
+
+    @Child private SLExpressionNode body;
+
+    private final SLExpressionNode uninitializedBody;
+    private final String name;
+    private final boolean inlineImmediatly;
+
+    public static RootCallTarget createFunction(String name, FrameDescriptor frameDescriptor, SLStatementNode body) {
+        SLFunctionBodyNode bodyContainer = new SLFunctionBodyNode(frameDescriptor, body);
+        SLRootNode root = new SLRootNode(frameDescriptor, bodyContainer, name, false);
+        return Truffle.getRuntime().createCallTarget(root);
+    }
+
+    public static RootCallTarget createBuiltin(SLContext context, NodeFactory<? extends SLBuiltinNode> factory, String name) {
+        int argumentCount = factory.getExecutionSignature().size();
+        SLExpressionNode[] arguments = new SLExpressionNode[argumentCount];
+        for (int i = 0; i < arguments.length; i++) {
+            arguments[i] = new SLReadArgumentNode(i);
+        }
+        SLBuiltinNode buitinBody = factory.createNode(arguments, context);
+        SLRootNode root = new SLRootNode(new FrameDescriptor(), buitinBody, name, true);
+        return Truffle.getRuntime().createCallTarget(root);
+    }
+
+    private SLRootNode(FrameDescriptor frameDescriptor, SLExpressionNode body, String name, boolean inlineImmediatly) {
+        super(null, frameDescriptor);
+        this.uninitializedBody = NodeUtil.cloneNode(body);
+        this.body = adoptChild(body);
+        this.name = name;
+        this.inlineImmediatly = inlineImmediatly;
+    }
+
+    @Override
+    public Object execute(VirtualFrame frame) {
+        return body.executeGeneric(frame);
+    }
+
+    public boolean isInlineImmediatly() {
+        return inlineImmediatly;
+    }
+
+    public SLExpressionNode inline() {
+        return NodeUtil.cloneNode(uninitializedBody);
+    }
+
+    public Node getUninitializedBody() {
+        return uninitializedBody;
+    }
+
+    @Override
+    public String toString() {
+        return "function " + name;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+@TypeSystemReference(SLTypes.class)
+public abstract class SLStatementNode extends Node {
+
+    public abstract void executeVoid(VirtualFrame frame);
+
+    @Override
+    public String toString() {
+        return getEncapsulatingSourceSection() != null ? getEncapsulatingSourceSection().toString() : super.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLTypes.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes;
+
+import java.math.*;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.runtime.*;
+
+@TypeSystem({long.class, BigInteger.class, boolean.class, String.class, SLFunction.class, SLNull.class, Object[].class})
+public class SLTypes {
+
+    @TypeCheck
+    public boolean isSLNull(Object value) {
+        return SLNull.INSTANCE == value;
+    }
+
+    @TypeCast
+    public SLNull asSLNull(Object value) {
+        assert isSLNull(value);
+        return SLNull.INSTANCE;
+    }
+
+    @ImplicitCast
+    public BigInteger castBigInteger(long value) {
+        return BigInteger.valueOf(value);
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/StatementNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.sl.*;
-
-public abstract class StatementNode extends SLNode {
-
-    public abstract void executeVoid(VirtualFrame frame);
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/StringLiteralNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-
-public final class StringLiteralNode extends TypedNode {
-
-    private final String value;
-
-    public StringLiteralNode(String value) {
-        this.value = value;
-    }
-
-    @Override
-    public String executeString(VirtualFrame frame) {
-        return value;
-    }
-
-    @Override
-    public Object executeGeneric(VirtualFrame frame) {
-        return value;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TernaryNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *  
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import java.math.*;
-
-import com.oracle.truffle.api.dsl.*;
-
-@SuppressWarnings("unused")
-@NodeChildren({@NodeChild(value = "conditionNode", type = ConditionNode.class), @NodeChild("ifPartNode"), @NodeChild("elsePartNode")})
-public abstract class TernaryNode extends TypedNode {
-
-    @ShortCircuit("ifPartNode")
-    public boolean needsIfPart(boolean condition) {
-        return condition;
-    }
-
-    @ShortCircuit("elsePartNode")
-    public boolean needsElsePart(boolean condition, boolean hasIfPart, Object ifPart) {
-        return !hasIfPart;
-    }
-
-    @Specialization
-    public int doInteger(boolean condition, boolean hasIfPart, int ifPart, boolean hasElsePart, int elsePart) {
-        return hasIfPart ? ifPart : elsePart;
-    }
-
-    @Specialization
-    public BigInteger doBigInteger(boolean condition, boolean hasIfPart, BigInteger ifPart, boolean hasElsePart, BigInteger elsePart) {
-        return hasIfPart ? ifPart : elsePart;
-    }
-
-    @Specialization
-    public Object doObject(boolean condition, boolean hasIfPart, Object ifPart, boolean hasElsePart, Object elsePart) {
-        return hasIfPart ? ifPart : elsePart;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TypedNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import java.math.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.sl.*;
-import com.oracle.truffle.sl.runtime.*;
-
-public abstract class TypedNode extends ConditionNode {
-
-    @Override
-    public final boolean executeCondition(VirtualFrame frame) {
-        try {
-            return executeBoolean(frame);
-        } catch (UnexpectedResultException ex) {
-            throw new RuntimeException("Illegal type for condition: " + ex.getResult().getClass().getSimpleName());
-        }
-    }
-
-    public abstract Object executeGeneric(VirtualFrame frame);
-
-    public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectBoolean(executeGeneric(frame));
-    }
-
-    public int executeInteger(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectInteger(executeGeneric(frame));
-    }
-
-    public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectBigInteger(executeGeneric(frame));
-    }
-
-    public String executeString(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectString(executeGeneric(frame));
-    }
-
-    public CallTarget executeCallTarget(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectCallTarget(executeGeneric(frame));
-    }
-
-    public Object[] executeArray(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectObjectArray(executeGeneric(frame));
-    }
-
-    public SLNull executeNull(VirtualFrame frame) throws UnexpectedResultException {
-        return SLTypesGen.SLTYPES.expectSLNull(executeGeneric(frame));
-    }
-
-    @Override
-    public final void executeVoid(VirtualFrame frame) {
-        executeGeneric(frame);
-    }
-
-    public boolean isString(Object a, Object b) {
-        return a instanceof String || b instanceof String;
-    }
-
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WhileNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.utilities.*;
-
-public class WhileNode extends StatementNode {
-
-    @Child private ConditionNode condition;
-
-    @Child private StatementNode body;
-
-    private final BreakException breakTarget;
-    private final ContinueException continueTarget;
-
-    private final BranchProfile continueMismatch = new BranchProfile();
-    private final BranchProfile continueMatch = new BranchProfile();
-    private final BranchProfile breakMismatch = new BranchProfile();
-    private final BranchProfile breakMatch = new BranchProfile();
-
-    public WhileNode(ConditionNode condition, StatementNode body) {
-        this.condition = adoptChild(condition);
-        this.body = adoptChild(body);
-
-        this.breakTarget = new BreakException();
-        this.continueTarget = new ContinueException();
-    }
-
-    @Override
-    public void executeVoid(VirtualFrame frame) {
-        try {
-            while (condition.executeCondition(frame)) {
-                try {
-                    body.executeVoid(frame);
-                } catch (ContinueException ex) {
-                    if (ex != continueTarget) {
-                        continueMismatch.enter();
-                        throw ex;
-                    }
-                    continueMatch.enter();
-                    // Fall through to next loop iteration.
-                }
-            }
-        } catch (BreakException ex) {
-            if (ex != breakTarget) {
-                breakMismatch.enter();
-                throw ex;
-            }
-            breakMatch.enter();
-            // Done executing this loop, exit method to execute statement following the loop.
-        }
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java	Fri Jan 24 18:13:38 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.sl.nodes;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.api.frame.*;
-
-@NodeChild(value = "rightNode", type = TypedNode.class)
-public abstract class WriteLocalNode extends FrameSlotNode {
-
-    public WriteLocalNode(FrameSlot slot) {
-        super(slot);
-    }
-
-    public WriteLocalNode(WriteLocalNode node) {
-        this(node.slot);
-    }
-
-    @Specialization(guards = "isIntKind")
-    public int write(VirtualFrame frame, int right) {
-        frame.setInt(slot, right);
-        return right;
-    }
-
-    @Specialization(guards = "isBooleanKind")
-    public boolean write(VirtualFrame frame, boolean right) {
-        frame.setBoolean(slot, right);
-        return right;
-    }
-
-    @Specialization(guards = "isObjectKind")
-    public Object writeGeneric(VirtualFrame frame, Object right) {
-        frame.setObject(slot, right);
-        return right;
-    }
-
-    protected final boolean isIntKind() {
-        return isKind(FrameSlotKind.Int);
-    }
-
-    protected final boolean isBooleanKind() {
-        return isKind(FrameSlotKind.Boolean);
-    }
-
-    protected final boolean isObjectKind() {
-        if (slot.getKind() != FrameSlotKind.Object) {
-            CompilerDirectives.transferToInterpreter();
-            slot.setKind(FrameSlotKind.Object);
-        }
-        return true;
-    }
-
-    private boolean isKind(FrameSlotKind kind) {
-        return slot.getKind() == kind || initialSetKind(kind);
-    }
-
-    private boolean initialSetKind(FrameSlotKind kind) {
-        if (slot.getKind() == FrameSlotKind.Illegal) {
-            CompilerDirectives.transferToInterpreter();
-            slot.setKind(kind);
-            return true;
-        }
-        return false;
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLAbstractDispatchNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+abstract class SLAbstractDispatchNode extends Node {
+
+    protected static final int INLINE_CACHE_SIZE = 2;
+
+    protected abstract Object executeCall(VirtualFrame frame, SLFunction function, SLArguments arguments);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLArgumentsNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public final class SLArgumentsNode extends SLExpressionNode {
+
+    @Children private final SLExpressionNode[] arguments;
+
+    public SLArgumentsNode(SLExpressionNode[] arguments) {
+        this.arguments = adoptChildren(arguments);
+    }
+
+    public SLExpressionNode[] getArguments() {
+        return arguments;
+    }
+
+    @Override
+    public Object[] executeGeneric(VirtualFrame frame) {
+        return executeArray(frame);
+    }
+
+    @Override
+    @ExplodeLoop
+    public Object[] executeArray(VirtualFrame frame) {
+        Object[] argumentValues = new Object[arguments.length];
+        for (int i = 0; i < arguments.length; i++) {
+            argumentValues[i] = arguments[i].executeGeneric(frame);
+        }
+        return argumentValues;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public final class SLCallNode extends SLExpressionNode {
+
+    public static SLCallNode create(SLExpressionNode function, SLExpressionNode[] arguments) {
+        return new SLCallNode(function, arguments, new SLUninitializedCallNode());
+    }
+
+    @Child protected SLExpressionNode functionNode;
+    @Children protected final SLExpressionNode[] argumentNodes;
+    @Child protected SLAbstractDispatchNode dispatchNode;
+
+    private SLCallNode(SLExpressionNode functionNode, SLExpressionNode[] argumentNodes, SLAbstractDispatchNode dispatchNode) {
+        this.functionNode = adoptChild(functionNode);
+        this.argumentNodes = adoptChildren(argumentNodes);
+        this.dispatchNode = adoptChild(dispatchNode);
+    }
+
+    @Override
+    @ExplodeLoop
+    public Object executeGeneric(VirtualFrame frame) {
+        SLFunction function;
+        try {
+            function = functionNode.executeFunction(frame);
+        } catch (UnexpectedResultException e) {
+            throw new UnsupportedOperationException("Call to " + e.getMessage() + " not supported.");
+        }
+
+        Object[] argumentValues = new Object[argumentNodes.length];
+        for (int i = 0; i < argumentNodes.length; i++) {
+            argumentValues[i] = argumentNodes[i].executeGeneric(frame);
+        }
+        SLArguments arguments = new SLArguments(argumentValues);
+
+        return dispatchNode.executeCall(frame, function, arguments);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+abstract class SLDirectDispatchNode extends SLAbstractDispatchNode {
+
+    protected final SLFunction cachedFunction;
+    protected final RootCallTarget cachedCallTarget;
+    protected final Assumption cachedCallTargetStable;
+
+    @Child protected SLAbstractDispatchNode nextNode;
+
+    protected SLDirectDispatchNode(SLAbstractDispatchNode next, SLFunction cachedFunction) {
+        this.cachedFunction = cachedFunction;
+        this.cachedCallTarget = cachedFunction.getCallTarget();
+        this.cachedCallTargetStable = cachedFunction.getCallTargetStable();
+        this.nextNode = adoptChild(next);
+    }
+
+    @Override
+    protected final Object executeCall(VirtualFrame frame, SLFunction function, SLArguments arguments) {
+        if (this.cachedFunction == function) {
+            try {
+                cachedCallTargetStable.check();
+                return executeCurrent(frame, arguments);
+            } catch (InvalidAssumptionException ex) {
+                /*
+                 * Remove ourselfs from the polymorphic inline cache, so that we fail the check only
+                 * once.
+                 */
+                replace(nextNode);
+                /*
+                 * Execute the next node in the chain by falling out of the if block.
+                 */
+            }
+        }
+        return nextNode.executeCall(frame, function, arguments);
+    }
+
+    protected abstract Object executeCurrent(VirtualFrame frame, SLArguments arguments);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLGenericDispatchNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.runtime.*;
+
+final class SLGenericDispatchNode extends SLAbstractDispatchNode {
+
+    @Override
+    protected Object executeCall(VirtualFrame frame, SLFunction function, SLArguments arguments) {
+        return function.getCallTarget().call(frame.pack(), arguments);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInlinableDirectDispatchNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+final class SLInlinableDirectDispatchNode extends SLDirectDispatchNode implements InlinableCallSite {
+
+    @CompilationFinal private int callCount;
+
+    protected SLInlinableDirectDispatchNode(SLAbstractDispatchNode next, SLFunction cachedFunction) {
+        super(next, cachedFunction);
+    }
+
+    @Override
+    protected Object executeCurrent(VirtualFrame frame, SLArguments arguments) {
+        if (CompilerDirectives.inInterpreter()) {
+            callCount++;
+        }
+        return cachedCallTarget.call(frame.pack(), arguments);
+    }
+
+    @Override
+    public boolean inline(FrameFactory factory) {
+        CompilerAsserts.neverPartOfCompilation();
+        RootNode root = cachedCallTarget.getRootNode();
+        SLExpressionNode inlinedNode = ((SLRootNode) root).inline();
+        assert inlinedNode != null;
+        replace(new SLInlinedDirectDispatchNode(this, inlinedNode), "Inlined " + root);
+        /* We are always able to inline if required. */
+        return true;
+    }
+
+    @Override
+    public int getCallCount() {
+        return callCount;
+    }
+
+    @Override
+    public void resetCallCount() {
+        callCount = 0;
+    }
+
+    @Override
+    public Node getInlineTree() {
+        RootNode root = cachedCallTarget.getRootNode();
+        if (root instanceof SLRootNode) {
+            return ((SLRootNode) root).getUninitializedBody();
+        }
+        return null;
+    }
+
+    @Override
+    public CallTarget getCallTarget() {
+        return cachedCallTarget;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInlinedDirectDispatchNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+final class SLInlinedDirectDispatchNode extends SLDirectDispatchNode implements InlinedCallSite {
+
+    private final FrameDescriptor descriptor;
+    @Child private SLExpressionNode inlinedBody;
+
+    protected SLInlinedDirectDispatchNode(SLInlinableDirectDispatchNode prev, SLExpressionNode inlinedBody) {
+        super(prev.nextNode, prev.cachedFunction);
+        this.descriptor = cachedCallTarget.getRootNode().getFrameDescriptor();
+        this.inlinedBody = adoptChild(inlinedBody);
+    }
+
+    @Override
+    protected Object executeCurrent(VirtualFrame frame, SLArguments arguments) {
+        VirtualFrame newFrame = Truffle.getRuntime().createVirtualFrame(frame.pack(), arguments, descriptor);
+        return inlinedBody.executeGeneric(newFrame);
+    }
+
+    @Override
+    public CallTarget getCallTarget() {
+        return cachedCallTarget;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLUninitializedCallNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.call;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.runtime.*;
+
+final class SLUninitializedCallNode extends SLAbstractDispatchNode {
+
+    @Override
+    protected Object executeCall(VirtualFrame frame, SLFunction function, SLArguments arguments) {
+        CompilerDirectives.transferToInterpreterAndInvalidate();
+
+        SLAbstractDispatchNode cur = this;
+        int depth = 0;
+        while (cur.getParent() instanceof SLAbstractDispatchNode) {
+            cur = (SLAbstractDispatchNode) cur.getParent();
+            depth++;
+        }
+        SLCallNode callNode = (SLCallNode) cur.getParent();
+
+        SLAbstractDispatchNode specialized;
+        if (depth < INLINE_CACHE_SIZE) {
+            SLAbstractDispatchNode next = new SLUninitializedCallNode();
+            SLAbstractDispatchNode direct = new SLInlinableDirectDispatchNode(next, function);
+            specialized = replace(direct);
+        } else {
+            SLAbstractDispatchNode generic = new SLGenericDispatchNode();
+            specialized = callNode.dispatchNode.replace(generic);
+        }
+
+        return specialized.executeCall(frame, function, arguments);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public class SLBlockNode extends SLStatementNode {
+
+    @Children private final SLStatementNode[] statements;
+
+    public SLBlockNode(SLStatementNode[] statements) {
+        this.statements = adoptChildren(statements);
+    }
+
+    @Override
+    @ExplodeLoop
+    public void executeVoid(VirtualFrame frame) {
+        for (SLStatementNode statement : statements) {
+            statement.executeVoid(frame);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBreakException.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.nodes.*;
+
+public final class SLBreakException extends ControlFlowException {
+
+    public static final SLBreakException SINGLETON = new SLBreakException();
+
+    private static final long serialVersionUID = -91013036379258890L;
+
+    private SLBreakException() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBreakNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public final class SLBreakNode extends SLStatementNode {
+
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        throw SLBreakException.SINGLETON;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLContinueException.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.nodes.*;
+
+public final class SLContinueException extends ControlFlowException {
+
+    public static final SLContinueException SINGLETON = new SLContinueException();
+
+    private static final long serialVersionUID = 5329687983726237188L;
+
+    private SLContinueException() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLContinueNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public final class SLContinueNode extends SLStatementNode {
+
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        throw SLContinueException.SINGLETON;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public class SLFunctionBodyNode extends SLExpressionNode {
+
+    @Child private SLStatementNode body;
+
+    private FrameDescriptor frameDescriptor;
+
+    public SLFunctionBodyNode(FrameDescriptor frameDescriptor, SLStatementNode body) {
+        this.frameDescriptor = frameDescriptor;
+        this.body = adoptChild(body);
+    }
+
+    @Override
+    public Object executeGeneric(VirtualFrame frame) {
+        try {
+            body.executeVoid(frame);
+        } catch (SLReturnException ex) {
+            return ex.getResult();
+        }
+        return SLNull.INSTANCE;
+    }
+
+    @Override
+    public Node copy() {
+        SLFunctionBodyNode copy = (SLFunctionBodyNode) super.copy();
+        copy.frameDescriptor = frameDescriptor.shallowCopy();
+        return copy;
+    }
+
+    public FrameDescriptor getFrameDescriptor() {
+        return frameDescriptor;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public class SLIfNode extends SLStatementNode {
+    @Child private SLExpressionNode conditionNode;
+    @Child private SLStatementNode thenPartNode;
+    @Child private SLStatementNode elsePartNode;
+
+    private final BranchProfile thenTaken = new BranchProfile();
+    private final BranchProfile elseTaken = new BranchProfile();
+
+    public SLIfNode(SLExpressionNode conditionNode, SLStatementNode thenPartNode, SLStatementNode elsePartNode) {
+        this.conditionNode = adoptChild(conditionNode);
+        this.thenPartNode = adoptChild(thenPartNode);
+        this.elsePartNode = adoptChild(elsePartNode);
+    }
+
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        if (conditionNode.executeCondition(frame)) {
+            thenTaken.enter();
+            thenPartNode.executeVoid(frame);
+        } else {
+            if (elsePartNode != null) {
+                elseTaken.enter();
+                elsePartNode.executeVoid(frame);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnException.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.nodes.*;
+
+public final class SLReturnException extends ControlFlowException {
+
+    private static final long serialVersionUID = 4073191346281369231L;
+
+    private final Object result;
+
+    public SLReturnException(Object result) {
+        this.result = result;
+    }
+
+    public Object getResult() {
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public class SLReturnNode extends SLStatementNode {
+
+    @Child private SLExpressionNode expr;
+
+    public SLReturnNode(SLExpressionNode expr) {
+        this.expr = adoptChild(expr);
+    }
+
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        Object result = expr.executeGeneric(frame);
+        throw new SLReturnException(result);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.controlflow;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public class SLWhileNode extends SLStatementNode {
+
+    @Child private SLExpressionNode condition;
+    @Child private SLStatementNode body;
+
+    private final BranchProfile continueTaken = new BranchProfile();
+    private final BranchProfile breakTaken = new BranchProfile();
+
+    public SLWhileNode(SLExpressionNode condition, SLStatementNode body) {
+        this.condition = adoptChild(condition);
+        this.body = adoptChild(body);
+    }
+
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        try {
+            while (condition.executeCondition(frame)) {
+                try {
+                    body.executeVoid(frame);
+                } catch (SLContinueException ex) {
+                    continueTaken.enter();
+                    /* Fall through to next loop iteration. */
+                }
+            }
+        } catch (SLBreakException ex) {
+            breakTaken.enter();
+            /* Done executing this loop, exit method to execute statement following the loop. */
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLAddNode extends SLBinaryNode {
+
+    @Specialization(rewriteOn = ArithmeticException.class)
+    long add(long left, long right) {
+        return ExactMath.addExact(left, right);
+    }
+
+    @Specialization
+    BigInteger add(BigInteger left, BigInteger right) {
+        return left.add(right);
+    }
+
+    @Specialization
+    String add(String left, String right) {
+        return left + right;
+    }
+
+    @Specialization(guards = "isString")
+    String add(Object left, Object right) {
+        return left.toString() + right.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLBigIntegerLiteralNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public final class SLBigIntegerLiteralNode extends SLExpressionNode {
+
+    private final BigInteger value;
+
+    public SLBigIntegerLiteralNode(BigInteger value) {
+        this.value = value;
+    }
+
+    @Override
+    public BigInteger executeBigInteger(VirtualFrame frame) {
+        return value;
+    }
+
+    @Override
+    public Object executeGeneric(VirtualFrame frame) {
+        return value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLDivNode extends SLBinaryNode {
+
+    @Specialization(rewriteOn = ArithmeticException.class)
+    long div(long left, long right) {
+        return left / right;
+    }
+
+    @Specialization
+    BigInteger div(BigInteger left, BigInteger right) {
+        return left.divide(right);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLEqualNode extends SLBinaryNode {
+
+    @Specialization
+    public boolean equal(long left, long right) {
+        return left == right;
+    }
+
+    @Specialization
+    public boolean equal(boolean left, boolean right) {
+        return left == right;
+    }
+
+    @Generic
+    public boolean equal(Object left, Object right) {
+        return left.equals(right);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public final class SLFunctionLiteralNode extends SLExpressionNode {
+
+    private final SLFunction value;
+
+    public SLFunctionLiteralNode(SLFunction value) {
+        this.value = value;
+    }
+
+    @Override
+    public SLFunction executeFunction(VirtualFrame frame) {
+        return value;
+    }
+
+    @Override
+    public Object executeGeneric(VirtualFrame frame) {
+        return value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLLessOrEqualNode extends SLBinaryNode {
+
+    @Specialization
+    public boolean lessOrEqual(long left, long right) {
+        return left <= right;
+    }
+
+    @Specialization
+    public boolean lessOrEqual(BigInteger left, BigInteger right) {
+        return left.compareTo(right) <= 0;
+    }
+
+    @Specialization(guards = "isString")
+    public boolean lessOrEqual(Object left, Object right) {
+        return left.toString().compareTo(right.toString()) <= 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLLessThanNode extends SLBinaryNode {
+
+    @Specialization
+    public boolean lessThan(long left, long right) {
+        return left < right;
+    }
+
+    @Specialization
+    public boolean lessThan(BigInteger left, BigInteger right) {
+        return left.compareTo(right) < 0;
+    }
+
+    @Specialization(guards = "isString")
+    public boolean lessThan(Object left, Object right) {
+        return left.toString().compareTo(right.toString()) < 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalAndNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+@SuppressWarnings("unused")
+public abstract class SLLogicalAndNode extends SLBinaryNode {
+
+    @ShortCircuit("rightNode")
+    public boolean needsRightNode(boolean left) {
+        return left;
+    }
+
+    @ShortCircuit("rightNode")
+    public boolean needsRightNode(Object left) {
+        return left instanceof Boolean && needsRightNode(((Boolean) left).booleanValue());
+    }
+
+    @Specialization
+    public boolean doBoolean(boolean left, boolean hasRight, boolean right) {
+        return left && right;
+    }
+
+    @Generic
+    public Object doGeneric(Object left, boolean hasRight, Object right) {
+        throw new RuntimeException("operation not defined for type " + left.getClass().getSimpleName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalOrNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+@SuppressWarnings("unused")
+public abstract class SLLogicalOrNode extends SLBinaryNode {
+
+    @ShortCircuit("rightNode")
+    public boolean needsRightNode(boolean left) {
+        return !left;
+    }
+
+    @ShortCircuit("rightNode")
+    public boolean needsRightNode(Object left) {
+        return left instanceof Boolean && needsRightNode(((Boolean) left).booleanValue());
+    }
+
+    @Specialization
+    public boolean doBoolean(boolean left, boolean hasRight, boolean right) {
+        return left || right;
+    }
+
+    @Generic
+    public Object doGeneric(Object left, boolean hasRight, Object right) {
+        throw new RuntimeException("operation not defined for type " + left.getClass().getSimpleName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLongLiteralNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public final class SLLongLiteralNode extends SLExpressionNode {
+
+    private final long value;
+
+    public SLLongLiteralNode(long value) {
+        this.value = value;
+    }
+
+    @Override
+    public long executeLong(VirtualFrame frame) throws UnexpectedResultException {
+        return value;
+    }
+
+    @Override
+    public Object executeGeneric(VirtualFrame frame) {
+        return value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLMulNode extends SLBinaryNode {
+
+    @Specialization(rewriteOn = ArithmeticException.class)
+    long mul(long left, long right) {
+        return ExactMath.multiplyExact(left, right);
+    }
+
+    @Specialization
+    BigInteger mul(BigInteger left, BigInteger right) {
+        return left.multiply(right);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLNotEqualNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLNotEqualNode extends SLBinaryNode {
+
+    @Specialization
+    public boolean notEqual(long left, long right) {
+        return left != right;
+    }
+
+    @Specialization
+    public boolean notEqual(boolean left, boolean right) {
+        return left != right;
+    }
+
+    @Generic
+    public boolean equal(Object left, Object right) {
+        return !left.equals(right);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLStringLiteralNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public final class SLStringLiteralNode extends SLExpressionNode {
+
+    private final String value;
+
+    public SLStringLiteralNode(String value) {
+        this.value = value;
+    }
+
+    @Override
+    public String executeString(VirtualFrame frame) {
+        return value;
+    }
+
+    @Override
+    public Object executeGeneric(VirtualFrame frame) {
+        return value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.expression;
+
+import java.math.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.sl.nodes.*;
+
+public abstract class SLSubNode extends SLBinaryNode {
+
+    @Specialization(rewriteOn = ArithmeticException.class)
+    long sub(long left, long right) {
+        return ExactMath.subtractExact(left, right);
+    }
+
+    @Specialization
+    BigInteger sub(BigInteger left, BigInteger right) {
+        return left.subtract(right);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/ReadLocalNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.local;
+
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+@PolymorphicLimit(1)
+public abstract class ReadLocalNode extends SLExpressionNode {
+
+    private final FrameSlot slot;
+
+    public ReadLocalNode(FrameSlot slot) {
+        this.slot = slot;
+    }
+
+    public ReadLocalNode(ReadLocalNode specialized) {
+        this(specialized.slot);
+    }
+
+    @Specialization(rewriteOn = {FrameSlotTypeException.class})
+    public long readLong(VirtualFrame frame) throws FrameSlotTypeException {
+        return frame.getLong(slot);
+    }
+
+    @Specialization(rewriteOn = {FrameSlotTypeException.class})
+    public boolean readBoolean(VirtualFrame frame) throws FrameSlotTypeException {
+        return frame.getBoolean(slot);
+    }
+
+    @Specialization(rewriteOn = {FrameSlotTypeException.class})
+    public Object readObject(VirtualFrame frame) throws FrameSlotTypeException {
+        return frame.getObject(slot);
+    }
+
+    @Generic
+    public Object doGeneric(VirtualFrame frame) {
+        return frame.getValue(slot);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.local;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public class SLReadArgumentNode extends SLExpressionNode {
+
+    private final int index;
+
+    private final BranchProfile outOfBounds = new BranchProfile();
+
+    public SLReadArgumentNode(int index) {
+        this.index = index;
+    }
+
+    @Override
+    public Object executeGeneric(VirtualFrame frame) {
+        Object[] args = SLArguments.getFromFrame(frame);
+        if (index < args.length) {
+            return args[index];
+        } else {
+            outOfBounds.enter();
+            return SLNull.INSTANCE;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/WriteLocalNode.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.nodes.local;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.sl.nodes.*;
+
+@NodeChild(value = "rightNode", type = SLExpressionNode.class)
+public abstract class WriteLocalNode extends SLExpressionNode {
+
+    private final FrameSlot slot;
+
+    public WriteLocalNode(FrameSlot slot) {
+        this.slot = slot;
+    }
+
+    public WriteLocalNode(WriteLocalNode node) {
+        this(node.slot);
+    }
+
+    @Specialization(guards = "isLongKind")
+    protected final long write(VirtualFrame frame, long right) {
+        frame.setLong(slot, right);
+        return right;
+    }
+
+    @Specialization(guards = "isBooleanKind")
+    protected final boolean write(VirtualFrame frame, boolean right) {
+        frame.setBoolean(slot, right);
+        return right;
+    }
+
+    @Specialization(guards = "isObjectKind")
+    protected final Object writeGeneric(VirtualFrame frame, Object right) {
+        frame.setObject(slot, right);
+        return right;
+    }
+
+    protected final boolean isLongKind() {
+        return isKind(FrameSlotKind.Long);
+    }
+
+    protected final boolean isBooleanKind() {
+        return isKind(FrameSlotKind.Boolean);
+    }
+
+    protected final boolean isObjectKind() {
+        if (slot.getKind() != FrameSlotKind.Object) {
+            CompilerDirectives.transferToInterpreter();
+            slot.setKind(FrameSlotKind.Object);
+        }
+        return true;
+    }
+
+    private boolean isKind(FrameSlotKind kind) {
+        return slot.getKind() == kind || initialSetKind(kind);
+    }
+
+    private boolean initialSetKind(FrameSlotKind kind) {
+        if (slot.getKind() == FrameSlotKind.Illegal) {
+            CompilerDirectives.transferToInterpreter();
+            slot.setKind(kind);
+            return true;
+        }
+        return false;
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.frame	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.frame	Fri Jan 24 18:16:24 2014 -0800
@@ -30,8 +30,10 @@
 
 import java.util.*;
 
+import com.oracle.truffle.api.*;
 import com.oracle.truffle.sl.*;
 import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
 
 // Checkstyle: stop
 // @formatter:off
@@ -49,9 +51,9 @@
     public final Errors errors;
     private final SLNodeFactory factory;
     -->declarations
-    public Parser(Scanner scanner, SLNodeFactory factory) {
-        this.scanner = scanner;
-        this.factory = factory;
+    public Parser(SLContext context, Source source) {
+        this.scanner = new Scanner(source.getInputStream());
+        this.factory = new SLNodeFactory(context, source, this);
         errors = new Errors();
     }
 
@@ -132,28 +134,22 @@
 -->initialization
     };
 
-    public String ParseErrors() {
-        java.io.PrintStream oldStream = System.out;
-
-        java.io.OutputStream out = new java.io.ByteArrayOutputStream();
-        java.io.PrintStream newStream = new java.io.PrintStream(out);
-
-        errors.errorStream = newStream;
-
-        Parse();
-
-        String errorStream = out.toString();
-        errors.errorStream = oldStream;
-
-        return errorStream;
-
+    public static void parseSL(SLContext context, Source source) {
+        Parser parser = new Parser(context, source);
+        parser.Parse();
+        if (parser.errors.errors.size() > 0) {
+            StringBuilder msg = new StringBuilder("Error(s) parsing script:\n");
+            for (String error : parser.errors.errors) {
+                msg.append(error).append("\n");
+            }
+            throw new SLException(msg.toString());
+        }
     }
 } // end Parser
 
 class Errors {
 
-    public int count = 0; // number of errors detected
-    public java.io.PrintStream errorStream = System.out; // error messages go to this stream
+    protected final List<String> errors = new ArrayList<>();
     public String errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
 
     protected void printMsg(int line, int column, String msg) {
@@ -171,7 +167,7 @@
         pos = b.indexOf("{2}");
         if (pos >= 0)
             b.replace(pos, pos + 3, msg);
-        errorStream.println(b.toString());
+        errors.add(b.toString());
     }
 
     public void SynErr(int line, int col, int n) {
@@ -182,17 +178,14 @@
                 break;
         }
         printMsg(line, col, s);
-        count++;
     }
 
     public void SemErr(int line, int col, String s) {
         printMsg(line, col, s);
-        count++;
     }
 
     public void SemErr(String s) {
-        errorStream.println(s);
-        count++;
+        errors.add(s);
     }
 
     public void Warning(int line, int col, String s) {
@@ -200,7 +193,7 @@
     }
 
     public void Warning(String s) {
-        errorStream.println(s);
+        errors.add(s);
     }
 } // Errors
 
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java	Fri Jan 24 18:16:24 2014 -0800
@@ -21,14 +21,17 @@
  * questions.
  */
 
-// The content of this file is automatically generated. DO NOT EDIT.
+ // The content of this file is automatically generated. DO NOT EDIT.
+
 
 package com.oracle.truffle.sl.parser;
 
 import java.util.*;
 
+import com.oracle.truffle.api.*;
 import com.oracle.truffle.sl.*;
 import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.runtime.*;
 
 // Checkstyle: stop
 // @formatter:off
@@ -37,7 +40,7 @@
 	public static final int _identifier = 1;
 	public static final int _stringLiteral = 2;
 	public static final int _numericLiteral = 3;
-	public static final int maxT = 29;
+	public static final int maxT = 30;
 
     static final boolean T = true;
     static final boolean x = false;
@@ -51,9 +54,9 @@
     public final Errors errors;
     private final SLNodeFactory factory;
     
-    public Parser(Scanner scanner, SLNodeFactory factory) {
-        this.scanner = scanner;
-        this.factory = factory;
+    public Parser(SLContext context, Source source) {
+        this.scanner = new Scanner(source.getInputStream());
+        this.factory = new SLNodeFactory(context, source, this);
         errors = new Errors();
     }
 
@@ -130,113 +133,142 @@
 
 	void Function() {
 		Expect(4);
-		factory.startFunction(); 
 		Expect(1);
 		String name = t.val; 
-		List<String> parameterNames = new ArrayList<>(); 
-		if (la.kind == 5) {
+		Expect(5);
+		List<String> parameters = new ArrayList<>(); 
+		if (la.kind == 1) {
 			Get();
-			if (la.kind == 1) {
-				Get();
-				parameterNames.add(t.val); 
-			}
+			parameters.add(t.val); 
 			while (la.kind == 6) {
 				Get();
 				Expect(1);
-				parameterNames.add(t.val); 
+				parameters.add(t.val); 
 			}
-			Expect(7);
 		}
-		StatementNode body = Block();
-		factory.createFunction(body, name, parameterNames.toArray(new String[parameterNames.size()])); 
+		Expect(7);
+		factory.startFunction(name, parameters); 
+		SLStatementNode body = Block();
+		factory.finishFunction(body); 
 	}
 
-	StatementNode  Block() {
-		StatementNode  result;
-		List<StatementNode> statements = new ArrayList<>(); 
+	SLStatementNode  Block() {
+		SLStatementNode  result;
+		factory.startBlock();
+		List<SLStatementNode> statements = new ArrayList<>(); 
 		Expect(8);
 		while (StartOf(1)) {
-			StatementNode statement = Statement();
+			SLStatementNode statement = Statement();
 			statements.add(statement); 
 		}
 		Expect(9);
-		result = factory.createBlock(statements); 
+		result = factory.finishBlock(statements); 
 		return result;
 	}
 
-	StatementNode  Statement() {
-		StatementNode  result;
+	SLStatementNode  Statement() {
+		SLStatementNode  result;
 		result = null; 
-		if (la.kind == 13) {
+		switch (la.kind) {
+		case 15: {
 			result = WhileStatement();
-		} else if (la.kind == 11) {
+			break;
+		}
+		case 10: {
+			Get();
+			result = factory.createBreak(); 
+			Expect(11);
+			break;
+		}
+		case 12: {
+			Get();
+			result = factory.createContinue(); 
+			Expect(11);
+			break;
+		}
+		case 13: {
 			result = IfStatement();
-		} else if (la.kind == 14) {
+			break;
+		}
+		case 16: {
 			result = ReturnStatement();
-		} else if (StartOf(2)) {
+			break;
+		}
+		case 1: case 2: case 3: case 5: {
 			result = Expression();
-			Expect(10);
-		} else SynErr(30);
+			Expect(11);
+			break;
+		}
+		default: SynErr(31); break;
+		}
 		return result;
 	}
 
-	StatementNode  WhileStatement() {
-		StatementNode  result;
-		Expect(13);
+	SLStatementNode  WhileStatement() {
+		SLStatementNode  result;
+		Expect(15);
 		Expect(5);
-		ConditionNode condition = Expression();
+		SLExpressionNode condition = Expression();
 		Expect(7);
-		StatementNode body = Block();
+		SLStatementNode body = Block();
 		result = factory.createWhile(condition, body); 
 		return result;
 	}
 
-	StatementNode  IfStatement() {
-		StatementNode  result;
-		Expect(11);
+	SLStatementNode  IfStatement() {
+		SLStatementNode  result;
+		Expect(13);
 		Expect(5);
-		ConditionNode condition = Expression();
+		SLExpressionNode condition = Expression();
 		Expect(7);
-		StatementNode thenNode = null; StatementNode elseNode = null; 
-		thenNode = Block();
-		if (la.kind == 12) {
+		SLStatementNode thenPart = Block();
+		SLStatementNode elsePart = null; 
+		if (la.kind == 14) {
 			Get();
-			elseNode = Block();
+			elsePart = Block();
 		}
-		result = factory.createIf(condition, thenNode, elseNode); 
+		result = factory.createIf(condition, thenPart, elsePart); 
 		return result;
 	}
 
-	StatementNode  ReturnStatement() {
-		StatementNode  result;
-		Expect(14);
-		TypedNode value = Expression();
-		Expect(10);
+	SLStatementNode  ReturnStatement() {
+		SLStatementNode  result;
+		Expect(16);
+		SLExpressionNode value = Expression();
+		Expect(11);
 		result = factory.createReturn(value); 
 		return result;
 	}
 
-	TypedNode  Expression() {
-		TypedNode  result;
-		result = ValueExpression();
-		if (StartOf(3)) {
+	SLExpressionNode  Expression() {
+		SLExpressionNode  result;
+		result = LogicTerm();
+		while (la.kind == 17) {
+			Get();
+			String op = t.val; 
+			SLExpressionNode right = LogicTerm();
+			result = factory.createBinary(op, result, right); 
+		}
+		return result;
+	}
+
+	SLExpressionNode  LogicTerm() {
+		SLExpressionNode  result;
+		result = LogicFactor();
+		while (la.kind == 18) {
+			Get();
+			String op = t.val; 
+			SLExpressionNode right = LogicFactor();
+			result = factory.createBinary(op, result, right); 
+		}
+		return result;
+	}
+
+	SLExpressionNode  LogicFactor() {
+		SLExpressionNode  result;
+		result = Arithmetic();
+		if (StartOf(2)) {
 			switch (la.kind) {
-			case 15: {
-				Get();
-				break;
-			}
-			case 16: {
-				Get();
-				break;
-			}
-			case 17: {
-				Get();
-				break;
-			}
-			case 18: {
-				Get();
-				break;
-			}
 			case 19: {
 				Get();
 				break;
@@ -245,130 +277,101 @@
 				Get();
 				break;
 			}
+			case 21: {
+				Get();
+				break;
+			}
+			case 22: {
+				Get();
+				break;
+			}
+			case 23: {
+				Get();
+				break;
+			}
+			case 24: {
+				Get();
+				break;
+			}
 			}
 			String op = t.val; 
-			TypedNode right = ValueExpression();
+			SLExpressionNode right = Arithmetic();
 			result = factory.createBinary(op, result, right); 
 		}
 		return result;
 	}
 
-	TypedNode  ValueExpression() {
-		TypedNode  result;
+	SLExpressionNode  Arithmetic() {
+		SLExpressionNode  result;
 		result = Term();
-		while (la.kind == 21 || la.kind == 22) {
-			if (la.kind == 21) {
+		while (la.kind == 25 || la.kind == 26) {
+			if (la.kind == 25) {
 				Get();
 			} else {
 				Get();
 			}
 			String op = t.val; 
-			TypedNode right = Term();
-			result = factory.createBinary(op, result, right); 
-		}
-		return result;
-	}
-
-	TypedNode  Term() {
-		TypedNode  result;
-		result = Factor();
-		while (la.kind == 23 || la.kind == 24) {
-			if (la.kind == 23) {
-				Get();
-			} else {
-				Get();
-			}
-			String op = t.val; 
-			TypedNode right = Factor();
+			SLExpressionNode right = Term();
 			result = factory.createBinary(op, result, right); 
 		}
 		return result;
 	}
 
-	TypedNode  Factor() {
-		TypedNode  result;
-		result = null; 
-		if (la.kind == 1) {
-			result = VariableRefOrCall();
-		} else if (la.kind == 2) {
-			result = StringLiteral();
-		} else if (la.kind == 3) {
-			result = NumericLiteral();
-		} else if (la.kind == 25) {
-			result = Ternary();
-		} else if (la.kind == 5) {
-			Get();
-			result = Expression();
-			Expect(7);
-		} else SynErr(31);
-		return result;
-	}
-
-	TypedNode  VariableRefOrCall() {
-		TypedNode  result;
-		result = VariableRef();
-		if (la.kind == 5 || la.kind == 28) {
-			if (la.kind == 5) {
-				TypedNode[] parameters = Parameters();
-				result = factory.createCall(result, parameters); 
+	SLExpressionNode  Term() {
+		SLExpressionNode  result;
+		result = Factor();
+		while (la.kind == 27 || la.kind == 28) {
+			if (la.kind == 27) {
+				Get();
 			} else {
 				Get();
-				TypedNode assignment = Expression();
-				result = factory.createAssignment(result, assignment); 
 			}
+			String op = t.val; 
+			SLExpressionNode right = Factor();
+			result = factory.createBinary(op, result, right); 
 		}
 		return result;
 	}
 
-	TypedNode  StringLiteral() {
-		TypedNode  result;
-		Expect(2);
-		result = factory.createStringLiteral(t.val.substring(1, t.val.length() - 1)); 
-		return result;
-	}
-
-	TypedNode  NumericLiteral() {
-		TypedNode  result;
-		Expect(3);
-		result = factory.createNumericLiteral(t.val); 
-		return result;
-	}
-
-	TypedNode  Ternary() {
-		TypedNode  result;
-		TypedNode condition, thenPart, elsePart; 
-		Expect(25);
-		condition = Expression();
-		Expect(26);
-		thenPart = Expression();
-		Expect(27);
-		elsePart = Expression();
-		result = factory.createTernary(condition, thenPart, elsePart); 
-		return result;
-	}
-
-	TypedNode  VariableRef() {
-		TypedNode  result;
-		Expect(1);
-		result = factory.createLocal(t.val); 
-		return result;
-	}
-
-	TypedNode[]  Parameters() {
-		TypedNode[]  result;
-		Expect(5);
-		List<TypedNode> parameters = new ArrayList<>(); 
-		if (StartOf(2)) {
-			TypedNode e1 = Expression();
-			parameters.add(e1); 
-			while (la.kind == 6) {
+	SLExpressionNode  Factor() {
+		SLExpressionNode  result;
+		result = null; 
+		if (la.kind == 1) {
+			Get();
+			String name = t.val; 
+			if (la.kind == 5) {
 				Get();
-				TypedNode e2 = Expression();
-				parameters.add(e2); 
-			}
-		}
-		result = parameters.toArray(new TypedNode[parameters.size()]); 
-		Expect(7);
+				List<SLExpressionNode> parameters = new ArrayList<>();
+				SLExpressionNode parameter; 
+				if (StartOf(3)) {
+					parameter = Expression();
+					parameters.add(parameter); 
+					while (la.kind == 6) {
+						Get();
+						parameter = Expression();
+						parameters.add(parameter); 
+					}
+				}
+				result = factory.createCall(factory.createRead(name), parameters); 
+				Expect(7);
+			} else if (la.kind == 29) {
+				Get();
+				SLExpressionNode value = Expression();
+				result = factory.createAssignment(name, value); 
+			} else if (StartOf(4)) {
+				result = factory.createRead(name); 
+			} else SynErr(32);
+		} else if (la.kind == 2) {
+			Get();
+			result = factory.createStringLiteral(t.val.substring(1, t.val.length() - 1)); 
+		} else if (la.kind == 3) {
+			Get();
+			result = factory.createNumericLiteral(t.val); 
+		} else if (la.kind == 5) {
+			Get();
+			result = Expression();
+			Expect(7);
+		} else SynErr(33);
 		return result;
 	}
 
@@ -384,35 +387,30 @@
     }
 
     private static final boolean[][] set = {
-		{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x},
-		{x,T,T,T, x,T,x,x, x,x,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x},
-		{x,T,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x},
-		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x}
+		{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x},
+		{x,T,T,T, x,T,x,x, x,x,T,x, T,T,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x},
+		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,x,x,x, x,x,x,x},
+		{x,T,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x},
+		{x,x,x,x, x,x,T,T, x,x,x,T, x,x,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x}
 
     };
 
-    public String ParseErrors() {
-        java.io.PrintStream oldStream = System.out;
-
-        java.io.OutputStream out = new java.io.ByteArrayOutputStream();
-        java.io.PrintStream newStream = new java.io.PrintStream(out);
-
-        errors.errorStream = newStream;
-
-        Parse();
-
-        String errorStream = out.toString();
-        errors.errorStream = oldStream;
-
-        return errorStream;
-
+    public static void parseSL(SLContext context, Source source) {
+        Parser parser = new Parser(context, source);
+        parser.Parse();
+        if (parser.errors.errors.size() > 0) {
+            StringBuilder msg = new StringBuilder("Error(s) parsing script:\n");
+            for (String error : parser.errors.errors) {
+                msg.append(error).append("\n");
+            }
+            throw new SLException(msg.toString());
+        }
     }
 } // end Parser
 
 class Errors {
 
-    public int count = 0; // number of errors detected
-    public java.io.PrintStream errorStream = System.out; // error messages go to this stream
+    protected final List<String> errors = new ArrayList<>();
     public String errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
 
     protected void printMsg(int line, int column, String msg) {
@@ -430,7 +428,7 @@
         pos = b.indexOf("{2}");
         if (pos >= 0)
             b.replace(pos, pos + 3, msg);
-        errorStream.println(b.toString());
+        errors.add(b.toString());
     }
 
     public void SynErr(int line, int col, int n) {
@@ -446,44 +444,43 @@
 			case 7: s = "\")\" expected"; break;
 			case 8: s = "\"{\" expected"; break;
 			case 9: s = "\"}\" expected"; break;
-			case 10: s = "\";\" expected"; break;
-			case 11: s = "\"if\" expected"; break;
-			case 12: s = "\"else\" expected"; break;
-			case 13: s = "\"while\" expected"; break;
-			case 14: s = "\"return\" expected"; break;
-			case 15: s = "\"<\" expected"; break;
-			case 16: s = "\">\" expected"; break;
-			case 17: s = "\"<=\" expected"; break;
-			case 18: s = "\">=\" expected"; break;
-			case 19: s = "\"==\" expected"; break;
-			case 20: s = "\"!=\" expected"; break;
-			case 21: s = "\"+\" expected"; break;
-			case 22: s = "\"-\" expected"; break;
-			case 23: s = "\"*\" expected"; break;
-			case 24: s = "\"/\" expected"; break;
-			case 25: s = "\"#\" expected"; break;
-			case 26: s = "\"?\" expected"; break;
-			case 27: s = "\":\" expected"; break;
-			case 28: s = "\"=\" expected"; break;
-			case 29: s = "??? expected"; break;
-			case 30: s = "invalid Statement"; break;
-			case 31: s = "invalid Factor"; break;
+			case 10: s = "\"break\" expected"; break;
+			case 11: s = "\";\" expected"; break;
+			case 12: s = "\"continue\" expected"; break;
+			case 13: s = "\"if\" expected"; break;
+			case 14: s = "\"else\" expected"; break;
+			case 15: s = "\"while\" expected"; break;
+			case 16: s = "\"return\" expected"; break;
+			case 17: s = "\"||\" expected"; break;
+			case 18: s = "\"&&\" expected"; break;
+			case 19: s = "\"<\" expected"; break;
+			case 20: s = "\">\" expected"; break;
+			case 21: s = "\"<=\" expected"; break;
+			case 22: s = "\">=\" expected"; break;
+			case 23: s = "\"==\" expected"; break;
+			case 24: s = "\"!=\" expected"; break;
+			case 25: s = "\"+\" expected"; break;
+			case 26: s = "\"-\" expected"; break;
+			case 27: s = "\"*\" expected"; break;
+			case 28: s = "\"/\" expected"; break;
+			case 29: s = "\"=\" expected"; break;
+			case 30: s = "??? expected"; break;
+			case 31: s = "invalid Statement"; break;
+			case 32: s = "invalid Factor"; break;
+			case 33: s = "invalid Factor"; break;
             default:
                 s = "error " + n;
                 break;
         }
         printMsg(line, col, s);
-        count++;
     }
 
     public void SemErr(int line, int col, String s) {
         printMsg(line, col, s);
-        count++;
     }
 
     public void SemErr(String s) {
-        errorStream.println(s);
-        count++;
+        errors.add(s);
     }
 
     public void Warning(int line, int col, String s) {
@@ -491,7 +488,7 @@
     }
 
     public void Warning(String s) {
-        errorStream.println(s);
+        errors.add(s);
     }
 } // Errors
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.parser;
+
+import java.math.*;
+import java.util.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.nodes.*;
+import com.oracle.truffle.sl.nodes.call.*;
+import com.oracle.truffle.sl.nodes.controlflow.*;
+import com.oracle.truffle.sl.nodes.expression.*;
+import com.oracle.truffle.sl.nodes.local.*;
+import com.oracle.truffle.sl.runtime.*;
+
+public class SLNodeFactory {
+
+    static class LexicalScope {
+        protected final LexicalScope outer;
+        protected final Map<String, FrameSlot> locals;
+
+        public LexicalScope(LexicalScope outer) {
+            this.outer = outer;
+            this.locals = new HashMap<>();
+            if (outer != null) {
+                locals.putAll(outer.locals);
+            }
+        }
+    }
+
+    /* State while parsing a source unit. */
+    private final SLContext context;
+    private final Source source;
+    private final Parser parser;
+
+    /* State while parsing a function. */
+    private String functionName;
+    private FrameDescriptor frameDescriptor;
+    private List<SLStatementNode> methodNodes;
+
+    /* State while parsing a block. */
+    private LexicalScope lexicalScope;
+
+    public SLNodeFactory(SLContext context, Source source, Parser parser) {
+        this.context = context;
+        this.source = source;
+        this.parser = parser;
+    }
+
+    public void startFunction(String name, List<String> parameters) {
+        assert functionName == null;
+        assert frameDescriptor == null;
+        assert lexicalScope == null;
+
+        functionName = name;
+        frameDescriptor = new FrameDescriptor();
+        startBlock();
+
+        /*
+         * Method parameters are assigned to local variables at the beginning of the method. This
+         * ensures that accesses to parameters are specialized the same way as local variables are
+         * specialized.
+         */
+        methodNodes = new ArrayList<>(parameters.size());
+        for (int i = 0; i < parameters.size(); i++) {
+            methodNodes.add(createAssignment(parameters.get(i), new SLReadArgumentNode(i)));
+        }
+    }
+
+    public void finishFunction(SLStatementNode body) {
+        methodNodes.add(body);
+        SLStatementNode methodBlock = finishBlock(methodNodes);
+        assert lexicalScope == null : "Wrong scoping of blocks in parser";
+
+        context.getFunctionRegistry().register(functionName, SLRootNode.createFunction(functionName, frameDescriptor, methodBlock));
+
+        functionName = null;
+        frameDescriptor = null;
+        lexicalScope = null;
+    }
+
+    public void startBlock() {
+        lexicalScope = new LexicalScope(lexicalScope);
+    }
+
+    public SLStatementNode finishBlock(List<SLStatementNode> statements) {
+        lexicalScope = lexicalScope.outer;
+
+        List<SLStatementNode> flattened = new ArrayList<>(statements.size());
+        flattenBlocks(statements, flattened);
+        if (flattened.size() == 1) {
+            return flattened.get(0);
+        } else {
+            return assignSource(new SLBlockNode(flattened.toArray(new SLStatementNode[flattened.size()])));
+        }
+    }
+
+    private void flattenBlocks(Iterable<? extends Node> statements, List<SLStatementNode> flattened) {
+        for (Node statement : statements) {
+            if (statement instanceof SLBlockNode) {
+                flattenBlocks(statement.getChildren(), flattened);
+            } else {
+                flattened.add((SLStatementNode) statement);
+            }
+        }
+    }
+
+    private <T extends Node> T assignSource(T node) {
+        assert functionName != null;
+        node.assignSourceSection(ParserUtils.createSourceSection(source, functionName, parser));
+        return node;
+    }
+
+    public SLExpressionNode createAssignment(String name, SLExpressionNode value) {
+        FrameSlot frameSlot = frameDescriptor.findOrAddFrameSlot(name);
+        lexicalScope.locals.put(name, frameSlot);
+        return assignSource(WriteLocalNodeFactory.create(frameSlot, value));
+    }
+
+    public SLExpressionNode createRead(String name) {
+        FrameSlot frameSlot = lexicalScope.locals.get(name);
+        if (frameSlot != null) {
+            /* Read of a local variable. */
+            return assignSource(ReadLocalNodeFactory.create(frameSlot));
+        } else {
+            /* Read of a global name. In our language, the only global names are functions. */
+            return new SLFunctionLiteralNode(context.getFunctionRegistry().lookup(name));
+        }
+    }
+
+    public SLExpressionNode createNumericLiteral(String value) {
+        try {
+            return assignSource(new SLLongLiteralNode(Long.parseLong(value)));
+        } catch (NumberFormatException ex) {
+            return assignSource(new SLBigIntegerLiteralNode(new BigInteger(value)));
+        }
+    }
+
+    public SLExpressionNode createStringLiteral(String value) {
+        return assignSource(new SLStringLiteralNode(value));
+    }
+
+    public SLStatementNode createWhile(SLExpressionNode condition, SLStatementNode body) {
+        return assignSource(new SLWhileNode(condition, body));
+    }
+
+    public SLStatementNode createBreak() {
+        return assignSource(new SLBreakNode());
+    }
+
+    public SLStatementNode createContinue() {
+        return assignSource(new SLContinueNode());
+    }
+
+    public SLExpressionNode createCall(SLExpressionNode function, List<SLExpressionNode> parameters) {
+        return assignSource(SLCallNode.create(function, parameters.toArray(new SLExpressionNode[parameters.size()])));
+    }
+
+    public SLExpressionNode createBinary(String operation, SLExpressionNode left, SLExpressionNode right) {
+        SLExpressionNode binary;
+        switch (operation) {
+            case "+":
+                binary = SLAddNodeFactory.create(left, right);
+                break;
+            case "*":
+                binary = SLMulNodeFactory.create(left, right);
+                break;
+            case "/":
+                binary = SLDivNodeFactory.create(left, right);
+                break;
+            case "-":
+                binary = SLSubNodeFactory.create(left, right);
+                break;
+            case "<":
+                binary = SLLessThanNodeFactory.create(left, right);
+                break;
+            case "<=":
+                binary = SLLessOrEqualNodeFactory.create(left, right);
+                break;
+            case "==":
+                binary = SLEqualNodeFactory.create(left, right);
+                break;
+            case "!=":
+                binary = SLNotEqualNodeFactory.create(left, right);
+                break;
+            case "&&":
+                binary = SLLogicalAndNodeFactory.create(left, right);
+                break;
+            case "||":
+                binary = SLLogicalOrNodeFactory.create(left, right);
+                break;
+            default:
+                throw new RuntimeException("unexpected operation: " + operation);
+        }
+        return assignSource(binary);
+    }
+
+    public SLStatementNode createReturn(SLExpressionNode value) {
+// FrameSlot slot = frameDescriptor.findOrAddFrameSlot("<retval>", FrameSlotKind.Int);
+// if (returnValue == null) {
+// returnValue = ReadLocalNodeFactory.create(slot);
+// }
+// SLStatementNode write = WriteLocalNodeFactory.create(slot, value);
+// return assignSource(new SLReturnNode(write));
+        return assignSource(new SLReturnNode(value));
+    }
+
+    public SLStatementNode createIf(SLExpressionNode condition, SLStatementNode then, SLStatementNode elseNode) {
+        return assignSource(new SLIfNode(condition, then, elseNode));
+    }
+
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java	Fri Jan 24 18:16:24 2014 -0800
@@ -21,7 +21,8 @@
  * questions.
  */
 
-// The content of this file is automatically generated. DO NOT EDIT.
+ // The content of this file is automatically generated. DO NOT EDIT.
+
 
 package com.oracle.truffle.sl.parser;
 
@@ -311,8 +312,8 @@
 
     static final char EOL = '\n';
     static final int eofSym = 0;
-	static final int maxT = 29;
-	static final int noSym = 29;
+	static final int maxT = 30;
+	static final int noSym = 30;
 
 
     public Buffer buffer; // scanner buffer
@@ -347,23 +348,24 @@
 		start.set(123, 9); 
 		start.set(125, 10); 
 		start.set(59, 11); 
-		start.set(60, 24); 
-		start.set(62, 25); 
-		start.set(61, 26); 
-		start.set(33, 15); 
-		start.set(43, 17); 
-		start.set(45, 18); 
-		start.set(42, 19); 
-		start.set(47, 20); 
-		start.set(35, 21); 
-		start.set(63, 22); 
-		start.set(58, 23); 
+		start.set(124, 12); 
+		start.set(38, 14); 
+		start.set(60, 25); 
+		start.set(62, 26); 
+		start.set(61, 27); 
+		start.set(33, 19); 
+		start.set(43, 21); 
+		start.set(45, 22); 
+		start.set(42, 23); 
+		start.set(47, 24); 
 		start.set(Buffer.EOF, -1);
 		literals.put("function", new Integer(4));
-		literals.put("if", new Integer(11));
-		literals.put("else", new Integer(12));
-		literals.put("while", new Integer(13));
-		literals.put("return", new Integer(14));
+		literals.put("break", new Integer(10));
+		literals.put("continue", new Integer(12));
+		literals.put("if", new Integer(13));
+		literals.put("else", new Integer(14));
+		literals.put("while", new Integer(15));
+		literals.put("return", new Integer(16));
 
     }
 
@@ -519,69 +521,73 @@
                 } // NextCh already done
 				case 1:
 					recEnd = pos; recKind = 1;
-					if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); state = 1; break;}
+					if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); state = 1; break;}
 					else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
 				case 2:
-					if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); state = 2; break;}
-					else if (ch == '"') {AddCh(); state = 3; break;}
+					if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); state = 2; break;}
+					else if (ch == '"') {AddCh(); state = 3; break;}
 					else {state = 0; break;}
-				case 3:
+				case 3:
 					{t.kind = 2; break loop;}
 				case 4:
 					recEnd = pos; recKind = 3;
-					if (ch >= '0' && ch <= '9') {AddCh(); state = 4; break;}
+					if (ch >= '0' && ch <= '9') {AddCh(); state = 4; break;}
 					else {t.kind = 3; break loop;}
-				case 5:
+				case 5:
 					{t.kind = 3; break loop;}
-				case 6:
+				case 6:
 					{t.kind = 5; break loop;}
-				case 7:
+				case 7:
 					{t.kind = 6; break loop;}
-				case 8:
+				case 8:
 					{t.kind = 7; break loop;}
-				case 9:
+				case 9:
 					{t.kind = 8; break loop;}
-				case 10:
+				case 10:
 					{t.kind = 9; break loop;}
-				case 11:
-					{t.kind = 10; break loop;}
-				case 12:
+				case 11:
+					{t.kind = 11; break loop;}
+				case 12:
+					if (ch == '|') {AddCh(); state = 13; break;}
+					else {state = 0; break;}
+				case 13:
 					{t.kind = 17; break loop;}
-				case 13:
+				case 14:
+					if (ch == '&') {AddCh(); state = 15; break;}
+					else {state = 0; break;}
+				case 15:
 					{t.kind = 18; break loop;}
-				case 14:
-					{t.kind = 19; break loop;}
-				case 15:
-					if (ch == '=') {AddCh(); state = 16; break;}
-					else {state = 0; break;}
-				case 16:
-					{t.kind = 20; break loop;}
-				case 17:
+				case 16:
 					{t.kind = 21; break loop;}
-				case 18:
+				case 17:
 					{t.kind = 22; break loop;}
-				case 19:
+				case 18:
 					{t.kind = 23; break loop;}
-				case 20:
+				case 19:
+					if (ch == '=') {AddCh(); state = 20; break;}
+					else {state = 0; break;}
+				case 20:
 					{t.kind = 24; break loop;}
-				case 21:
+				case 21:
 					{t.kind = 25; break loop;}
-				case 22:
+				case 22:
 					{t.kind = 26; break loop;}
-				case 23:
+				case 23:
 					{t.kind = 27; break loop;}
 				case 24:
-					recEnd = pos; recKind = 15;
-					if (ch == '=') {AddCh(); state = 12; break;}
-					else {t.kind = 15; break loop;}
+					{t.kind = 28; break loop;}
 				case 25:
-					recEnd = pos; recKind = 16;
-					if (ch == '=') {AddCh(); state = 13; break;}
-					else {t.kind = 16; break loop;}
+					recEnd = pos; recKind = 19;
+					if (ch == '=') {AddCh(); state = 16; break;}
+					else {t.kind = 19; break loop;}
 				case 26:
-					recEnd = pos; recKind = 28;
-					if (ch == '=') {AddCh(); state = 14; break;}
-					else {t.kind = 28; break loop;}
+					recEnd = pos; recKind = 20;
+					if (ch == '=') {AddCh(); state = 17; break;}
+					else {t.kind = 20; break loop;}
+				case 27:
+					recEnd = pos; recKind = 29;
+					if (ch == '=') {AddCh(); state = 18; break;}
+					else {t.kind = 29; break loop;}
 
             }
         }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Fri Jan 24 18:16:24 2014 -0800
@@ -24,6 +24,7 @@
 
 PRODUCTIONS
 
+
 SimpleLanguage
 =
 Function 
@@ -32,30 +33,46 @@
 }
 .
 
+
 Function
 =
-"function"                                      (. factory.startFunction(); .)
-identifier                                      (. String name = t.val; 
-                                                   List<String> parameterNames = new ArrayList<>(); .)
-["(" [identifier                                (. parameterNames.add(t.val); .)
-] {"," identifier                               (. parameterNames.add(t.val); .)
-} ")"]
-Block<out StatementNode body>                   (. factory.createFunction(body, name, parameterNames.toArray(new String[parameterNames.size()])); .)
+"function"                                      
+identifier                                      (. String name = t.val; .)
+"("                                             (. List<String> parameters = new ArrayList<>(); .)
+[
+    identifier                                  (. parameters.add(t.val); .)
+    {
+        "," 
+        identifier                              (. parameters.add(t.val); .)
+    }    
+]
+")"                                             (. factory.startFunction(name, parameters); .)
+Block<out SLStatementNode body>                 (. factory.finishFunction(body); .)
 .
 
-Block<out StatementNode result>
-=                                               (. List<StatementNode> statements = new ArrayList<>(); .)
+
+
+Block<out SLStatementNode result>
+=                                               (. factory.startBlock();
+                                                   List<SLStatementNode> statements = new ArrayList<>(); .)
 "{" 
 {
-    Statement<out StatementNode statement>      (. statements.add(statement); .)
+    Statement<out SLStatementNode statement>    (. statements.add(statement); .)
 }
-"}"                                             (. result = factory.createBlock(statements); .)
+"}"                                             (. result = factory.finishBlock(statements); .)
 .
 
-Statement<out StatementNode result>
+
+Statement<out SLStatementNode result>
 =                                               (. result = null; .)
 (
     WhileStatement<out result>
+|
+    "break"                                     (. result = factory.createBreak(); .)
+    ";"
+|
+    "continue"                                  (. result = factory.createContinue(); .)
+    ";"
 |   
     IfStatement<out result>
 |
@@ -65,109 +82,117 @@
 )
 .
 
-IfStatement<out StatementNode result>
+
+IfStatement<out SLStatementNode result>
 =
-"if" "(" Expression<out ConditionNode condition> ")"  (. StatementNode thenNode = null; StatementNode elseNode = null; .)
-Block<out thenNode>                             
-["else" Block<out elseNode>]                    (. result = factory.createIf(condition, thenNode, elseNode); .)
+"if" 
+"(" 
+Expression<out SLExpressionNode condition> 
+")"
+Block<out SLStatementNode thenPart>             (. SLStatementNode elsePart = null; .)                             
+[
+    "else" 
+    Block<out elsePart>
+]                                               (. result = factory.createIf(condition, thenPart, elsePart); .)
 .
 
-WhileStatement<out StatementNode result>
+
+WhileStatement<out SLStatementNode result>
 =
 "while"
 "("
-Expression<out ConditionNode condition>
+Expression<out SLExpressionNode condition>
 ")" 
-Block<out StatementNode body>                   (. result = factory.createWhile(condition, body); .)
+Block<out SLStatementNode body>                 (. result = factory.createWhile(condition, body); .)
+.
+
+
+ReturnStatement<out SLStatementNode result>
+=
+"return"
+Expression<out SLExpressionNode value> ";"      (. result = factory.createReturn(value); .)
 .
 
 
-ReturnStatement<out StatementNode result>
+Expression<out SLExpressionNode result>
 =
-"return"
-Expression<out TypedNode value> ";"             (. result = factory.createReturn(value); .)
+LogicTerm<out result>
+{
+    "||"                                        (. String op = t.val; .)
+    LogicTerm<out SLExpressionNode right>       (. result = factory.createBinary(op, result, right); .)
+}
 .
 
-Expression<out TypedNode result>
+
+LogicTerm<out SLExpressionNode result>
 =
-ValueExpression<out result>
+LogicFactor<out result>
+{
+    "&&"                                        (. String op = t.val; .)
+    LogicFactor<out SLExpressionNode right>     (. result = factory.createBinary(op, result, right); .)
+}
+.
+
+
+LogicFactor<out SLExpressionNode result>
+=
+Arithmetic<out result>
 [
-    ("<" | ">" | "<=" | ">=" | "==" | "!=" )    (.  String op = t.val; .)
-    ValueExpression<out TypedNode right>        (.  result = factory.createBinary(op, result, right); .)
+    ("<" | "<=" | "==" | "!=" )    (.  String op = t.val; .)
+    Arithmetic<out SLExpressionNode right>      (.  result = factory.createBinary(op, result, right); .)
 ]
 .
 
-ValueExpression<out TypedNode result>
+
+Arithmetic<out SLExpressionNode result>
 =
 Term<out result>
 {
     ("+" | "-")                                 (. String op = t.val; .)
-    Term<out TypedNode right>                   (. result = factory.createBinary(op, result, right); .)
+    Term<out SLExpressionNode right>            (. result = factory.createBinary(op, result, right); .)
 }
 .
 
-Term<out TypedNode result>
+
+Term<out SLExpressionNode result>
 =
 Factor<out result>
 {
     ("*" | "/")                                 (. String op = t.val; .)
-    Factor<out TypedNode right>                 (. result = factory.createBinary(op, result, right); .)
+    Factor<out SLExpressionNode right>          (. result = factory.createBinary(op, result, right); .)
 }
 .
 
-Factor<out TypedNode result>
+
+Factor<out SLExpressionNode result>
 =                                               (. result = null; .)
 (
-    VariableRefOrCall<out result>
-|
-    StringLiteral<out result>
+    identifier                                  (. String name = t.val; .)
+    (
+        "("                                     (. List<SLExpressionNode> parameters = new ArrayList<>();
+                                                   SLExpressionNode parameter; .)
+        [
+            Expression<out parameter>           (. parameters.add(parameter); .)
+            {
+                "," 
+                Expression<out parameter>       (. parameters.add(parameter); .)
+            }                                               
+        ]                                       (. result = factory.createCall(factory.createRead(name), parameters); .) 
+        ")"
+    |
+        "=" 
+        Expression<out SLExpressionNode value>  (. result = factory.createAssignment(name, value); .)
+    |
+                                                (. result = factory.createRead(name); .)
+    )
 |
-    NumericLiteral<out result>
+    stringLiteral                               (. result = factory.createStringLiteral(t.val.substring(1, t.val.length() - 1)); .)
 |
-    Ternary<out result>
+    numericLiteral                              (. result = factory.createNumericLiteral(t.val); .)
 |
     "(" Expression<out result> ")"
 ) 
 .
 
-Ternary<out TypedNode result>                   (. TypedNode condition, thenPart, elsePart; .)
-=
-"#" Expression<out condition> "?" Expression<out thenPart> ":" Expression<out elsePart>
-                                                (. result = factory.createTernary(condition, thenPart, elsePart); .)
-.
-
-VariableRefOrCall<out TypedNode result> 
-=
-VariableRef<out result>                  
-[
-  (Parameters<out TypedNode[] parameters>)      (. result = factory.createCall(result, parameters); .)
-| ("=" Expression<out TypedNode assignment>)    (. result = factory.createAssignment(result, assignment); .)
-]
-.
-
-Parameters<out TypedNode[] result> 
-=      
-"("                                         (. List<TypedNode> parameters = new ArrayList<>(); .)
-[Expression<out TypedNode e1>                   (. parameters.add(e1); .)
-{"," Expression<out TypedNode e2>               (. parameters.add(e2); .)
-}                                               
-]                                           (. result = parameters.toArray(new TypedNode[parameters.size()]); .) 
-")"
-.
-
-VariableRef<out TypedNode result>
-=
-identifier                                      (. result = factory.createLocal(t.val); .)
-.
-
-StringLiteral<out TypedNode result>
-=
-stringLiteral                                   (. result = factory.createStringLiteral(t.val.substring(1, t.val.length() - 1)); .)
-.
-
-NumericLiteral<out TypedNode result>
-=
-numericLiteral                                  (. result = factory.createNumericLiteral(t.val); .)
-.
 
 END SimpleLanguage.
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLArguments.java	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLArguments.java	Fri Jan 24 18:16:24 2014 -0800
@@ -27,13 +27,13 @@
 
 public final class SLArguments extends Arguments {
 
-    public final Object[] arguments;
+    private final Object[] arguments;
 
     public SLArguments(Object[] arguments) {
         this.arguments = arguments;
     }
 
-    public static SLArguments get(VirtualFrame frame) {
-        return frame.getArguments(SLArguments.class);
+    public static Object[] getFromFrame(VirtualFrame frame) {
+        return frame.getArguments(SLArguments.class).arguments;
     }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Fri Jan 24 18:16:24 2014 -0800
@@ -24,32 +24,43 @@
 
 import java.io.*;
 
+import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.sl.builtins.*;
+import com.oracle.truffle.sl.nodes.*;
 
 public final class SLContext {
-
-    private final PrintStream printOutput;
+    private final SourceManager sourceManager;
+    private final PrintStream output;
     private final SLFunctionRegistry functionRegistry;
-    private final SourceManager sourceManager;
 
-    public SLContext(PrintStream print) {
-        this.printOutput = print;
+    public SLContext(SourceManager sourceManager, PrintStream output) {
+        this.sourceManager = sourceManager;
+        this.output = output;
         this.functionRegistry = new SLFunctionRegistry();
-        DefaultBuiltins.install(this);
-        this.sourceManager = new SourceManager();
+
+        installBuiltins();
+    }
+
+    public SourceManager getSourceManager() {
+        return sourceManager;
     }
 
     public PrintStream getPrintOutput() {
-        return printOutput;
+        return output;
     }
 
     public SLFunctionRegistry getFunctionRegistry() {
         return functionRegistry;
     }
 
-    public SourceManager getSourceManager() {
-        return sourceManager;
+    private void installBuiltins() {
+        installBuiltin(SLPrintBuiltinFactory.getInstance(), "print");
+        installBuiltin(SLTimeBuiltinFactory.getInstance(), "time");
+        installBuiltin(SLDefineFunctionBuiltinFactory.getInstance(), "defineFunction");
     }
 
+    private void installBuiltin(NodeFactory<? extends SLBuiltinNode> factory, String name) {
+        getFunctionRegistry().register(name, SLRootNode.createBuiltin(this, factory, name));
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunction.java	Fri Jan 24 18:16:24 2014 -0800
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.sl.runtime;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.utilities.*;
+
+public final class SLFunction {
+
+    private final String name;
+    private RootCallTarget callTarget;
+    private final CyclicAssumption callTargetStable;
+
+    protected SLFunction(String name) {
+        this.name = name;
+        this.callTargetStable = new CyclicAssumption(name);
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    protected void setCallTarget(RootCallTarget callTarget) {
+        this.callTarget = callTarget;
+        callTargetStable.invalidate();
+    }
+
+    public RootCallTarget getCallTarget() {
+        return callTarget;
+    }
+
+    public Assumption getCallTargetStable() {
+        return callTargetStable.getAssumption();
+    }
+
+    @Override
+    public String toString() {
+        return "function " + name;
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java	Fri Jan 24 18:13:38 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java	Fri Jan 24 18:16:24 2014 -0800
@@ -28,17 +28,23 @@
 
 public final class SLFunctionRegistry {
 
-    private Map<String, CallTarget> map = new HashMap<>();
+    private final Map<String, SLFunction> functions = new HashMap<>();
 
-    public void register(String name, CallTarget target) {
-        if (map.containsKey(name)) {
-            throw new IllegalArgumentException(String.format("Function with name '%s' already exists.", name));
+    public SLFunction lookup(String name) {
+        SLFunction result = functions.get(name);
+        if (result == null) {
+            result = new SLFunction(name);
+            functions.put(name, result);
         }
-        map.put(name, target);
+        return result;
     }
 
-    public CallTarget lookup(String name) {
-        return map.get(name);
+    public void register(String name, RootCallTarget callTarget) {
+        SLFunction function = lookup(name);
+        function.setCallTarget(callTarget);
     }
 
+    public Collection<SLFunction> getFunctions() {
+        return functions.values();
+    }
 }
--- a/mx/mx_graal.py	Fri Jan 24 18:13:38 2014 -0800
+++ b/mx/mx_graal.py	Fri Jan 24 18:16:24 2014 -0800
@@ -1358,7 +1358,7 @@
 def sl(args):
     """run an SL program"""
     vmArgs, slArgs = _extract_VM_args(args)
-    vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl"), "com.oracle.truffle.sl.SimpleLanguage"] + slArgs)
+    vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl"), "com.oracle.truffle.sl.SLMain"] + slArgs)
 
 def trufflejar(args=None):
     """make truffle.jar"""