// Path: lang/src/main/java/mumbler/truffle/MumblerException.java
// public class MumblerException extends RuntimeException {
//     private static final long serialVersionUID = 1L;
// 
//     public MumblerException(String message) {
//         super(message);
//     }
// 
//     @Override
//     public Throwable fillInStackTrace() {
//         CompilerAsserts.neverPartOfCompilation();
//         return fillInMumblerStackTrace(this);
//     }
// 
//     public static Throwable fillInMumblerStackTrace(Throwable t) {
//         final List<StackTraceElement> stackTrace = new ArrayList<>();
//         Truffle.getRuntime().iterateFrames((FrameInstanceVisitor<Void>) frame -> {
//             Node callNode = frame.getCallNode();
//             if (callNode == null) {
//                 return null;
//             }
//             RootNode root = callNode.getRootNode();
// 
//             /*
//              * There should be no RootNodes other than SLRootNodes on the stack. Just for the
//              * case if this would change.
//              */
//             String methodName = "$unknownFunction";
//             if (root instanceof MumblerRootNode) {
//                 methodName = ((MumblerRootNode) root).name;
//             }
// 
//             SourceSection sourceSection = callNode.getEncapsulatingSourceSection();
//             Source source = sourceSection != null ? sourceSection.getSource() : null;
//             String sourceName = source != null ? source.getName() : null;
//             int lineNumber;
//             try {
//                 lineNumber = sourceSection != null ? sourceSection.getStartLine() : -1;
//             } catch (UnsupportedOperationException e) {
//                 /*
//                  * SourceSection#getLineLocation() may throw an UnsupportedOperationException.
//                  */
//                 lineNumber = -1;
//             }
//             stackTrace.add(new StackTraceElement("mumbler", methodName, sourceName, lineNumber));
//             return null;
//         });
//         t.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()]));
//         return t;
//     }
// }
// 
// 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;
//         }
//     }
// }


import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import mumbler.truffle.MumblerException;
import mumbler.truffle.node.MumblerNode;
package mumbler.truffle.node.read;



public class ReadArgumentNode extends MumblerNode {
    public final int argumentIndex;

    public ReadArgumentNode(int argumentIndex) {
        this.argumentIndex = argumentIndex;
    }

    @Override
    public Object execute(VirtualFrame virtualFrame) {
        if (!this.isArgumentIndexInRange(virtualFrame, this.argumentIndex)) {
            CompilerDirectives.transferToInterpreterAndInvalidate();
// Path: lang/src/main/java/mumbler/truffle/MumblerException.java
// public class MumblerException extends RuntimeException {
//     private static final long serialVersionUID = 1L;
// 
//     public MumblerException(String message) {
//         super(message);
//     }
// 
//     @Override
//     public Throwable fillInStackTrace() {
//         CompilerAsserts.neverPartOfCompilation();
//         return fillInMumblerStackTrace(this);
//     }
// 
//     public static Throwable fillInMumblerStackTrace(Throwable t) {
//         final List<StackTraceElement> stackTrace = new ArrayList<>();
//         Truffle.getRuntime().iterateFrames((FrameInstanceVisitor<Void>) frame -> {
//             Node callNode = frame.getCallNode();
//             if (callNode == null) {
//                 return null;
//             }
//             RootNode root = callNode.getRootNode();
// 
//             /*
//              * There should be no RootNodes other than SLRootNodes on the stack. Just for the
//              * case if this would change.
//              */
//             String methodName = "$unknownFunction";
//             if (root instanceof MumblerRootNode) {
//                 methodName = ((MumblerRootNode) root).name;
//             }
// 
//             SourceSection sourceSection = callNode.getEncapsulatingSourceSection();
//             Source source = sourceSection != null ? sourceSection.getSource() : null;
//             String sourceName = source != null ? source.getName() : null;
//             int lineNumber;
//             try {
//                 lineNumber = sourceSection != null ? sourceSection.getStartLine() : -1;
//             } catch (UnsupportedOperationException e) {
//                 /*
//                  * SourceSection#getLineLocation() may throw an UnsupportedOperationException.
//                  */
//                 lineNumber = -1;
//             }
//             stackTrace.add(new StackTraceElement("mumbler", methodName, sourceName, lineNumber));
//             return null;
//         });
//         t.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()]));
//         return t;
//     }
// }
// 
// 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/node/read/ReadArgumentNode.java
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import mumbler.truffle.MumblerException;
import mumbler.truffle.node.MumblerNode;

package mumbler.truffle.node.read;



public class ReadArgumentNode extends MumblerNode {
    public final int argumentIndex;

    public ReadArgumentNode(int argumentIndex) {
        this.argumentIndex = argumentIndex;
    }

    @Override
    public Object execute(VirtualFrame virtualFrame) {
        if (!this.isArgumentIndexInRange(virtualFrame, this.argumentIndex)) {
            CompilerDirectives.transferToInterpreterAndInvalidate();
            throw new MumblerException("Not enough arguments passed. Missing " +