Пример #1
0
        public AssociativeNode CompileToAstNode(AstBuilder builder)
        {
            if (!RequiresRecalc)
            {
                return this.AstIdentifier;
            }

            builder.ClearAstNodes(GUID);
            bool isPartiallyApplied = false;

            // Recursively compile its inputs to ast nodes and add intermediate
            // nodes to builder
            var inputAstNodes = new List<AssociativeNode>();
            for (int index = 0; index < InPortData.Count; ++index)
            {
                Tuple<int, NodeModel> input;
                if (!TryGetInput(index, out input))
                {
                    isPartiallyApplied = true;
                    inputAstNodes.Add(null);
                }
                else
                {
                    inputAstNodes.Add(input.Item2.CompileToAstNode(builder));
                }
            }

            // Build evaluatiion for this node. If the rhs is a partially
            // applied function, then a function defintion node will be created.
            // But in the end there is always an assignment:
            //
            //     AstIdentifier = ...;
            var rhs = BuildAstNode(builder, inputAstNodes)
                      ?? builder.BuildEvaluator(this, inputAstNodes);
            builder.BuildEvaluation(this, rhs, isPartiallyApplied);

            return AstIdentifier;
        }