Пример #1
0
 public void Visit(ExprListNode node)
 {
     foreach (var subnode in node)
     {
         Visit((dynamic)subnode);
     }
 }
 public virtual void VisitExprListNode(ExprListNode exn)
 {
     foreach (var ex in exn.ExprList)
     {
         ex.Visit(this);
     }
 }
Пример #3
0
 public override void VisitExprListNode(ExprListNode e)
 {
     PreVisit(e);
     for (var i = 0; i < e.ExprChildren.Count; ++i)
     {
         e.ExprChildren[i].Visit(this);
     }
     PostVisit(e);
 }
 public override void VisitExprListNode(ExprListNode e)
 {
     e.ExprChildren[0].Visit(this);
     for (var i = 1; i < e.ExprChildren.Count; ++i)
     {
         Text += ", ";
         e.ExprChildren[i].Visit(this);
     }
 }
Пример #5
0
 public override void VisitExprListNode(ExprListNode e)
 {
     PreVisit(e);
     foreach (var x in e.ExprChildren)
     {
         x.Visit(this);
     }
     PostVisit(e);
 }
Пример #6
0
        internal BinaryExpressionNode CreatePreCompilationAstNode(NodeModel node, List <AssociativeNode> inputAstNodes)
        {
            IdentifierNode identifier = AstFactory.BuildIdentifier(node.AstIdentifierBase + beginTag);

            string          id           = node.GUID.ToString();
            ExprListNode    exprListNode = AstFactory.BuildExprList(inputAstNodes);
            AssociativeNode bridgeData   = DataBridge.GenerateBridgeDataAst(id + profilingID, exprListNode);

            return(AstFactory.BuildAssignment(identifier, bridgeData));
        }
Пример #7
0
        public void VisitExprListNode(ExprListNode a)
        {
            string label = Mark(a);

            _nodes.AppendLine($"{label}  [label = \"ExprList\"]");

            foreach (var st in a.ExprList)
            {
                st.Visit(this);
                _edges.AppendLine($"{label} -> {Mark(st)}");
            }
        }
Пример #8
0
        public static ExprListNode BuildArrayExprList(AssociativeNode arrayNode)
        {
            ExprListNode exprlist = new ExprListNode();

            while (arrayNode is ArrayNode)
            {
                ArrayNode array = arrayNode as ArrayNode;
                exprlist.Exprs.Add(array.Expr);
                arrayNode = array.Type;
            }
            return(exprlist);
        }
Пример #9
0
        public virtual void VisitExprListNode(ExprListNode node)
        {
            for (int i = 0; i < node.Exprs.Count; ++i)
            {
                node.Exprs[i].Accept(this);
            }

            if (node.ArrayDimensions != null)
            {
                node.ArrayDimensions.Accept(this);
            }
        }
        /// <summary>
        /// Посещение узла с меткой
        /// </summary>
        /// <param name="el">Узел LabeledNode</param>
        public virtual void VisitExprListNode(ExprListNode el)
        {
            var last = el.ExprList.Last();

            el.ExprList.ForEach(expr =>
            {
                expr.Visit(this);
                if (expr != last)
                {
                    Text += ",";
                }
            });
        }
Пример #11
0
        internal BinaryExpressionNode CreatePostCompilationAstNode(NodeModel node, List <AssociativeNode> inputAstNodes)
        {
            IdentifierNode identifier = AstFactory.BuildIdentifier(node.AstIdentifierBase + endTag);

            string id = node.GUID.ToString();
            List <AssociativeNode> outPortNodeList =
                Enumerable.Range(0, node.OutPorts.Count).Select(
                    index => (AssociativeNode)node.GetAstIdentifierForOutputIndex(index)).ToList();
            ExprListNode    exprListNode = AstFactory.BuildExprList(outPortNodeList);
            AssociativeNode bridgeData   = DataBridge.GenerateBridgeDataAst(id + profilingID, exprListNode);

            return(AstFactory.BuildAssignment(identifier, bridgeData));
        }
Пример #12
0
            public override bool VisitExprListNode(ExprListNode node)
            {
                if (forDefinition)
                {
                    return(false);
                }

                if (node.list.Any(e => e.Accept(this)))
                {
                    return(true);
                }

                return(node.ArrayDimensions != null?node.ArrayDimensions.Accept(this) : false);
            }
Пример #13
0
        public override AssociativeNode VisitExprListNode(ExprListNode node)
        {
            node.Exprs = VisitNodeList(node.Exprs);

            if (node.ArrayDimensions != null)
            {
                var newArrayDimensions = node.ArrayDimensions.Accept(this);
                if (node.ArrayDimensions != newArrayDimensions)
                {
                    node.ArrayDimensions = newArrayDimensions as ArrayNode;
                }
            }

            return(node);
        }
Пример #14
0
        public override AssociativeNode VisitExprListNode(ExprListNode node)
        {
            List <AssociativeNode> items = new List <AssociativeNode>();

            for (int i = 0; i < node.Exprs.Count; ++i)
            {
                var newItem = node.Exprs[i].Accept(this);
                if (node.Exprs[i] != newItem)
                {
                    node.Exprs[i] = newItem;
                }
            }

            return(node);
        }
Пример #15
0
        public Node ExprList()
        {
            var node = new ExprListNode();

            if (CurrentToken == TokenCategory.PARENTHESIS_CLOSE || CurrentToken == TokenCategory.SQUARE_CLOSE)
            {
                return(node);
            }
            node.Add(Expr());
            while (CurrentToken == TokenCategory.COMMA)
            {
                Expect(TokenCategory.COMMA);
                node.Add(Expr());
            }
            return(node);
        }
Пример #16
0
        /// <summary>
        /// API for external hosts to build an identifier array assignment node, e.g.: var = {var1, var2, ...}
        /// </summary>
        /// <param name="arrayInputs"></param>
        /// <param name="symbolName"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static AssociativeNode BuildArrayNode(List <string> arrayInputs, ref string symbolName, ref string code)
        {
            ExprListNode         arrayNode = AstFactory.BuildExprList(arrayInputs);
            BinaryExpressionNode bNode     = CreateAssignmentNode(arrayNode);

            if (bNode.LeftNode is IdentifierNode)
            {
                symbolName = (bNode.LeftNode as IdentifierNode).Value;
            }

            List <AssociativeNode> astNodes = new List <AssociativeNode>();

            astNodes.Add(bNode);
            ProtoCore.CodeGenDS codeGen = new ProtoCore.CodeGenDS(astNodes);
            code = codeGen.GenerateCode();

            return(bNode);
        }
Пример #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputAstNodes"></param>
        /// <returns></returns>
        public override IEnumerable <AssociativeNode> BuildOutputAst(List <AssociativeNode> inputAstNodes)
        {
            AssociativeNode node;

            if (SelectionResults == null || !SelectionResults.Any())
            {
                node = AstFactory.BuildNullNode();
            }
            else
            {
                IEnumerable <AssociativeNode> strInputs = SelectionResults.Select(res => AstFactory.BuildStringNode(res) as AssociativeNode);
                ExprListNode inputNode1 = AstFactory.BuildExprList(strInputs.ToList());
                node = AstFactory.BuildFunctionCall(new Func <IEnumerable <string>, IEnumerable <SteelDbObject> >(Utils.GetDynObjects), new List <AssociativeNode>()
                {
                    inputNode1
                });
            }

            return(new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) });
        }
Пример #18
0
        private void TraverseToSplit(AssociativeNode node, out AssociativeNode outNode, ref List <AssociativeNode> splitList)
        {
            if (node is BinaryExpressionNode)
            {
                BinaryExpressionNode ben = node as BinaryExpressionNode;

                BinaryExpressionNode newNode = new BinaryExpressionNode();
                AssociativeNode      lNode   = null;
                TraverseToSplit(ben.LeftNode, out lNode, ref splitList);
                newNode.LeftNode = lNode;
                newNode.Optr     = ben.Optr;

                AssociativeNode rNode = null;
                TraverseToSplit(ben.RightNode, out rNode, ref splitList);
                newNode.RightNode = rNode;

                if (ben.Optr == ProtoCore.DSASM.Operator.assign)
                {
                    if (NotEnlisted(splitList, newNode))
                    {
                        splitList.Add(newNode);
                    }
                    outNode = lNode;
                }
                else
                {
                    outNode = newNode;
                }
            }
            else if (node is FunctionCallNode)
            {
                FunctionCallNode funcCallNode = node as FunctionCallNode;
                AssociativeNode  statement    = null;
                foreach (AssociativeNode argNode in funcCallNode.FormalArguments)
                {
                    TraverseToSplit(argNode, out statement, ref splitList);
                }
                for (int i = 0; i < funcCallNode.FormalArguments.Count; i++)
                {
                    AssociativeNode argNode = funcCallNode.FormalArguments[i];
                    if (argNode is BinaryExpressionNode)
                    {
                        funcCallNode.FormalArguments[i] = (argNode as BinaryExpressionNode).LeftNode;
                    }
                }
                //if (statement is BinaryExpressionNode)
                //{
                //    splitList.Add(statement);
                //}
                outNode = funcCallNode;
            }
            else if (node is FunctionDotCallNode)
            {
                FunctionDotCallNode funcDotNode = node as FunctionDotCallNode;
                AssociativeNode     statement   = null;
                TraverseToSplit(funcDotNode.FunctionCall, out statement, ref splitList);
                funcDotNode.FunctionCall = (statement as FunctionCallNode);
                TraverseToSplit(funcDotNode.DotCall.FormalArguments[0], out statement, ref splitList);
                if (statement is BinaryExpressionNode)
                {
                    funcDotNode.DotCall.FormalArguments[0] = (statement as BinaryExpressionNode).LeftNode;
                }
                else
                {
                    funcDotNode.DotCall.FormalArguments[0] = statement;
                }
                outNode = funcDotNode;
            }
            else if (node is ProtoCore.AST.AssociativeAST.ImportNode)
            {
                outNode = node;
                splitList.Add(outNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.ArrayIndexerNode)
            {
                ArrayIndexerNode arrIdxNode = node as ArrayIndexerNode;
                AssociativeNode  statement  = null;
                TraverseToSplit(arrIdxNode.Array, out statement, ref splitList);
                arrIdxNode.Array = statement;
                outNode          = arrIdxNode;
            }
            else if (node is ProtoCore.AST.AssociativeAST.ExprListNode)
            {
                ExprListNode    exprListNode = node as ExprListNode;
                AssociativeNode statement    = null;
                //for (int i=0; i<exprListNode.list.Count; i++)
                foreach (AssociativeNode listNode in exprListNode.list)
                {
                    TraverseToSplit(listNode, out statement, ref splitList);
                }
                for (int i = 0; i < exprListNode.list.Count; i++)
                {
                    AssociativeNode argNode = exprListNode.list[i];
                    if (argNode is BinaryExpressionNode)
                    {
                        exprListNode.list[i] = (argNode as BinaryExpressionNode).LeftNode;
                    }
                }
                outNode = exprListNode;
            }
            //else if (node is ProtoCore.AST.AssociativeAST.ArrayNode)
            //{
            //    k
            //}
            else if (node is ProtoCore.AST.AssociativeAST.RangeExprNode)
            {
                RangeExprNode   rangeExprNode = node as RangeExprNode;
                AssociativeNode statement     = null;
                TraverseToSplit(rangeExprNode.FromNode, out statement, ref splitList);
                TraverseToSplit(rangeExprNode.StepNode, out statement, ref splitList);
                TraverseToSplit(rangeExprNode.ToNode, out statement, ref splitList);
                if (rangeExprNode.FromNode is BinaryExpressionNode)
                {
                    rangeExprNode.FromNode = (rangeExprNode.FromNode as BinaryExpressionNode).LeftNode;
                }
                if (rangeExprNode.StepNode is BinaryExpressionNode)
                {
                    rangeExprNode.StepNode = (rangeExprNode.StepNode as BinaryExpressionNode).LeftNode;
                }
                if (rangeExprNode.ToNode is BinaryExpressionNode)
                {
                    rangeExprNode.ToNode = (rangeExprNode.ToNode as BinaryExpressionNode).LeftNode;
                }
                outNode = rangeExprNode;
            }
            else
            {
                outNode = node;
            }
        }
Пример #19
0
 public ExprListNode(ExprListNode rhs)
     : base(rhs)
 {
     Exprs = new List<ImperativeNode>();
     foreach (ImperativeNode argNode in rhs.Exprs)
     {
         ImperativeNode tempNode = NodeUtils.Clone(argNode);
         Exprs.Add(tempNode);
     }
 }
Пример #20
0
        public static FunctionDotCallNode GenerateCallDotNode(AssociativeNode lhs,
                                                              FunctionCallNode rhsCall, Core core = null)
        {
            // The function name to call
            string       rhsName = rhsCall.Function.Name;
            int          argNum  = rhsCall.FormalArguments.Count;
            ExprListNode argList = new ExprListNode();

            foreach (AssociativeNode arg in rhsCall.FormalArguments)
            {
                // The function arguments
                argList.Exprs.Add(arg);
            }


            FunctionCallNode funCallNode = new FunctionCallNode();
            IdentifierNode   funcName    = new IdentifierNode {
                Value = Constants.kDotArgMethodName, Name = Constants.kDotArgMethodName
            };

            funCallNode.Function = funcName;
            funCallNode.Name     = Constants.kDotArgMethodName;

            NodeUtils.CopyNodeLocation(funCallNode, lhs);
            int    rhsIdx  = DSASM.Constants.kInvalidIndex;
            string lhsName = string.Empty;

            if (lhs is IdentifierNode)
            {
                lhsName = (lhs as IdentifierNode).Name;
                if (lhsName == DSDefinitions.Keyword.This)
                {
                    lhs = new ThisPointerNode();
                }
            }

            if (core != null)
            {
                DynamicFunction func;
                if (core.DynamicFunctionTable.TryGetFunction(rhsName, 0, Constants.kInvalidIndex, out func))
                {
                    rhsIdx = func.Index;
                }
                else
                {
                    func   = core.DynamicFunctionTable.AddNewFunction(rhsName, 0, Constants.kInvalidIndex);
                    rhsIdx = func.Index;
                }
            }

            // The first param to the dot arg (the pointer or the class name)
            funCallNode.FormalArguments.Add(lhs);

            // The second param which is the dynamic table index of the function to call
            var rhs = new IntNode(rhsIdx);

            funCallNode.FormalArguments.Add(rhs);

            // The array dimensions
            ExprListNode arrayDimExperList = new ExprListNode();
            int          dimCount          = 0;

            if (rhsCall.Function is IdentifierNode)
            {
                // Number of dimensions
                IdentifierNode fIdent = rhsCall.Function as IdentifierNode;
                if (fIdent.ArrayDimensions != null)
                {
                    arrayDimExperList = CoreUtils.BuildArrayExprList(fIdent.ArrayDimensions);
                    dimCount          = arrayDimExperList.Exprs.Count;
                }
                else if (rhsCall.ArrayDimensions != null)
                {
                    arrayDimExperList = CoreUtils.BuildArrayExprList(rhsCall.ArrayDimensions);
                    dimCount          = arrayDimExperList.Exprs.Count;
                }
                else
                {
                    arrayDimExperList = new ExprListNode();
                }
            }

            funCallNode.FormalArguments.Add(arrayDimExperList);

            // Number of dimensions
            var dimNode = new IntNode(dimCount);

            funCallNode.FormalArguments.Add(dimNode);

            if (argNum >= 0)
            {
                funCallNode.FormalArguments.Add(argList);
                funCallNode.FormalArguments.Add(new IntNode(argNum));
            }

            var funDotCallNode = new FunctionDotCallNode(rhsCall);

            funDotCallNode.DotCall = funCallNode;
            funDotCallNode.FunctionCall.Function = rhsCall.Function;

            // Consider the case of "myClass.Foo(a, b)", we will have "DotCall" being
            // equal to "myClass" (in terms of its starting line/column), and "rhsCall"
            // matching with the location of "Foo(a, b)". For execution cursor to cover
            // this whole statement, the final "DotCall" function call node should
            // range from "lhs.col" to "rhs.col".
            //
            NodeUtils.SetNodeEndLocation(funDotCallNode.DotCall, rhsCall);
            NodeUtils.CopyNodeLocation(funDotCallNode, funDotCallNode.DotCall);


            return(funDotCallNode);
        }
Пример #21
0
 public virtual void VisitExprListNode(ExprListNode e)
 {
 }
Пример #22
0
 public ExprListNode(ExprListNode rhs)
     : base(rhs)
 {
     list = new List<ImperativeNode>();
     foreach (ImperativeNode argNode in rhs.list)
     {
         ImperativeNode tempNode = ProtoCore.Utils.NodeUtils.Clone(argNode);
         list.Add(tempNode);
     }
 }
Пример #23
0
 public virtual TAssociative VisitExprListNode(ExprListNode node)
 {
     return(VisitAssociativeNode(node));
 }
Пример #24
0
 void factor(out Node node)
 {
     node = null;
     if (la.kind == 2 || la.kind == 3 || la.kind == 38)
     {
         num(out node);
     }
     else if (isFunctionCall())
     {
         functioncall(out node);
     }
     else if (isArrayAccess())
     {
         arrayident(out node);
     }
     else if (la.kind == 27)
     {
         Get();
         node = new BooleanNode()
         {
             value = ProtoCore.DSASM.Literal.True
         };
     }
     else if (la.kind == 28)
     {
         Get();
         node = new BooleanNode()
         {
             value = ProtoCore.DSASM.Literal.False
         };
     }
     else if (la.kind == 29)
     {
         Get();
         node = new NullNode();
     }
     else if (la.kind == 32)
     {
         Get();
         ExprListNode exprlist = new ExprListNode();
         if (StartOf(3))
         {
             expr(out node);
             exprlist.list.Add(node);
             while (la.kind == 30)
             {
                 Get();
                 expr(out node);
                 exprlist.list.Add(node);
             }
         }
         Expect(33);
         node = exprlist;
     }
     else if (la.kind == 8)
     {
         Get();
         expr(out node);
         Expect(9);
     }
     else if (la.kind == 1)
     {
         identifierList(out node);
     }
     else
     {
         SynErr(65);
     }
 }
Пример #25
0
        public static FunctionDotCallNode GenerateCallDotNode(AssociativeNode lhs,
                                                              FunctionCallNode rhsCall, Core core = null)
        {
            // The function name to call
            string       rhsName = rhsCall.Function.Name;
            int          argNum  = rhsCall.FormalArguments.Count;
            ExprListNode argList = new ExprListNode();

            foreach (AssociativeNode arg in rhsCall.FormalArguments)
            {
                // The function arguments
                argList.Exprs.Add(arg);
            }

            var arguments = new List <AssociativeNode>();

            int    rhsIdx  = DSASM.Constants.kInvalidIndex;
            string lhsName = string.Empty;

            if (lhs is IdentifierNode)
            {
                lhsName = (lhs as IdentifierNode).Name;
                if (lhsName == DSDefinitions.Keyword.This)
                {
                    lhs = new ThisPointerNode();
                }
            }

            if (core != null)
            {
                DynamicFunction func;
                if (core.DynamicFunctionTable.TryGetFunction(rhsName, 0, Constants.kInvalidIndex, out func))
                {
                    rhsIdx = func.Index;
                }
                else
                {
                    func   = core.DynamicFunctionTable.AddNewFunction(rhsName, 0, Constants.kInvalidIndex);
                    rhsIdx = func.Index;
                }
            }

            // The first param to the dot arg (the pointer or the class name)
            arguments.Add(lhs);

            // The second param which is the dynamic table index of the function to call
            arguments.Add(new IntNode(rhsIdx));

            // The array dimensions
            ExprListNode arrayDimExperList = new ExprListNode();
            int          dimCount          = 0;

            if (rhsCall.Function is IdentifierNode)
            {
                // Number of dimensions
                IdentifierNode fIdent = rhsCall.Function as IdentifierNode;
                if (fIdent.ArrayDimensions != null)
                {
                    arrayDimExperList = CoreUtils.BuildArrayExprList(fIdent.ArrayDimensions);
                    dimCount          = arrayDimExperList.Exprs.Count;
                }
                else if (rhsCall.ArrayDimensions != null)
                {
                    arrayDimExperList = CoreUtils.BuildArrayExprList(rhsCall.ArrayDimensions);
                    dimCount          = arrayDimExperList.Exprs.Count;
                }
                else
                {
                    arrayDimExperList = new ExprListNode();
                }
            }

            arguments.Add(arrayDimExperList);

            // Number of dimensions
            var dimNode = new IntNode(dimCount);

            arguments.Add(dimNode);

            if (argNum >= 0)
            {
                arguments.Add(argList);
                arguments.Add(new IntNode(argNum));
            }

            var funDotCallNode = new FunctionDotCallNode(rhsCall, arguments);

            // funDotCallNode.FunctionCall.Function = rhsCall.Function;
            NodeUtils.SetNodeEndLocation(funDotCallNode, rhsCall);
            return(funDotCallNode);
        }
Пример #26
0
 public virtual TResult Visit(ExprListNode node) => this.VisitChildren(node);