コード例 #1
0
 public override bool Visit(AstAssignStatement node)
 {
     return true;
 }
コード例 #2
0
 public override bool Visit(AstAssignStatement node)
 {
     ErrorIfIsNull(node.NewValue);
     ErrorIfIsNull(node.Variable);
     return true;
 }
コード例 #3
0
 // #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);
 }
コード例 #4
0
        // #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);
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        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;
        }
コード例 #7
0
 public abstract bool Visit(AstAssignStatement node);