当前位置: 首页>>代码示例>>C#>>正文


C# ProtoCore.PushDependent方法代码示例

本文整理汇总了C#中ProtoCore.PushDependent方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoCore.PushDependent方法的具体用法?C# ProtoCore.PushDependent怎么用?C# ProtoCore.PushDependent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProtoCore的用法示例。


在下文中一共展示了ProtoCore.PushDependent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitLanguageBlockNode

        private void EmitLanguageBlockNode(AssociativeNode node, ref ProtoCore.Type inferedType, ProtoCore.AssociativeGraph.GraphNode graphNode, ProtoCore.CompilerDefinitions.Associative.SubCompilePass subPass = ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kNone)
        {
            if (IsParsingGlobal() || IsParsingGlobalFunctionBody() || IsParsingMemberFunctionBody() )
            {
                if (subPass == ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kUnboundIdentifier)
                {
                    return;
                }

                LanguageBlockNode langblock = node as LanguageBlockNode;

                //Validity.Assert(ProtoCore.Language.kInvalid != langblock.codeblock.language);
                if (ProtoCore.Language.NotSpecified == langblock.codeblock.Language)
                    throw new BuildHaltException("Invalid language block type (D1B95A65)");

                ProtoCore.CompileTime.Context nextContext = new ProtoCore.CompileTime.Context();

                // Save the guid of the current scope (which is stored in the current graphnodes) to the nested language block.
                // This will be passed on to the nested language block that will be compiled
                nextContext.guid = graphNode.guid;

                int entry = 0;
                int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;

                // Top block signifies the auto inserted global block
                bool isTopBlock = null == codeBlock.parent;

                // The warning is enforced only if this is not the top block
                if (ProtoCore.Language.Associative == langblock.codeblock.Language && !isTopBlock)
                {
                    // TODO Jun: Move the associative and all common string into some table
                    buildStatus.LogSyntaxError(Resources.InvalidNestedAssociativeBlock, core.CurrentDSFileName, langblock.line, langblock.col);
                }


                // Set the current class scope so the next language can refer to it
                core.ClassIndex = globalClassIndex;

                if (globalProcIndex != ProtoCore.DSASM.Constants.kInvalidIndex && core.ProcNode == null)
                {
                    if (globalClassIndex != ProtoCore.DSASM.Constants.kInvalidIndex)
                        core.ProcNode = core.ClassTable.ClassNodes[globalClassIndex].ProcTable.Procedures[globalProcIndex];
                    else
                        core.ProcNode = codeBlock.procedureTable.Procedures[globalProcIndex];
                }

                ProtoCore.AssociativeGraph.GraphNode propagateGraphNode = null;
                if (core.Options.AssociativeToImperativePropagation && Language.Imperative == langblock.codeblock.Language)
                {
                    propagateGraphNode = graphNode;
                }

                core.Compilers[langblock.codeblock.Language].Compile(out blockId, codeBlock, langblock.codeblock, nextContext, codeBlock.EventSink, langblock.CodeBlockNode, propagateGraphNode);
                graphNode.isLanguageBlock = true;
                graphNode.languageBlockId = blockId;
                foreach (GraphNode dNode in nextContext.DependentVariablesInScope)
                {
                    graphNode.PushDependent(dNode);
                }

                setBlkId(blockId);
                inferedType = core.InferedType;
                //Validity.Assert(codeBlock.children[codeBlock.children.Count - 1].blockType == ProtoCore.DSASM.CodeBlockType.kLanguage);
                codeBlock.children[codeBlock.children.Count - 1].Attributes = PopulateAttributes(langblock.Attributes);

                EmitInstrConsole(ProtoCore.DSASM.kw.bounce + " " + blockId + ", " + entry.ToString());
                EmitBounceIntrinsic(blockId, entry);


                // The callee language block will have stored its result into the RX register. 
                EmitInstrConsole(ProtoCore.DSASM.kw.push, ProtoCore.DSASM.kw.regRX);
                StackValue opRes = StackValue.BuildRegister(Registers.RX);
                EmitPush(opRes);
            }
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:75,代码来源:CodeGen.cs

示例2: EmitInlineConditionalNode

        private void EmitInlineConditionalNode(AssociativeNode node, ref ProtoCore.Type inferedType, ProtoCore.AssociativeGraph.GraphNode graphNode = null, ProtoCore.CompilerDefinitions.Associative.SubCompilePass subPass = ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kNone, ProtoCore.AST.AssociativeAST.BinaryExpressionNode parentNode = null)
        {
            if (subPass == ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kUnboundIdentifier)
            {
                return;
            }

            bool isInlineConditionalFlag = false;
            int startPC = pc;
            bool isReturn = false;
            if (graphNode != null)
            {
                isInlineConditionalFlag = graphNode.isInlineConditional;
                graphNode.isInlineConditional = true;
                startPC = graphNode.updateBlock.startpc;
                isReturn = graphNode.isReturn;
            }

            InlineConditionalNode inlineConditionalNode = node as InlineConditionalNode;
            // TODO: Jun, this 'if' condition needs to be removed as it was the old implementation - pratapa
            if (inlineConditionalNode.IsAutoGenerated)
            {
                // Normal inline conditional

                IfStatementNode ifNode = new IfStatementNode();
                ifNode.ifExprNode = inlineConditionalNode.ConditionExpression;
                List<AssociativeNode> ifBody = new List<AssociativeNode>();
                List<AssociativeNode> elseBody = new List<AssociativeNode>();
                ifBody.Add(inlineConditionalNode.TrueExpression);
                elseBody.Add(inlineConditionalNode.FalseExpression);
                ifNode.IfBody = ifBody;
                ifNode.ElseBody = elseBody;

                EmitIfStatementNode(ifNode, ref inferedType, graphNode);
            }
            else
            {
                // CPS inline conditional
                
                FunctionCallNode inlineCall = new FunctionCallNode();
                IdentifierNode identNode = new IdentifierNode();
                identNode.Name = ProtoCore.DSASM.Constants.kInlineConditionalMethodName;
                inlineCall.Function = identNode;

                DebugProperties.BreakpointOptions oldOptions = core.DebuggerProperties.breakOptions;
                DebugProperties.BreakpointOptions newOptions = oldOptions;
                newOptions |= DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint;
                core.DebuggerProperties.breakOptions = newOptions;

                core.DebuggerProperties.highlightRange = new ProtoCore.CodeModel.CodeRange
                {
                    StartInclusive = new ProtoCore.CodeModel.CodePoint
                    {
                        LineNo = parentNode.line,
                        CharNo = parentNode.col
                    },

                    EndExclusive = new ProtoCore.CodeModel.CodePoint
                    {
                        LineNo = parentNode.endLine,
                        CharNo = parentNode.endCol
                    }
                };

                // As SSA conversion is enabled, we have got the values of
                // true and false branch, so it isn't necessary to create 
                // language blocks.
                if (core.Options.GenerateSSA)
                {
                    inlineCall.FormalArguments.Add(inlineConditionalNode.ConditionExpression);
                    inlineCall.FormalArguments.Add(inlineConditionalNode.TrueExpression);
                    inlineCall.FormalArguments.Add(inlineConditionalNode.FalseExpression);
                }
                else
                {
                    // True condition language block
                    BinaryExpressionNode bExprTrue = AstFactory.BuildReturnStatement(inlineConditionalNode.TrueExpression);

                    LanguageBlockNode langblockT = new LanguageBlockNode();
                    int trueBlockId = Constants.kInvalidIndex;
                    langblockT.codeblock.Language = ProtoCore.Language.Associative;
                    core.AssocNode = bExprTrue;
                    core.InlineConditionalBodyGraphNodes.Push(new List<GraphNode>());
                    EmitDynamicLanguageBlockNode(langblockT, bExprTrue, ref inferedType, ref trueBlockId, graphNode, ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kNone);
                    List<GraphNode> trueBodyNodes = core.InlineConditionalBodyGraphNodes.Pop();

                    // Append dependent nodes of the inline conditional 
                    foreach (GraphNode gnode in trueBodyNodes)
                        foreach (GraphNode dNode in gnode.dependentList)
                            graphNode.PushDependent(dNode);

                    core.AssocNode = null;
                    DynamicBlockNode dynBlockT = new DynamicBlockNode(trueBlockId);

                    // False condition language block
                    BinaryExpressionNode bExprFalse = AstFactory.BuildReturnStatement(inlineConditionalNode.FalseExpression);

                    LanguageBlockNode langblockF = new LanguageBlockNode();
                    int falseBlockId = Constants.kInvalidIndex;
                    langblockF.codeblock.Language = ProtoCore.Language.Associative;
//.........这里部分代码省略.........
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例3: EmitLanguageBlockNode

        private void EmitLanguageBlockNode(ImperativeNode node, ref ProtoCore.Type inferedType, ProtoCore.AssociativeGraph.GraphNode propogateUpdateGraphNode = null)
        {
            //
            // TODO Jun:
            //      Add support for language blocks, classes and functions in GRAPH post july release
            //      This Temporary guard will no longer be necessary
            bool disableLanguageBlocks = compileStateTracker.IsParsingCodeBlockNode || compileStateTracker.IsParsingPreloadedAssembly;
            if (disableLanguageBlocks)
            {
                compileStateTracker.BuildStatus.LogSemanticError("Defining language blocks are not yet supported");
            }

            if (IsParsingGlobal() || IsParsingGlobalFunctionBody())
            {
                LanguageBlockNode langblock = node as LanguageBlockNode;
                //(Fuqiang, Ayush) : Throwing an assert stops NUnit. Negative tests expect to catch a
                // CompilerException, so we throw that instead.
                //Debug.Assert(ProtoCore.Language.kInvalid != langblock.codeblock.language);

                if (ProtoCore.Language.kInvalid == langblock.codeblock.language)
                {
                    throw new ProtoCore.Exceptions.CompileErrorsOccured("Invalid language block");
                }

                ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context();

                int entry = 0;
                int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
                if (ProtoCore.Language.kImperative == langblock.codeblock.language)
                {
                    // TODO Jun: Move the associative and all common string into some table
                    buildStatus.LogSyntaxError("An imperative language block is declared within an imperative language block.", compileStateTracker.CurrentDSFileName, langblock.line, langblock.col);
                }

                if (globalProcIndex != ProtoCore.DSASM.Constants.kInvalidIndex && compileStateTracker.ProcNode == null)
                {
                    compileStateTracker.ProcNode = codeBlock.procedureTable.procList[globalProcIndex];
                }

                compileStateTracker.Executives[langblock.codeblock.language].Compile(compileStateTracker, out blockId, codeBlock, langblock.codeblock, context, codeBlock.EventSink, langblock.CodeBlockNode);

                if (propogateUpdateGraphNode != null)
                {
                    propogateUpdateGraphNode.languageBlockId = blockId;
                    CodeBlock childBlock = compileStateTracker.CompleteCodeBlockList[blockId];
                    foreach (var subGraphNode in childBlock.instrStream.dependencyGraph.GraphList)
                    {
                        foreach (var depentNode in subGraphNode.dependentList)
                        {
                            if (depentNode.updateNodeRefList != null
                                && depentNode.updateNodeRefList.Count > 0
                                && depentNode.updateNodeRefList[0].nodeList != null
                                && depentNode.updateNodeRefList[0].nodeList.Count > 0)
                            {
                                SymbolNode dependentSymbol = depentNode.updateNodeRefList[0].nodeList[0].symbol;
                                int symbolBlockId = dependentSymbol.codeBlockId;
                                if (symbolBlockId != Constants.kInvalidIndex)
                                {
                                    CodeBlock symbolBlock = compileStateTracker.CompleteCodeBlockList[symbolBlockId];
                                    if (!symbolBlock.IsMyAncestorBlock(codeBlock.codeBlockId))
                                    {
                                        propogateUpdateGraphNode.PushDependent(depentNode);
                                    }
                                }
                            }
                        }
                    }
                }

                setBlkId(blockId);
                inferedType = compileStateTracker.InferedType;
                //Debug.Assert(codeBlock.children[codeBlock.children.Count - 1].blockType == ProtoCore.DSASM.CodeBlockType.kLanguage);
                codeBlock.children[codeBlock.children.Count - 1].Attributes = PopulateAttributes(langblock.Attributes);

            #if ENABLE_EXCEPTION_HANDLING
                core.ExceptionHandlingManager.Register(blockId, globalProcIndex, globalClassIndex);
            #endif

                EmitInstrConsole("bounce " + blockId + ", " + entry.ToString());
                EmitBounceIntrinsic(blockId, entry);

                // The callee language block will have stored its result into the RX register.
                EmitInstrConsole(ProtoCore.DSASM.kw.push, ProtoCore.DSASM.kw.regRX);
                ProtoCore.DSASM.StackValue opRes = new ProtoCore.DSASM.StackValue();
                opRes.optype = ProtoCore.DSASM.AddressType.Register;
                opRes.opdata = (int)ProtoCore.DSASM.Registers.RX;
                EmitPush(opRes);
            }
        }
开发者ID:seasailor,项目名称:designscript,代码行数:89,代码来源:CodeGen.cs

示例4: PushSymbolAsDependent

        /// <summary>
        /// Pushes the symbol as a dependent to graphNode if codegeneration semantic conditions are met
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="graphNode"></param>
        private ProtoCore.AssociativeGraph.GraphNode PushSymbolAsDependent(SymbolNode symbol, ProtoCore.AssociativeGraph.GraphNode graphNode)
        {
            // Check for symbols that need to be pushed as dependents
            // Temporary properties and default args are autogenerated and are not part of the assocaitve behavior
            // For temp properties, refer to: EmitGettersForRHSIdentList
            // For default arg temp vars, refer to usage of: Constants.kTempDefaultArg
            if (CoreUtils.IsPropertyTemp(symbol.name) || CoreUtils.IsDefaultArgTemp(symbol.name))
            {
                return null;
            }

            ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
            dependentNode.PushSymbolReference(symbol, UpdateNodeType.kSymbol);
            graphNode.PushDependent(dependentNode);
            return dependentNode;
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:21,代码来源:CodeGen.cs

示例5: TraverseFunctionCall


//.........这里部分代码省略.........
                        int classIndex = compileStateTracker.ClassTable.IndexOf(procName);
                        int dummy;

                        if (classIndex != Constants.kInvalidIndex)
                        {
                            procNode = compileStateTracker.ClassTable.ClassNodes[classIndex].GetMemberFunction(procName, arglist, globalClassIndex, out isAccessible, out dummy, true);
                            if (procNode != null && procNode.isConstructor)
                            {
                                type = classIndex;
                            }
                            else
                            {
                                procNode = null;
                            }
                        }
                    }
                }
            }

            // Try function pointer firstly
            if ((procNode == null) && (procName != ProtoCore.DSASM.Constants.kFunctionPointerCall))
            {
                bool isAccessibleFp;
                ProtoCore.DSASM.SymbolNode symbolnode = null;
                bool isAllocated = VerifyAllocation(procName, globalClassIndex, globalProcIndex, out symbolnode, out isAccessibleFp);
                if (isAllocated) // not checking the type against function pointer, as the type could be var
                {
                    procName = ProtoCore.DSASM.Constants.kFunctionPointerCall;
                    // The graph node always depends on this function pointer
                    if (null != graphNode)
                    {
                        ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                        dependentNode.PushSymbolReference(symbolnode);
                        graphNode.PushDependent(dependentNode);
                    }
                }
            }

            // Always try global function firstly. Because we dont have syntax
            // support for calling global function (say, ::foo()), if we try
            // member function firstly, there is no way to call a global function
            // For member function, we can use this.foo() to distinguish it from
            // global function.
            if ((procNode == null) && (procName != ProtoCore.DSASM.Constants.kFunctionPointerCall))
            {
                procNode = compileStateTracker.GetFirstVisibleProcedure(procName, arglist, codeBlock);
                if (null != procNode)
                {
                    type = ProtoCore.DSASM.Constants.kGlobalScope;
                    if (compileStateTracker.TypeSystem.IsHigherRank(procNode.returntype.UID, inferedType.UID))
                    {
                        inferedType = procNode.returntype;
                    }
                }
            }

            // Try member functions in global class scope
            if ((procNode == null) && (procName != ProtoCore.DSASM.Constants.kFunctionPointerCall) && (parentNode == null))
            {
                if (globalClassIndex != ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    int realType;
                    bool isAccessible;
                    bool isStaticOrConstructor = refClassIndex != ProtoCore.DSASM.Constants.kInvalidIndex;
                    ProtoCore.DSASM.ProcedureNode memProcNode = compileStateTracker.ClassTable.ClassNodes[globalClassIndex].GetMemberFunction(procName, arglist, globalClassIndex, out isAccessible, out realType, isStaticOrConstructor);
开发者ID:seasailor,项目名称:designscript,代码行数:66,代码来源:CodeGen.cs

示例6: EmitIdentifierNode


//.........这里部分代码省略.........
                        EmitInstrConsole(ProtoCore.DSASM.kw.push, t.Name);
                        ProtoCore.DSASM.StackValue opFunctionPointer = new ProtoCore.DSASM.StackValue();
                        opFunctionPointer.optype = ProtoCore.DSASM.AddressType.FunctionPointer;
                        opFunctionPointer.opdata = fptr;
                        opFunctionPointer.opdata_d = fptr;
                        EmitPush(opFunctionPointer, t.line, t.col);
                        return;
                    }
                }
            }

            bool isAllocated = VerifyAllocation(t.Value, globalClassIndex, globalProcIndex, out symbolnode, out isAccessible);
            if (!isAllocated || !isAccessible)
            {
                if (isAllocated)
                {
                    if (!isAccessible)
                    {
                        string message = String.Format(ProtoCore.BuildData.WarningMessage.kPropertyIsInaccessible, t.Value);
                        buildStatus.LogWarning(ProtoCore.BuildData.WarningID.kAccessViolation, message, compileStateTracker.CurrentDSFileName, t.line, t.col);
                    }
                }
                else
                {
                    string message = String.Format(ProtoCore.BuildData.WarningMessage.kUnboundIdentifierMsg, t.Value);
                    buildStatus.LogWarning(ProtoCore.BuildData.WarningID.kIdUnboundIdentifier, message, compileStateTracker.CurrentDSFileName, t.line, t.col);
                }

                inferedType.UID = (int)ProtoCore.PrimitiveType.kTypeNull;

                // Jun Comment: Specification excerpt
                //      If resolution fails at this point a com.Design-Script.Imperative.Core.UnboundIdentifier
                //      warning is emitted during pre-execute phase, and at the ID is bound to null. (R1 - Feb)

                EmitPushNull();

                EmitPushVarData(runtimeIndex, dimensions);

                ProtoCore.Type varType = compileStateTracker.TypeSystem.BuildTypeObject((int)PrimitiveType.kTypeVar, false, 0);
                symbolnode = Allocate(t.Value, globalProcIndex, varType);

                EmitInstrConsole(ProtoCore.DSASM.kw.pop, t.Value);
                EmitPopForSymbol(symbolnode);
            }
            else
            {
                type = symbolnode.datatype;
                runtimeIndex = symbolnode.runtimeTableIndex;

                if (compileStateTracker.Options.AssociativeToImperativePropagation)
                {
                    // Comment Jun: If this symbol belongs to an outer block, then append it to this language blocks dependent
                    if (symbolnode.codeBlockId != codeBlock.codeBlockId)
                    {
                        // A parent codeblock owns this symbol
                        if (null != graphNode)
                        {
                            ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                            dependentNode.PushSymbolReference(symbolnode);
                            graphNode.PushDependent(dependentNode);
                        }
                    }
                }
            }

            if (null != t.ArrayDimensions)
            {
                dimensions = DfsEmitArrayIndexHeap(t.ArrayDimensions);
            }

            //fix type's rank
            //fix type's rank
            if (type.rank >= 0)
            {
                type.rank -= dimensions;
                if (type.rank < 0)
                {
                    //throw new Exception("Exceed maximum rank!");
                    type.rank = 0;
                }
            }

            //check whether the value is an array
            if (type.rank == 0)
            {
                type.IsIndexable = false;
            }

            EmitPushVarData(runtimeIndex, dimensions);

            EmitInstrConsole(ProtoCore.DSASM.kw.push, t.Value);
            EmitPushForSymbol(symbolnode, t);

            if (compileStateTracker.TypeSystem.IsHigherRank(type.UID, inferedType.UID))
            {
                inferedType = type;
            }
            // We need to get inferedType for boolean variable so that we can perform type check
            inferedType.UID = (isBooleanOp || (type.UID == (int)PrimitiveType.kTypeBool)) ? (int)PrimitiveType.kTypeBool : type.UID;
        }
开发者ID:seasailor,项目名称:designscript,代码行数:101,代码来源:CodeGen.cs

示例7: EmitIdentNode


//.........这里部分代码省略.........
                        {
                            var curDep = graphNode.dependentList[curDepIndex].updateNodeRefList[0].nodeList[0];
                            curDep.dimensionNodeList.Add(updateNode);

                            if (null != firstSSAGraphNode)
                            {
                                curDepIndex = firstSSAGraphNode.dependentList.Count - 1;
                                if (curDepIndex >= 0)
                                {
                                    ProtoCore.AssociativeGraph.UpdateNode firstSSAUpdateNode = firstSSAGraphNode.dependentList[curDepIndex].updateNodeRefList[0].nodeList[0];
                                    firstSSAUpdateNode.dimensionNodeList.Add(updateNode);
                                }
                            }
                        }
                    }
                }

                // If it is a property, replaced it with getter: %get_prop()
                if (symbolnode.classScope != ProtoCore.DSASM.Constants.kInvalidIndex &&
                    symbolnode.functionIndex == ProtoCore.DSASM.Constants.kGlobalScope &&
                    localProcedure != null)
                {
                    string getterName = ProtoCore.DSASM.Constants.kGetterPrefix + t.Name;
                    if (!string.Equals(localProcedure.name, getterName))
                    {
                        var thisNode = nodeBuilder.BuildIdentfier(ProtoCore.DSDefinitions.Keyword.This);
                        var identListNode = nodeBuilder.BuildIdentList(thisNode, t);
                        EmitIdentifierListNode(identListNode, ref inferedType, false, graphNode, ProtoCore.DSASM.AssociativeSubCompilePass.kNone);

                        if (null != graphNode)
                        {
                            ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                            dependentNode.PushSymbolReference(symbolnode);
                            graphNode.PushDependent(dependentNode);
                        }

                        return;
                    }
                }

                type = symbolnode.datatype;
                runtimeIndex = symbolnode.runtimeTableIndex;

                // The graph node always depends on this identifier
                if (null != graphNode)
                {
                    ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                    dependentNode.PushSymbolReference(symbolnode);
                    graphNode.PushDependent(dependentNode);
                }

                bool emitReplicationGuideFlag = emitReplicationGuide;
                emitReplicationGuide = false;
                if (null != t.ArrayDimensions)
                {
                    dimensions = DfsEmitArrayIndexHeap(t.ArrayDimensions, graphNode, parentNode, subPass);
                }
                emitReplicationGuide = emitReplicationGuideFlag;

                //fix type's rank
                if (type.rank >= 0)
                {
                    type.rank -= dimensions;
                    if (type.rank < 0)
                    {
                        //throw new Exception("Exceed maximum rank!");
开发者ID:samuto,项目名称:designscript,代码行数:67,代码来源:CodeGen.cs

示例8: TraverseDotFunctionCall


//.........这里部分代码省略.........
                            x = p<1>.f({1,2}<2>); // guides allowed on the pointer 'p'

                            class A
                            {
                                x : var[];
                                constructor A()
                                {
                                    x = {1,2};
                                }
                            }
                            a = A.A();
                            b = A.A();
                            c = a<1>.x<2>; // guides not allowed on getter

                         */
                        if (!ProtoCore.Utils.CoreUtils.IsGetterSetter(procName) && !isConstructor)
                        {
                            emitReplicationGuide = true;
                        }

                        DfsTraverse(paramNode, ref paramType, false, graphNode, subPass, bnode);
                        if (subPass != ProtoCore.DSASM.AssociativeSubCompilePass.kUnboundIdentifier)
                        {
                            if (isStaticCall && isStaticCallAllowed)
                            {
                                Validity.Assert(ProtoCore.DSASM.Constants.kInvalidIndex != classIndex);
                                Validity.Assert(string.Empty != className);
                                SymbolNode classSymbol = new SymbolNode();
                                classSymbol.name = className;
                                classSymbol.classScope = classIndex;

                                ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                                dependentNode.PushSymbolReference(classSymbol, ProtoCore.AssociativeGraph.UpdateNodeType.kSymbol);
                                graphNode.PushDependent(dependentNode);
                            }
                        }
                    }

                    // Traversing the actual arguments passed into the function (not the dot function)
                    else if (ProtoCore.DSASM.Constants.kDotArgIndexArrayArgs == n)
                    {
                        int defaultAdded = 0;

                        // If its null this is the second call in a chained dot
                        if (null != procCallNode)
                        {
                            // Check how many args were passed in.... against what is expected
                            defaultAdded = procCallNode.argInfoList.Count - dotCall.FunctionCall.FormalArguments.Count;
                        }

                        // Enable graphnode dependencies if its a setter method
                        bool allowDependentState = null != graphNode ? graphNode.allowDependents : false;
                        if (ProtoCore.Utils.CoreUtils.IsSetter(procName))
                        {
                            // If the arguments are not temporaries
                            ProtoCore.AST.AssociativeAST.ExprListNode exprList = paramNode as ExprListNode;
                            Validity.Assert(1 == exprList.list.Count);

                            string varname = string.Empty;
                            if (exprList.list[0] is IdentifierNode)
                            {
                                varname = (exprList.list[0] as IdentifierNode).Name;

                                // Only allow the acutal function variables and SSA temp vars
                                // TODO Jun: determine what temp could be passed in that is autodegenerated and non-SSA
                                if (!ProtoCore.Utils.CoreUtils.IsAutoGeneratedVar(varname)
开发者ID:samuto,项目名称:designscript,代码行数:67,代码来源:CodeGen.cs

示例9: TraverseFunctionCall


//.........这里部分代码省略.........
                {
                    Debug.Assert(realType != ProtoCore.DSASM.Constants.kInvalidIndex);
                    type = lefttype = realType;

                    if (!isAccessible)
                    {
                        type = lefttype = realType;
                        procNode = null;
                        string message = String.Format(ProtoCore.BuildData.WarningMessage.kMethodIsInaccessible, procName);
                        buildStatus.LogWarning(ProtoCore.BuildData.WarningID.kAccessViolation, message, compileStateTracker.CurrentDSFileName, funcCall.line, funcCall.col);
                        inferedType.UID = (int)PrimitiveType.kTypeNull;

                        EmitPushNull();
                        return procNode;
                    }

                }
            }

            // Try function pointer firstly
            if ((procNode == null) && (procName != ProtoCore.DSASM.Constants.kFunctionPointerCall))
            {
                bool isAccessibleFp;
                ProtoCore.DSASM.SymbolNode symbolnode = null;
                bool isAllocated = VerifyAllocation(procName, globalClassIndex, globalProcIndex, out symbolnode, out isAccessibleFp);
                if (isAllocated) // not checking the type against function pointer, as the type could be var
                {
                    procName = ProtoCore.DSASM.Constants.kFunctionPointerCall;
                    // The graph node always depends on this function pointer
                    if (null != graphNode)
                    {
                        ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                        dependentNode.PushSymbolReference(symbolnode);
                        graphNode.PushDependent(dependentNode);
                    }
                }
            }

            // Always try global function firstly. Because we dont have syntax
            // support for calling global function (say, ::foo()), if we try
            // member function firstly, there is no way to call a global function
            // For member function, we can use this.foo() to distinguish it from
            // global function.
            if ((procNode == null) && (procName != ProtoCore.DSASM.Constants.kFunctionPointerCall))
            {
                procNode = compileStateTracker.GetFirstVisibleProcedure(procName, arglist, codeBlock);
                if (null != procNode)
                {
                    type = ProtoCore.DSASM.Constants.kGlobalScope;
                    if (compileStateTracker.TypeSystem.IsHigherRank(procNode.returntype.UID, inferedType.UID))
                    {
                        inferedType = procNode.returntype;
                    }
                }
            }

            // Try member functions in global class scope
            if ((procNode == null) && (procName != ProtoCore.DSASM.Constants.kFunctionPointerCall) && (parentNode == null))
            {
                if (globalClassIndex != ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    int realType;
                    bool isAccessible;
                    bool isStaticOrConstructor = refClassIndex != ProtoCore.DSASM.Constants.kInvalidIndex;
                    ProtoCore.DSASM.ProcedureNode memProcNode = compileStateTracker.ClassTable.ClassNodes[globalClassIndex].GetMemberFunction(procName, arglist, globalClassIndex, out isAccessible, out realType, isStaticOrConstructor);
开发者ID:samuto,项目名称:designscript,代码行数:66,代码来源:CodeGen.cs

示例10: EmitLanguageBlockNode

        private void EmitLanguageBlockNode(ImperativeNode node, ref ProtoCore.Type inferedType, ProtoCore.AssociativeGraph.GraphNode propogateUpdateGraphNode = null)
        {
            if (IsParsingGlobal() || IsParsingGlobalFunctionBody())
            {
                LanguageBlockNode langblock = node as LanguageBlockNode;
                //(Fuqiang, Ayush) : Throwing an assert stops NUnit. Negative tests expect to catch a 
                // CompilerException, so we throw that instead.
                //Validity.Assert(ProtoCore.Language.kInvalid != langblock.codeblock.language);

                if (ProtoCore.Language.kInvalid == langblock.codeblock.language)
                {
                    throw new ProtoCore.Exceptions.CompileErrorsOccured("Invalid language block");
                }

                ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context();
                // Save the guid of the current scope (which is stored in the current graphnodes) to the nested language block.
                // This will be passed on to the nested language block that will be compiled
                if (propogateUpdateGraphNode != null)
                {
                    context.guid = propogateUpdateGraphNode.guid;
                }

                int entry = 0;
                int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
                if (ProtoCore.Language.kImperative == langblock.codeblock.language)
                {
                    // TODO Jun: Move the associative and all common string into some table
                    buildStatus.LogSyntaxError(Resources.InvalidNestedImperativeBlock, core.CurrentDSFileName, langblock.line, langblock.col);
                }

                if (globalProcIndex != ProtoCore.DSASM.Constants.kInvalidIndex && core.ProcNode == null)
                    core.ProcNode = codeBlock.procedureTable.procList[globalProcIndex];

                core.Compilers[langblock.codeblock.language].Compile(out blockId, codeBlock, langblock.codeblock, context, codeBlock.EventSink, langblock.CodeBlockNode);

                if (propogateUpdateGraphNode != null)
                {
                    propogateUpdateGraphNode.languageBlockId = blockId;
                    CodeBlock childBlock = core.CompleteCodeBlockList[blockId];
                    foreach (var subGraphNode in childBlock.instrStream.dependencyGraph.GraphList)
                    {
                        foreach (var depentNode in subGraphNode.dependentList)
                        {
                            if (depentNode.updateNodeRefList != null 
                                && depentNode.updateNodeRefList.Count > 0 
                                && depentNode.updateNodeRefList[0].nodeList != null
                                && depentNode.updateNodeRefList[0].nodeList.Count > 0)
                            {
                                SymbolNode dependentSymbol = depentNode.updateNodeRefList[0].nodeList[0].symbol;
                                int symbolBlockId = dependentSymbol.codeBlockId;
                                if (symbolBlockId != Constants.kInvalidIndex)
                                {
                                    CodeBlock symbolBlock = core.CompleteCodeBlockList[symbolBlockId];
                                    if (!symbolBlock.IsMyAncestorBlock(codeBlock.codeBlockId))
                                    {
                                        propogateUpdateGraphNode.PushDependent(depentNode);
                                    }
                                }
                            }
                        }
                    }
                }

                setBlkId(blockId);
                inferedType = core.InferedType;
                //Validity.Assert(codeBlock.children[codeBlock.children.Count - 1].blockType == ProtoCore.DSASM.CodeBlockType.kLanguage);
                codeBlock.children[codeBlock.children.Count - 1].Attributes = PopulateAttributes(langblock.Attributes);

                EmitInstrConsole("bounce " + blockId + ", " + entry.ToString());
                EmitBounceIntrinsic(blockId, entry);

                // The callee language block will have stored its result into the RX register. 
                EmitInstrConsole(ProtoCore.DSASM.kw.push, ProtoCore.DSASM.kw.regRX);
                StackValue opRes = StackValue.BuildRegister(Registers.RX);
                EmitPush(opRes);
            }
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:77,代码来源:CodeGen.cs

示例11: EmitIdentifierNode


//.........这里部分代码省略.........
                        int fptr = core.FunctionPointerTable.functionPointerDictionary.Count;
                        var fptrNode = new ProtoCore.DSASM.FunctionPointerNode(procNode);
                        core.FunctionPointerTable.functionPointerDictionary.TryAdd(fptr, fptrNode);
                        core.FunctionPointerTable.functionPointerDictionary.TryGetBySecond(fptrNode, out fptr);

                        EmitInstrConsole(ProtoCore.DSASM.kw.push, t.Name);
                        StackValue opFunctionPointer = StackValue.BuildFunctionPointer(fptr);
                        EmitPush(opFunctionPointer, runtimeIndex, t.line, t.col);
                        return;
                    }
                }
            }

            if (!isAllocated || !isAccessible)
            {
                if (isAllocated)
                {
                    if (!isAccessible)
                    {
                        string message = String.Format(ProtoCore.Properties.Resources.kPropertyIsInaccessible, t.Value);
                        buildStatus.LogWarning(WarningID.AccessViolation, message, core.CurrentDSFileName, t.line, t.col, graphNode);
                    }
                }
                else
                {
                    string message = String.Format(ProtoCore.Properties.Resources.kUnboundIdentifierMsg, t.Value);
                    var unboundSymbol = new SymbolNode
                    {
                        name = t.Value
                    };
                    buildStatus.LogUnboundVariableWarning(unboundSymbol, message, core.CurrentDSFileName, t.line, t.col, graphNode);
                }

                inferedType.UID = (int)ProtoCore.PrimitiveType.Null;

                // Jun Comment: Specification excerpt
                //      If resolution fails at this point a com.Design-Script.Imperative.Core.UnboundIdentifier 
                //      warning is emitted during pre-execute phase, and at the ID is bound to null. (R1 - Feb)

                EmitPushNull();
                ProtoCore.Type varType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, 0);
                symbolnode = Allocate(t.Value, globalProcIndex, varType);

                EmitInstrConsole(kw.pop, t.Value);
                EmitPopForSymbol(symbolnode, runtimeIndex);
            }
            else
            {
                type = symbolnode.datatype;
                runtimeIndex = symbolnode.runtimeTableIndex;

                if (core.Options.AssociativeToImperativePropagation)
                {
                    // Comment Jun: If this symbol belongs to an outer block, then append it to this language blocks dependent
                    if (symbolnode.codeBlockId != codeBlock.codeBlockId)
                    {
                        // A parent codeblock owns this symbol
                        if (null != graphNode)
                        {
                            ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
                            dependentNode.PushSymbolReference(symbolnode);
                            graphNode.PushDependent(dependentNode);
                        }
                    }
                }
            }

            EmitInstrConsole(kw.push, t.Value);
            EmitPushForSymbol(symbolnode, runtimeIndex, t);

            if (null != t.ArrayDimensions)
            {
                dimensions = DfsEmitArrayIndexHeap(t.ArrayDimensions);
            }

            //fix type's rank    
            //fix type's rank   
            if (type.rank >= 0)
            {
                type.rank -= dimensions;
                if (type.rank < 0)
                {
                    //throw new Exception("Exceed maximum rank!");
                    type.rank = 0;
                }
            }

            if (dimensions > 0)
            {
                EmitPushDimensions(dimensions);
                EmitLoadElement(symbolnode, runtimeIndex);
            }

            if (core.TypeSystem.IsHigherRank(type.UID, inferedType.UID))
            {
                inferedType = type;
            }
            // We need to get inferedType for boolean variable so that we can perform type check
            inferedType.UID = (isBooleanOp || (type.UID == (int)PrimitiveType.Bool)) ? (int)PrimitiveType.Bool : type.UID;
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs


注:本文中的ProtoCore.PushDependent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。