Example #1
0
        void ArgDecl(out Node node)
        {
            IdentifierNode tNode = null;
            VarDeclNode varDeclNode = new ProtoImperative.AST.VarDeclNode();
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;

            if (la.kind == 25) {
            Get();
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemHeap;
            }
            if (isArrayAccess()) {
            arrayident(out node);
            tNode = node as IdentifierNode;
            varDeclNode.NameNode = tNode;

            } else if (la.kind == 1) {
            Get();
            tNode = new IdentifierNode()
            {
               Value = t.val,
               Name = t.val,
               type = (int)ProtoCore.PrimitiveType.kTypeVar,
               datatype = ProtoCore.PrimitiveType.kTypeVar
            };
            varDeclNode.NameNode = tNode;

            } else SynErr(68);
            ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
            if (la.kind == 36) {
            Get();
            Expect(1);
            argtype.Name = t.val;
            if (la.kind == 6) {
                argtype.IsIndexable = true;
                Get();
                Expect(7);
                argtype.rank = 1;
                if (la.kind == 6 || la.kind == 17 || la.kind == 31) {
                    if (la.kind == 17) {
                        Get();
                        Expect(6);
                        Expect(7);
                        argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
                    } else {
                        while (la.kind == 6) {
                            Get();
                            Expect(7);
                            argtype.rank++;
                        }
                    }
                }
            }
            }
            varDeclNode.ArgumentType = argtype;
            if (la.kind == 31) {
            Get();
            Node rhsNode;
            expr(out rhsNode);
            BinaryExpressionNode bNode = new BinaryExpressionNode();
            bNode.LeftNode = tNode;
            bNode.RightNode = rhsNode;
            bNode.Optr = Operator.assign;
            varDeclNode.NameNode = bNode;

            }
            node = varDeclNode;
            if(!isGlobalScope) {
               localVarCount++;
            }
        }
Example #2
0
 public void AddArgument(VarDeclNode arg)
 {
     Arguments.Add(arg);
 }
Example #3
0
        void ArgDecl(out Node node)
        {
            IdentifierNode tNode       = null;
            VarDeclNode    varDeclNode = new ProtoImperative.AST.VarDeclNode();

            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;

            if (la.kind == 25)
            {
                Get();
                varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemHeap;
            }
            if (isArrayAccess())
            {
                arrayident(out node);
                tNode = node as IdentifierNode;
                varDeclNode.NameNode = tNode;
            }
            else if (la.kind == 1)
            {
                Get();
                tNode = new IdentifierNode()
                {
                    Value    = t.val,
                    Name     = t.val,
                    type     = (int)ProtoCore.PrimitiveType.kTypeVar,
                    datatype = ProtoCore.PrimitiveType.kTypeVar
                };
                varDeclNode.NameNode = tNode;
            }
            else
            {
                SynErr(68);
            }
            ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
            if (la.kind == 36)
            {
                Get();
                Expect(1);
                argtype.Name = t.val;
                if (la.kind == 6)
                {
                    argtype.IsIndexable = true;
                    Get();
                    Expect(7);
                    argtype.rank = 1;
                    if (la.kind == 6 || la.kind == 17 || la.kind == 31)
                    {
                        if (la.kind == 17)
                        {
                            Get();
                            Expect(6);
                            Expect(7);
                            argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
                        }
                        else
                        {
                            while (la.kind == 6)
                            {
                                Get();
                                Expect(7);
                                argtype.rank++;
                            }
                        }
                    }
                }
            }
            varDeclNode.ArgumentType = argtype;
            if (la.kind == 31)
            {
                Get();
                Node rhsNode;
                expr(out rhsNode);
                BinaryExpressionNode bNode = new BinaryExpressionNode();
                bNode.LeftNode       = tNode;
                bNode.RightNode      = rhsNode;
                bNode.Optr           = Operator.assign;
                varDeclNode.NameNode = bNode;
            }
            node = varDeclNode;
            if (!isGlobalScope)
            {
                localVarCount++;
            }
        }
Example #4
0
 public void AddArgument(VarDeclNode arg)
 {
     Arguments.Add(arg);
 }