• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ProtoCore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ConcatString

 public static StackValue ConcatString(StackValue op1, StackValue op2, ProtoCore.Core core)
 {
     var v1 = op1.IsString ? ArrayUtils.GetValues(op1, core) : new StackValue[] { op1 };
     var v2 = op2.IsString ? ArrayUtils.GetValues(op2, core) : new StackValue[] { op2 };
     StackValue tmp = core.Rmem.BuildArray(v1.Concat(v2).ToArray());
     return StackValue.BuildString(tmp.opdata);
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:7,代码来源:StringUtils.cs


示例2: BuildAssocIdentifier

 public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(ProtoLanguage.CompileStateTracker compileState, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
 {
     var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
     ident.Name = ident.Value = name;
     ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, false);
     return ident;
 }
开发者ID:junmendoza,项目名称:designscript,代码行数:7,代码来源:CoreUtils.cs


示例3: BuildAssocIdentifier

 public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(Core core, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
 {
     var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
     ident.Name = ident.Value = name;
     ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, 0);
     return ident;
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:7,代码来源:CoreUtils.cs


示例4: Compile

        private bool Compile(string code, ProtoCore.Core core, ProtoCore.CompileTime.Context context)
        {
            bool buildSucceeded = false;
            try
            {
                // No More HashAngleReplace for unified parser (Fuqiang)
                //String strSource = ProtoCore.Utils.LexerUtils.HashAngleReplace(code);    

                //defining the global Assoc block that wraps the entire .ds source file
                ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock();
                globalBlock.Language = ProtoCore.Language.Associative;
                globalBlock.Code = code;

                //passing the global Assoc wrapper block to the compiler
                ProtoCore.Language id = globalBlock.Language;
                int blockId = Constants.kInvalidIndex;
                core.Compilers[id].Compile(out blockId, null, globalBlock, context, EventSink);

                core.BuildStatus.ReportBuildResult();
                buildSucceeded = core.BuildStatus.BuildSucceeded;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return buildSucceeded;
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:28,代码来源:ProtoScriptRunner.cs


示例5: ImperativeCodeGen

        public ImperativeCodeGen(ProtoLanguage.CompileStateTracker compileState, ProtoCore.DSASM.CodeBlock parentBlock = null)
            : base(compileState, parentBlock)
        {
            //  dumpbytecode is optionally enabled
            //
            astNodes = new List<ImperativeNode>();

            SetCompileOptions();

            // Create a new symboltable for this block
            // Set the new symbol table's parent
            // Set the new table as a child of the parent table

            codeBlock = new ProtoCore.DSASM.CodeBlock(
                ProtoCore.DSASM.CodeBlockType.kLanguage,
                ProtoCore.Language.kImperative,
                compileState.CodeBlockIndex,
                new ProtoCore.DSASM.SymbolTable("imperative lang block", compileState.RuntimeTableIndex),
                new ProtoCore.DSASM.ProcedureTable(compileState.RuntimeTableIndex));

            ++compileState.CodeBlockIndex;
            ++compileState.RuntimeTableIndex;

            compileState.CodeBlockList.Add(codeBlock);
            if (null != parentBlock)
            {
                // This is a nested block
                parentBlock.children.Add(codeBlock);
                codeBlock.parent = parentBlock;
            }

            blockScope = 0;
        }
开发者ID:samuto,项目名称:designscript,代码行数:33,代码来源:ImperativeCodeGen.cs


示例6: ExecutionMirror

        /// <summary>
        /// Create a mirror for a given executive
        /// </summary>
        /// <param name="exec"></param>
        public ExecutionMirror(ProtoCore.DSASM.Executive exec, ProtoCore.RuntimeCore coreObj)
        {
            Validity.Assert(exec != null, "Can't mirror a null executive");

            runtimeCore = coreObj;
            MirrorTarget = exec;
        }
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:11,代码来源:ExecutionMirror.cs


示例7: LoadAndExecute

        public ExecutionMirror LoadAndExecute(string fileName, ProtoCore.Core core, bool isTest = true)
        {
            string codeContent = string.Empty;

            try
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader(fileName, Encoding.UTF8, true))
                {
                    codeContent = reader.ReadToEnd();
                }
            }
            catch (System.IO.IOException)
            {
                throw new FatalError("Cannot open file " + fileName);
            }

            //Start the timer
            core.StartTimer();
            core.CurrentDSFileName = ProtoCore.Utils.FileUtils.GetFullPathName(fileName);
            core.Options.RootModulePathName = core.CurrentDSFileName;

            Execute(codeContent, core);
            if (!core.Options.CompileToLib && (null != core.CurrentExecutive))
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);

            return null;
        }
开发者ID:samuto,项目名称:designscript,代码行数:27,代码来源:ProtoScriptWebRunner.cs


示例8: Compile

        public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null)
        {
            Validity.Assert(langBlock != null);
            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;

            bool buildSucceeded = false;
            bool isLanguageSignValid = isLanguageSignValid = core.Langverify.Verify(langBlock);

            if (isLanguageSignValid)
            {
                try
                {
                    ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core, callContext, parentBlock);

                    codegen.context = callContext;
                    codegen.codeBlock.EventSink = sink;
                    blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode);
                }
                catch (ProtoCore.BuildHaltException)
                {
                }

                buildSucceeded = core.BuildStatus.BuildSucceeded;
            }
            return buildSucceeded;
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:26,代码来源:Compiler.cs


示例9: CoreCodeGen

        public CoreCodeGen(ProtoLanguage.CompileStateTracker compileState, ProtoCore.DSASM.CodeBlock parentBlock = null)
        {
            Debug.Assert(compileState != null);
            this.compileState = compileState;
            argOffset = 0;
            globalClassIndex = compileState.ClassIndex;

            if (null == CoreCodeGen.CodeRangeTable)
                CoreCodeGen.CodeRangeTable = new CodeRangeTable();
            if (null == CoreCodeGen.IdentLocation)
                CoreCodeGen.IdentLocation = new IdentLocationTable();
            if (null == CoreCodeGen.ImportTable)
                CoreCodeGen.ImportTable = new ImportTable();

            context = new ProtoCore.CompileTime.Context();

            targetLangBlock = ProtoCore.DSASM.Constants.kInvalidIndex;

            enforceTypeCheck = true;

            localProcedure = compileState.ProcNode;
            globalProcIndex = null != localProcedure ? localProcedure.procId : ProtoCore.DSASM.Constants.kGlobalScope;

            tryLevel = 0;
        }
开发者ID:qingemeng,项目名称:designscript,代码行数:25,代码来源:CoreCodeGen.cs


示例10: Compile

        public override bool Compile(ProtoLanguage.CompileStateTracker compileState, out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null)
        {
            Debug.Assert(langBlock != null);
            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;

            bool buildSucceeded = false;
            bool isLanguageSignValid = isLanguageSignValid = compileState.Langverify.Verify(langBlock);

            if (isLanguageSignValid)
            {
                try
                {
                    ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(compileState, parentBlock);

                    codegen.context = callContext;
                    codegen.codeBlock.EventSink = sink;
                    blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode);
                }
                catch (ProtoCore.BuildHaltException e)
                {
            #if DEBUG
                    //core.BuildStatus.LogSemanticError(e.errorMsg);
            #endif
                }

                int errors = 0;
                int warnings = 0;
                buildSucceeded = compileState.BuildStatus.GetBuildResult(out errors, out warnings);
            }
            return buildSucceeded;
        }
开发者ID:samuto,项目名称:designscript,代码行数:31,代码来源:Executive.cs


示例11: BinExprNode

 public BinExprNode(ProtoCore.DSASM.Operator optr, Node leftNode, Node rightNode)
     : base(leftNode.Name, leftNode.Guid)
 {
     this.Optr = optr;
     this.left = leftNode;
     this.right = rightNode;
 }
开发者ID:algobasket,项目名称:Dynamo,代码行数:7,代码来源:DerivedNodes.cs


示例12: Compile

        public bool Compile(string code, ProtoCore.Core core, out int blockId)
        {
            bool buildSucceeded = false;
            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            try
            {
                // No More HashAngleReplace for unified parser (Fuqiang)
                //String strSource = ProtoCore.Utils.LexerUtils.HashAngleReplace(code);
                System.IO.MemoryStream sourceMemStream = new System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(code));
                ProtoScript.GenerateScript gs = new ProtoScript.GenerateScript(core);

                core.Script = gs.preParseFromStream(sourceMemStream);

                foreach (ProtoCore.LanguageCodeBlock codeblock in core.Script.codeblockList)
                {
                    ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context();
                    ProtoCore.Language id = codeblock.language;

                    core.Executives[id].Compile(out blockId, null, codeblock, context, EventSink);
                }

                core.BuildStatus.ReportBuildResult();

                buildSucceeded = core.BuildStatus.BuildSucceeded;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return buildSucceeded;
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:32,代码来源:ProtoScriptRunner.cs


示例13: Execute

        private ExecutionMirror Execute(string code, ProtoCore.Core core, bool isTest = true)
        {
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(code, core, out blockId);

            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushFrameForGlobals(core.GlobOffset);
                core.RunningBlock = blockId;
                Execute(core);

                if (!isTest) { core.Heap.Free(); }


                if (isTest && !core.Options.CompileToLib)
                    return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
                else
                    return null;
            }
            //else
            //  throw new ProtoCore.Exceptions.CompileErrorsOccured();

            //if (isTest && !core.Options.CompileToLib)
            //    return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            //else
            return null;
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:28,代码来源:ProtoScriptWebRunner.cs


示例14: RuntimeMirror

 /// <summary>
 /// This consutructor is for instantiating a Runtime mirror object where we already have the mirrorData
 /// </summary>
 /// <param name="mirrorData"></param>
 /// <param name="core"></param>
 public RuntimeMirror(MirrorData mirrorData, ProtoCore.Core core, ProtoCore.Core staticCore = null) : base(core, staticCore)
 {
     Validity.Assert(this.core != null);
     TargetExecutive = core.CurrentExecutive.CurrentDSASMExec;
     deprecateThisMirror = new DSASM.Mirror.ExecutionMirror(TargetExecutive, core);
     this.mirrorData = mirrorData;
 }
开发者ID:algobasket,项目名称:Dynamo,代码行数:12,代码来源:Mirror.cs


示例15: DebugRunner

 public DebugRunner(ProtoCore.Core core)
 {
     this.core = core;
     this.core.Options.IDEDebugMode = true;
     RegisteredBreakpoints = new List<Breakpoint>();
     executionsuspended = false;
 }
开发者ID:joespiff,项目名称:Dynamo,代码行数:7,代码来源:DebugRunner.cs


示例16: GetOpType

 protected ProtoCore.DSASM.AddressType GetOpType(ProtoCore.PrimitiveType type)
 {
     ProtoCore.DSASM.AddressType optype = ProtoCore.DSASM.AddressType.Int;
     // Data coercion for the prototype
     // The JIL executive handles int primitives
     if (ProtoCore.PrimitiveType.kTypeInt == type
         || ProtoCore.PrimitiveType.kTypeBool == type
         || ProtoCore.PrimitiveType.kTypeChar == type
         || ProtoCore.PrimitiveType.kTypeString == type)
     {
         optype = ProtoCore.DSASM.AddressType.Int;
     }
     else if (ProtoCore.PrimitiveType.kTypeDouble == type)
     {
         optype = ProtoCore.DSASM.AddressType.Double;
     }
     else if (ProtoCore.PrimitiveType.kTypeVar == type)
     {
         optype = ProtoCore.DSASM.AddressType.VarIndex;
     }
     else if (ProtoCore.PrimitiveType.kTypeReturn == type)
     {
         optype = ProtoCore.DSASM.AddressType.Register;
     }
     else
     {
         Debug.Assert(false);
     }
     return optype;
 }
开发者ID:qingemeng,项目名称:designscript,代码行数:30,代码来源:CoreCodeGen.cs


示例17: Compile

        public ProtoLanguage.CompileStateTracker Compile(ProtoCore.CompileTime.Context context, ProtoCore.Core core, out int blockId)
        {
            ProtoLanguage.CompileStateTracker compileState = ProtoScript.CompilerUtils.BuildDefaultCompilerState(core.Options.IsDeltaExecution);

            core.ExecMode = ProtoCore.DSASM.InterpreterMode.kNormal;

            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            try
            {
                //defining the global Assoc block that wraps the entire .ds source file
                ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock();
                globalBlock.language = ProtoCore.Language.kAssociative;

                Validity.Assert(null != context.SourceCode && String.Empty != context.SourceCode);
                globalBlock.body = context.SourceCode;
                //the wrapper block can be given a unique id to identify it as the global scope
                globalBlock.id = ProtoCore.LanguageCodeBlock.OUTERMOST_BLOCK_ID;

                //passing the global Assoc wrapper block to the compiler
                ProtoCore.Language id = globalBlock.language;
                compileState.Executives[id].Compile(compileState, out blockId, null, globalBlock, context, EventSink);

                compileState.BuildStatus.ReportBuildResult();

                int errors = 0;
                int warnings = 0;
                compileState.compileSucceeded = compileState.BuildStatus.GetBuildResult(out errors, out warnings);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return compileState;
        }
开发者ID:samuto,项目名称:designscript,代码行数:35,代码来源:ProtoScriptTestRunner.cs


示例18: Execute

        public void Execute(string code, ProtoCore.Core core)
        {
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            ProtoLanguage.CompileStateTracker compileState = Compile(code, out blockId);
            Validity.Assert(null != compileState);
            if (compileState.compileSucceeded)
            {
                // This is the boundary between compilestate and runtime core
                // Generate the executable
                compileState.GenerateExecutable();

                // Get the executable from the compileState
                core.DSExecutable = compileState.DSExecutable;

                // Setup the initial size of the global stack
                core.Rmem.PushGlobFrame(compileState.GlobOffset);
                core.RunningBlock = blockId;

                Execute(core);
                core.Heap.Free();

                //core.GenerateExecutable();
                //core.Rmem.PushGlobFrame(core.GlobOffset);
                //core.RunningBlock = blockId;
                //Execute(core);
                //core.Heap.Free();
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }
        }
开发者ID:samuto,项目名称:designscript,代码行数:32,代码来源:ProtoScriptRunner.cs


示例19: MarkGraphNodesDirty

        /// <summary>
        /// Finds all graphnodes associated with each AST and marks them dirty
        /// </summary>
        /// <param name="nodeList"></param>
        /// <summary>
        /// <returns></returns>
        public static void MarkGraphNodesDirty(ProtoCore.Core core, IEnumerable<ProtoCore.AST.AssociativeAST.AssociativeNode> nodeList)
        {
            if (nodeList == null)
                return;

            bool setEntryPoint = false;
            foreach (var node in nodeList)
            {
                var bNode = node as ProtoCore.AST.AssociativeAST.BinaryExpressionNode;
                if (bNode == null)
                {
                    continue;
                }

                foreach (var gnode in core.DSExecutable.instrStreamList[0].dependencyGraph.GraphList)
                {
                    if (gnode.isActive && gnode.OriginalAstID == bNode.OriginalAstID)
                    {
                        if (!setEntryPoint)
                        {
                            setEntryPoint = true;
                            core.SetNewEntryPoint(gnode.updateBlock.startpc);
                        }
                        gnode.isDirty = true;
                        gnode.isActive = true;
                    }
                }
            }
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:35,代码来源:AssociativeGraph.cs


示例20: Compile

        public bool Compile(string code, ProtoCore.Core core, out int blockId)
        {
            bool buildSucceeded = false;

            core.ExecMode = ProtoCore.DSASM.InterpreterMode.kNormal;

            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            try
            {
                // No More HashAngleReplace for unified parser (Fuqiang)
                //String strSource = ProtoCore.Utils.LexerUtils.HashAngleReplace(code);    

                //defining the global Assoc block that wraps the entire .ds source file
                ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock();
                globalBlock.language = ProtoCore.Language.kAssociative;
                globalBlock.body = code;
                //the wrapper block can be given a unique id to identify it as the global scope
                globalBlock.id = ProtoCore.LanguageCodeBlock.OUTERMOST_BLOCK_ID;


                //passing the global Assoc wrapper block to the compiler
                ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context();
                ProtoCore.Language id = globalBlock.language;
                core.Executives[id].Compile(out blockId, null, globalBlock, context, EventSink);

                core.BuildStatus.ReportBuildResult();
                buildSucceeded = core.BuildStatus.BuildSucceeded;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return buildSucceeded;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:35,代码来源:ProtoScriptTestRunner.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AssociativeAST.BinaryExpressionNode类代码示例发布时间:2022-05-24
下一篇:
C# Proto类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap