public List <Instruction> VisitExpression(object context, AstStatement.ExpressionStmt expressionStmt)
        {
            var instructions = expressionStmt.Expression.Accept(expressionStmt.Scope, this);

            // pop return value if type is not void
            if (expressionStmt.Expression.Type != DataTypes.Void)
            {
                if (expressionStmt.Expression.Type == DataTypes.Int)
                {
                    instructions.Add(PopInt);
                }
                else
                {
                    throw new NotImplementedException(
                              "invalid return type " + expressionStmt.Expression.Type);
                }
            }

            return(instructions);
        }
 public void VisitExpression(IndentWriter context, AstStatement.ExpressionStmt expressionStmt)
 {
     this.PrintExpression(context, expressionStmt.Expression, expressionStmt.Scope);
 }
 public AstStatement VisitExpression(Scope context, AstStatement.ExpressionStmt expressionStmt)
 {
     expressionStmt.Expression = expressionStmt.Expression.Accept(context, this);
     expressionStmt.Scope      = context;
     return(expressionStmt);
 }
Exemple #4
0
 public Tree VisitExpression(object c, AstStatement.ExpressionStmt expressionStmt)
 => new Tree("stmt");