// Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
//     @CompilationFinal
//     private SourceSection sourceSection;
// 
//     @CompilationFinal
//     private boolean isTail = false;
// 
//     @Override
//     public SourceSection getSourceSection() {
//     	return this.sourceSection;
//     }
// 
//     public void setSourceSection(SourceSection sourceSection) {
//     	this.sourceSection = sourceSection;
//     }
// 
//     public boolean isTail() {
//         return this.isTail;
//     }
// 
//     public void setIsTail() {
//         this.isTail = true;
//     }
// 
//     public abstract Object execute(VirtualFrame virtualFrame);
// 
//     public long executeLong(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectLong(this.execute(virtualFrame));
//     }
// 
//     public boolean executeBoolean(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
//     }
// 
//     public BigInteger executeBigInteger(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
//     }
// 
//     public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
//     }
// 
//     public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectMumblerFunction(
//                 this.execute(virtualFrame));
//     }
// 
//     public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
//     }
// 
//     public String executeString(VirtualFrame virtualFrame)
//             throws UnexpectedResultException{
//         return MumblerTypesGen.expectString(this.execute(virtualFrame));
//     }
// 
//     protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
//             int index) {
//         return (index + 1) < virtualFrame.getArguments().length;
//     }
// 
//     protected Object getArgument(VirtualFrame virtualFrame, int index) {
//         return virtualFrame.getArguments()[index + 1];
//     }
// 
//     protected static MaterializedFrame getLexicalScope(Frame frame) {
//         Object[] args = frame.getArguments();
//         if (args.length > 0) {
//             return (MaterializedFrame) frame.getArguments()[0];
//         } else {
//             return null;
//         }
//     }
// }
// 
// Path: lang/src/main/java/mumbler/truffle/type/MumblerFunction.java
// public class MumblerFunction {
//     public final RootCallTarget callTarget;
//     private MaterializedFrame lexicalScope;
// 
//     public MumblerFunction(RootCallTarget callTarget) {
//         this.callTarget = callTarget;
//     }
// 
//     public MaterializedFrame getLexicalScope() {
//         return lexicalScope;
//     }
// 
//     public void setLexicalScope(MaterializedFrame lexicalScope) {
//         this.lexicalScope = lexicalScope;
//     }
// 
//     public static MumblerFunction create(MumblerLanguage lang, FrameSlot[] arguments,
//                                          MumblerNode[] bodyNodes, FrameDescriptor frameDescriptor) {
//         return new MumblerFunction(
//                 Truffle.getRuntime().createCallTarget(
//                         MumblerRootNode.create(lang, arguments, bodyNodes, frameDescriptor)));
//     }
// }


import java.util.Arrays;
import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.type.MumblerFunction;
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
package mumbler.truffle.node.call;




public class InvokeNode extends MumblerNode {
    @Child protected MumblerNode functionNode;
    @Children protected final MumblerNode[] argumentNodes;
    @Child protected DispatchNode dispatchNode;

    public InvokeNode(MumblerNode functionNode, MumblerNode[] argumentNodes,
            SourceSection sourceSection) {
        this.functionNode = functionNode;
        this.argumentNodes = argumentNodes;
        this.dispatchNode = new UninitializedDispatchNode();
        setSourceSection(sourceSection);
    }

    @Override
    @ExplodeLoop
    public Object execute(VirtualFrame virtualFrame) {
// Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
//     @CompilationFinal
//     private SourceSection sourceSection;
// 
//     @CompilationFinal
//     private boolean isTail = false;
// 
//     @Override
//     public SourceSection getSourceSection() {
//     	return this.sourceSection;
//     }
// 
//     public void setSourceSection(SourceSection sourceSection) {
//     	this.sourceSection = sourceSection;
//     }
// 
//     public boolean isTail() {
//         return this.isTail;
//     }
// 
//     public void setIsTail() {
//         this.isTail = true;
//     }
// 
//     public abstract Object execute(VirtualFrame virtualFrame);
// 
//     public long executeLong(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectLong(this.execute(virtualFrame));
//     }
// 
//     public boolean executeBoolean(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
//     }
// 
//     public BigInteger executeBigInteger(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
//     }
// 
//     public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
//     }
// 
//     public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectMumblerFunction(
//                 this.execute(virtualFrame));
//     }
// 
//     public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
//             throws UnexpectedResultException {
//         return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
//     }
// 
//     public String executeString(VirtualFrame virtualFrame)
//             throws UnexpectedResultException{
//         return MumblerTypesGen.expectString(this.execute(virtualFrame));
//     }
// 
//     protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
//             int index) {
//         return (index + 1) < virtualFrame.getArguments().length;
//     }
// 
//     protected Object getArgument(VirtualFrame virtualFrame, int index) {
//         return virtualFrame.getArguments()[index + 1];
//     }
// 
//     protected static MaterializedFrame getLexicalScope(Frame frame) {
//         Object[] args = frame.getArguments();
//         if (args.length > 0) {
//             return (MaterializedFrame) frame.getArguments()[0];
//         } else {
//             return null;
//         }
//     }
// }
// 
// Path: lang/src/main/java/mumbler/truffle/type/MumblerFunction.java
// public class MumblerFunction {
//     public final RootCallTarget callTarget;
//     private MaterializedFrame lexicalScope;
// 
//     public MumblerFunction(RootCallTarget callTarget) {
//         this.callTarget = callTarget;
//     }
// 
//     public MaterializedFrame getLexicalScope() {
//         return lexicalScope;
//     }
// 
//     public void setLexicalScope(MaterializedFrame lexicalScope) {
//         this.lexicalScope = lexicalScope;
//     }
// 
//     public static MumblerFunction create(MumblerLanguage lang, FrameSlot[] arguments,
//                                          MumblerNode[] bodyNodes, FrameDescriptor frameDescriptor) {
//         return new MumblerFunction(
//                 Truffle.getRuntime().createCallTarget(
//                         MumblerRootNode.create(lang, arguments, bodyNodes, frameDescriptor)));
//     }
// }


// Path: lang/src/main/java/mumbler/truffle/node/call/InvokeNode.java
import java.util.Arrays;
import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.type.MumblerFunction;
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;

package mumbler.truffle.node.call;




public class InvokeNode extends MumblerNode {
    @Child protected MumblerNode functionNode;
    @Children protected final MumblerNode[] argumentNodes;
    @Child protected DispatchNode dispatchNode;

    public InvokeNode(MumblerNode functionNode, MumblerNode[] argumentNodes,
            SourceSection sourceSection) {
        this.functionNode = functionNode;
        this.argumentNodes = argumentNodes;
        this.dispatchNode = new UninitializedDispatchNode();
        setSourceSection(sourceSection);
    }

    @Override
    @ExplodeLoop
    public Object execute(VirtualFrame virtualFrame) {
        MumblerFunction function = this.evaluateFunction(virtualFrame);