public AstExpression VisitVariable(Scope context, AstExpression.Var var) { var.Variable = context.FindVariable(var.TokenName.Value); if (var.Variable == null) { throw new CompilerException(var.TokenName, $"variable {var.TokenName.Value} is not defined."); } return(var); }
public List <Instruction> VisitVariable(Scope context, AstExpression.Var var) { if (var.Type == DataTypes.Int) { var heapLayout = context.GetHeapLayoutUntil(var.Variable); return(new List <Instruction>() { new Instruction(ReadLocal, heapLayout), new Instruction(DupInt), new Instruction(WriteLocal, heapLayout), }); } throw new NotImplementedException(); }
public Tree VisitVariable(object c, AstExpression.Var var) => new Tree("v:" + var.TokenName.Value);