Пример #1
0
        public CodeGen(Core coreObj, ProtoCore.CompileTime.Context callContext, ProtoCore.DSASM.CodeBlock parentBlock = null) : base(coreObj, parentBlock)
        {
            context = callContext;

            codeBlock = BuildNewCodeBlock();

            if (null == parentBlock)
            {
                // This is a top level block
                core.CodeBlockList.Add(codeBlock);
            }
            else
            {
                // This is a nested block
                parentBlock.children.Add(codeBlock);
                codeBlock.parent = parentBlock;
            }

            blockScope = 0;

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

            backpatchMap = new BackpatchMap();

            nodeBuilder = new NodeBuilder(core);
        }
Пример #2
0
        public CodeGen(ProtoLanguage.CompileStateTracker coreObj, ProtoCore.DSASM.CodeBlock parentBlock = null) : base(coreObj, 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,
                compileStateTracker.CodeBlockIndex, 
                new ProtoCore.DSASM.SymbolTable("imperative lang block", compileStateTracker.RuntimeTableIndex),
                new ProtoCore.DSASM.ProcedureTable(compileStateTracker.RuntimeTableIndex), 
                false, 
                compileStateTracker);

            ++compileStateTracker.CodeBlockIndex;
            ++compileStateTracker.RuntimeTableIndex;

            if (null == parentBlock)
            {
                // This is a top level block
                compileStateTracker.CodeBlockList.Add(codeBlock);
            }
            else
            {
                // This is a nested block
                parentBlock.children.Add(codeBlock);
                codeBlock.parent = parentBlock;
            }
            compileStateTracker.CompleteCodeBlockList.Add(codeBlock);
            blockScope = 0;

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

            backpatchMap = new BackpatchMap();

            nodeBuilder = new NodeBuilder(compileStateTracker);
        }
Пример #3
0
        public CodeGen(Core coreObj, ProtoCore.CompileTime.Context callContext, ProtoCore.DSASM.CodeBlock parentBlock = null) : base(coreObj, parentBlock)
        {
            context = callContext;
            //  dumpbytecode is optionally enabled
            //
            astNodes = new List<ImperativeNode>();

            // 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

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

            if (null == parentBlock)
            {
                // This is a top level block
                core.CodeBlockList.Add(codeBlock);
            }
            else
            {
                // This is a nested block
                parentBlock.children.Add(codeBlock);
                codeBlock.parent = parentBlock;
            }

            blockScope = 0;

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

            backpatchMap = new BackpatchMap();

            nodeBuilder = new NodeBuilder(core);
        }