public override bool Visit(AstAssignStatement node) { return true; }
public override bool Visit(AstAssignStatement node) { ErrorIfIsNull(node.NewValue); ErrorIfIsNull(node.Variable); return true; }
// #ASSIGN_STATEMENT ID ASSIGNMENT #EXPRESSION private void ConstructAssignStatement() { var expr = nodes.Pop() as AstExpression; var variable = nodes.Pop() as AstIdExpression; var assignStmt = new AstAssignStatement(variable, expr); PushNode(assignStmt); }
// #ASSIGN_STATEMENT ID #ARRAY ASSIGNMENT #EXPRESSION private void ConstructAssignArrayStatement() { var newValue = nodes.Pop() as AstExpression; List<AstArrayIndex> indices = new List<AstArrayIndex>(); while (nodes.Peek() is AstArrayIndex) { indices.Insert(0, nodes.Pop() as AstArrayIndex); } AstExpressionList index = new AstExpressionList(indices.ToArray()); var id = nodes.Pop() as AstIdExpression; var idArrExpression = new AstIdArrayExpression(id.Id, index); idArrExpression.SetTextPosition( tokenCurrPosition ); var node = new AstAssignStatement(idArrExpression, newValue); PushNode(node); }
public override bool Visit(AstAssignStatement node) { var symbolTableVariable = table.Lookup(node.Variable.Id); node.NewValue.Accept(this); if (Symbol.IsArray(symbolTableVariable)) { arrAssign = true; var newValueVar = GetCurrUnnamedVariable(); node.Variable.Accept(this); var index = GetCurrUnnamedVariable(); codeStream.WriteLine("store i32 " + newValueVar + ", " + GetLLVMType(symbolTableVariable.Type) + "* " + GetCurrUnnamedVariable()); arrAssign = false; } else if (classVariables.Contains(node.Variable.Id)) { codeStream.WriteLine("store " + GetLLVMType(symbolTableVariable.Type) + " " + GetCurrUnnamedVariable() + ", " + GetLLVMType(symbolTableVariable.Type) + "* @" + node.Variable.Id); } else if (symbolTableVariable.Type == BuiltInTypes.STRING) { } else { UseVaribaleCatched(node.Variable.Id); var name = GetCurrVariableState(node.Variable.Id); var type = GetLLVMType(symbolTableVariable.Type); codeStream.WriteLine("%" + name + " = add " + type + " 0, " + GetCurrUnnamedVariable()); } return false; }
public override bool Visit(AstAssignStatement node) { var leftType = resolver.Resolve(node.Variable); var rightType = resolver.Resolve(node.NewValue); if (leftType != rightType) { DispatchError(node.TextPosition, "Can not assign " + rightType + " to variable of type " + leftType ); return false; } currStateInsideExpr = false; node.Variable.Accept(this); currStateInsideExpr = true; node.NewValue.Accept(this); return false; }
public abstract bool Visit(AstAssignStatement node);