Example #1
0
        // This constructor is only called for Preloading of assemblies and
        // precompilation of CodeBlockNode nodes in GraphUI for global language blocks - pratapa
        public CodeGen(ProtoLanguage.CompileStateTracker compileState)
            : base(compileState)
        {
            Validity.Assert(compileStateTracker.IsParsingPreloadedAssembly || compileStateTracker.IsParsingCodeBlockNode);

            classOffset = 0;

            //  either of these should set the console to flood
            //
            ignoreRankCheck = false;
            emitReplicationGuide = false;

            astNodes = new List<AssociativeNode>();
            globalInstanceProcList = new List<GlobalInstanceProc>();
            setConstructorStartPC = false;

            // Re-use the existing procedureTable and symbolTable to access the built-in and predefined functions
            ProcedureTable procTable = compileStateTracker.CodeBlockList[0].procedureTable;
            codeBlock = BuildNewCodeBlock(procTable);

            // Remove global symbols from existing symbol table for subsequent run in Graph UI
            //SymbolTable sTable = core.CodeBlockList[0].symbolTable;
            //sTable.RemoveGlobalSymbols();
            //codeBlock = core.CodeBlockList[0];

            compilePass = ProtoCore.DSASM.AssociativeCompilePass.kClassName;

            // Bouncing to this language codeblock from a function should immediately set the first instruction as the entry point
            if (ProtoCore.DSASM.Constants.kGlobalScope != globalProcIndex)
            {
                isEntrySet = true;
                codeBlock.instrStream.entrypoint = 0;
            }

            nodeBuilder = new NodeBuilder(compileStateTracker);
            unPopulatedClasses = new Dictionary<int, ClassDeclNode>();
        }
Example #2
0
        public CodeGen(ProtoLanguage.CompileStateTracker compileState, ProtoCore.DSASM.CodeBlock parentBlock = null)
            : base(compileState, parentBlock)
        {
            classOffset = 0;

            //  either of these should set the console to flood
            //
            ignoreRankCheck = false;
            emitReplicationGuide = false;

            astNodes = new List<AssociativeNode>();
            globalInstanceProcList = new List<GlobalInstanceProc>();
            setConstructorStartPC = false;

            // Comment Jun: Get the codeblock to use for this codegenerator
            if (compileStateTracker.Options.IsDeltaExecution)
            {
                codeBlock = GetDeltaCompileCodeBlock();
                pc = compileStateTracker.deltaCompileStartPC;
            }
            else
            {
                codeBlock = BuildNewCodeBlock();
            }

            if (null == parentBlock)
            {
                if (!compileStateTracker.Options.IsDeltaExecution)
                {
                    // This is a top level block
                    compileStateTracker.CodeBlockList.Add(codeBlock);
                }
            }
            else
            {
                // TODO Jun: Handle nested codeblock here when we support scoping in the graph

                // This is a nested block

                // parentBlock == codeBlock happens when the core is in
                // delta exectuion and at the same time we create a dynamic
                // code block (e.g., inline condition)
                if  (parentBlock == codeBlock)
                {
                    codeBlock = BuildNewCodeBlock();
                    pc = 0;
                }
                parentBlock.children.Add(codeBlock);
                codeBlock.parent = parentBlock;
            }

            compileStateTracker.CompleteCodeBlockList.Add(codeBlock);
            compilePass = ProtoCore.DSASM.AssociativeCompilePass.kClassName;

            // Bouncing to this language codeblock from a function should immediately set the first instruction as the entry point
            if (ProtoCore.DSASM.Constants.kGlobalScope != globalProcIndex)
            {
                isEntrySet = true;
                codeBlock.instrStream.entrypoint = 0;
            }

            nodeBuilder = new NodeBuilder(compileStateTracker);
            unPopulatedClasses = new Dictionary<int, ClassDeclNode>();

            // For sub code block, say in inline condition, do we need context?
            /*
            if (core.assocCodegen != null)
            {
                context = core.assocCodegen.context;
            }
            */
        }