public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { List<Node> arguments = function.GetArguments(1); LabelNode labelNode = VerifyType<LabelNode>(arguments[0]); walker.scriptBuilder.EmitStatement($"jump {TreeWalker.MangleLabelName(labelNode.labelName)}"); }
//Return statements can take either no argument, or a label as argument (the return destination). public Node HandleReturn() { Lexeme returnWord = Pop(); LabelNode returnDestination = null; if (HasCurrent() && Peek().type == LexemeType.LABEL) { returnDestination = new LabelNode(Pop()); } return(new ReturnNode(returnWord, returnDestination)); }
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { List<Node> arguments = function.GetArguments(1); LabelNode gosubTargetLabel = VerifyType<LabelNode>(arguments[0]); walker.scriptBuilder.EmitStatement($"call {gosubTargetLabel.labelName}"); }
public LabelNode returnDestination; //can be null if no return destination given. public ReturnNode(Lexeme lexeme, LabelNode returnDestination) : base(lexeme) { this.returnDestination = returnDestination; }