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


C# CompileTime.Context类代码示例

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


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

示例1: 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

示例2: Compile

        public ProtoLanguage.CompileStateTracker Compile(string code, out int blockId)
        {
            ProtoLanguage.CompileStateTracker compileState = ProtoScript.CompilerUtils.BuildDefaultCompilerState();

            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            try
            {
                System.IO.MemoryStream sourceMemStream = new System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(code));
                ProtoScript.GenerateScript gs = new ProtoScript.GenerateScript(compileState);

                compileState.Script = gs.preParseFromStream(sourceMemStream);

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

                    compileState.Executives[id].Compile(compileState, out blockId, null, codeblock, 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,代码行数:33,代码来源:ProtoScriptRunner.cs

示例3: 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

示例4: ExecuteAndVerify

 protected int ExecuteAndVerify(String code, ValidationData[] data, Dictionary<string, Object> context, out int nErrors)
 {
     ProtoCore.Core core = Setup();
     ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
     ProtoCore.CompileTime.Context compileContext = new ProtoCore.CompileTime.Context(code, context);
     ProtoCore.RuntimeCore runtimeCore = null;
     ExecutionMirror mirror = fsr.Execute(compileContext, core, out runtimeCore);
     int nWarnings = runtimeCore.RuntimeStatus.WarningCount;
     nErrors = core.BuildStatus.ErrorCount;
     if (data == null)
     {
         runtimeCore.Cleanup();
         return nWarnings + nErrors;
     }
     TestFrameWork thisTest = new TestFrameWork();
     foreach (var item in data)
     {
         if (item.ExpectedValue == null)
         {
             object nullOb = null;
             TestFrameWork.Verify(mirror, item.ValueName, nullOb, item.BlockIndex);
         }
         else
         {
             TestFrameWork.Verify(mirror, item.ValueName, item.ExpectedValue, item.BlockIndex);
         }
     }
     runtimeCore.Cleanup();
     return nWarnings + nErrors;
 }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:30,代码来源:CSFFITest.cs

示例5: 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

示例6: PreStart

        public void PreStart(String source, Dictionary<string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


            RunnerCore = new ProtoCore.Core(options);
            RunnerCore.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(RunnerCore));
            RunnerCore.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(RunnerCore));

            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            Runner = new ProtoScriptRunner();
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:16,代码来源:ProtoRunner.cs

示例7: Compile

        public bool Compile(string code, out int blockId)
        {
            bool buildSucceeded = false;
            blockId = ProtoCore.DSASM.Constants.kInvalidIndex;

            //compileState = ProtoScript.CompilerUtils.BuildDefaultCompilerState();

            try
            {
                //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;

                compileState.ExprInterpreterExe.iStreamCanvas = new InstructionStream(globalBlock.language, compileState);

                // Save the global offset and restore after compilation
                int offsetRestore = compileState.GlobOffset;
                compileState.GlobOffset = Core.Rmem.Stack.Count;

                compileState.Executives[id].Compile(compileState, out blockId, null, globalBlock, context, EventSink);

                // Restore the global offset
                compileState.GlobOffset = offsetRestore;

                compileState.BuildStatus.ReportBuildResult();

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

            return buildSucceeded;
        }
开发者ID:qingemeng,项目名称:designscript,代码行数:46,代码来源:ExpressionInterpreterRunner.cs

示例8: Compile

        public bool Compile(string code, int currentBlockID, out int blockId)
        {
            bool buildSucceeded = false;
            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;
                //globalBlock.language = ProtoCore.Language.kImperative;
                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();
                context.SetExprInterpreterProperties(currentBlockID, runtimeCore.RuntimeMemory, runtimeCore.watchClassScope, runtimeCore.DebugProps);
                ProtoCore.Language id = globalBlock.language;

                runtimeCore.ExprInterpreterExe.iStreamCanvas = new InstructionStream(globalBlock.language, Core);

                // Save the global offset and restore after compilation
                int offsetRestore = Core.GlobOffset;
                Core.GlobOffset = runtimeCore.RuntimeMemory.Stack.Count;

                Core.Compilers[id].Compile(out blockId, null, globalBlock, context, EventSink);

                // Restore the global offset
                Core.GlobOffset = offsetRestore;

                Core.BuildStatus.ReportBuildResult();

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

            return buildSucceeded;
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:42,代码来源:ExpressionInterpreterRunner.cs

示例9: PreStart

        public ProtoVMState PreStart(String source, Dictionary<string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


            RunnerCore = new ProtoCore.Core(options);
            RunnerCore.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(RunnerCore));
            RunnerCore.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(RunnerCore));

            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            //Validity.Assert(null == ExecutionContext);
            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            //Validity.Assert(null == Runner);
            Runner = new ProtoScriptRunner();

            // TODO Jun: Implement run and halt at the first instruction
            //ProtoCore.DSASM.Mirror.ExecutionMirror mirror = null; // runner.Execute(executionContext, RunnerCore);

            return new ProtoVMState(RunnerCore, runtimeCore);
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:23,代码来源:ProtoRunner.cs

示例10: Compile

        public ProtoLanguage.CompileStateTracker Compile(string code, ProtoCore.Core core, out int blockId)
        {
            ProtoLanguage.CompileStateTracker compileState = ProtoScript.CompilerUtils.BuildDefaultCompilerState();

            bool buildSucceeded = false;

            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;
                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;
                compileState.Executives[id].Compile(compileState, out blockId, null, globalBlock, context, EventSink);

                compileState.BuildStatus.ReportBuildResult();

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

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

示例11: ReInitializeLiveRunner

 /// <summary>
 /// Re-initializes the LiveRunner to reset the VM 
 /// Used temporarily when importing libraries on-demand during delta execution
 /// Will be deprecated once this is supported by the core language
 /// </summary>
 public void ReInitializeLiveRunner()
 {
     runner = new ProtoScriptRunner();
     deltaSymbols = 0;
     InitCore();
     staticContext = new ProtoCore.CompileTime.Context();
     changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
     CLRModuleType.ClearTypes();
 }
开发者ID:maajor,项目名称:Dynamo,代码行数:14,代码来源:LiveRunner.cs

示例12: EmitLanguageBlockNode

        private void EmitLanguageBlockNode(ImperativeNode node, ref ProtoCore.Type inferedType)
        {
            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 blockId = ProtoCore.DSASM.Constants.kInvalidIndex;

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

                if (langblock.codeblock.language == Language.kAssociative)
                {
                    AssociativeCodeGen codegen = new AssociativeCodeGen(compileState, codeBlock);
                    blockId = codegen.Emit(langblock.CodeBlockNode as ProtoCore.AST.AssociativeAST.CodeBlockNode);
                }
                else if (langblock.codeblock.language == Language.kImperative)
                {
                    ImperativeCodeGen codegen = new ImperativeCodeGen(compileState, codeBlock);
                    blockId = codegen.Emit(langblock.CodeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode);
                }

                //core.Executives[langblock.codeblock.language].Compile(out blockId, codeBlock, langblock.codeblock, context, codeBlock.EventSink, langblock.CodeBlockNode);
                inferedType = compileState.InferedType;

                ExceptionRegistration registration = compileState.ExceptionHandlingManager.ExceptionTable.GetExceptionRegistration(blockId, globalProcIndex, globalClassIndex);
                if (registration == null)
                {
                    registration = compileState.ExceptionHandlingManager.ExceptionTable.Register(blockId, globalProcIndex, globalClassIndex);
                    Debug.Assert(registration != null);
                }
            }
        }
开发者ID:samuto,项目名称:designscript,代码行数:43,代码来源:ImperativeCodeGen.cs

示例13: LiveRunner

        public LiveRunner(Configuration configuration)
        {
            this.configuration = configuration;

            runner = new ProtoScriptRunner();

            InitCore();

            taskQueue = new Queue<Task>();

            workerThread = new Thread(new ThreadStart(TaskExecMethod));
            workerThread.IsBackground = true;
            workerThread.Start();

            staticContext = new ProtoCore.CompileTime.Context();

            terminating = false;
            changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
            changeSetApplier = new ChangeSetApplier();
        }
开发者ID:maajor,项目名称:Dynamo,代码行数:20,代码来源:LiveRunner.cs

示例14: CodeGen

        public CodeGen(Core coreObj, ProtoCore.DSASM.CodeBlock parentBlock = null)
        {
            Validity.Assert(coreObj != null);
            core = coreObj;
            buildStatus = core.BuildStatus;
            isEntrySet = false;

            emitReplicationGuide = false;

            dumpByteCode = core.Options.DumpByteCode;
            isAssocOperator = false;

            pc = 0;
            argOffset = 0;
            globalClassIndex = core.ClassIndex;

            context = new ProtoCore.CompileTime.Context();

            targetLangBlock = ProtoCore.DSASM.Constants.kInvalidIndex;

            enforceTypeCheck = true;

            localProcedure = core.ProcNode;
            globalProcIndex = null != localProcedure ? localProcedure.ID : ProtoCore.DSASM.Constants.kGlobalScope;

            tryLevel = 0;

            functionCallStack = new List<DSASM.ProcedureNode>();

            IsAssociativeArrayIndexing = false;

            if (core.AsmOutput == null)
            {
                if (core.Options.CompileToLib)
                {
                    string path = "";
                    if (core.Options.LibPath == null)
                    {
                        path += core.Options.RootModulePathName + "ASM";
                    }
                    else
                    {
                        path = Path.Combine(core.Options.LibPath, Path.GetFileNameWithoutExtension(core.Options.RootModulePathName) + ".dsASM");
                    }

                    core.AsmOutput = new StreamWriter(File.Open(path, FileMode.Create));
                }
                else
                {
                    core.AsmOutput = Console.Out;
                }
            }

            ssaPointerStack = new Stack<List<AST.AssociativeAST.AssociativeNode>>();
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:55,代码来源:CodeGen.cs

示例15: 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


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