Example #1
0
        public ClassNode(ClassNode rhs)
        {
            IsImportedClass = rhs.IsImportedClass;
            Name = rhs.Name;
            Size = rhs.Size;
            hasCachedDisposeMethod = rhs.hasCachedDisposeMethod;
            disposeMethod = rhs.disposeMethod;
            Rank = rhs.Rank;
            Symbols = new SymbolTable("classscope", 0);
            if (rhs.Symbols != null)
            {
                Symbols = new SymbolTable(rhs.Symbols.ScopeName, rhs.Symbols.RuntimeIndex);
            }
            DefaultArgExprList = new List<AST.AssociativeAST.AssociativeNode>();
            ID = rhs.ID;

            int classRuntimProc = ProtoCore.DSASM.Constants.kInvalidIndex;
            ProcTable = new ProcedureTable(classRuntimProc);
            if (rhs.ProcTable != null)
            {
                ProcTable = new ProcedureTable(rhs.ProcTable);
            }
            Bases = new List<int>(rhs.Bases);
            ExternLib = rhs.ExternLib;
            TypeSystem = rhs.TypeSystem;
            CoerceTypes = new Dictionary<int, int>(rhs.CoerceTypes);
        }
Example #2
0
        public ClassNode(ClassNode rhs)
        {
            IsImportedClass = rhs.IsImportedClass;
            name = rhs.name;
            size = rhs.size;
            hasCachedDisposeMethod = rhs.hasCachedDisposeMethod;
            disposeMethod = rhs.disposeMethod;
            rank = rhs.rank;
            symbols = new SymbolTable("classscope", 0);
            if (rhs.symbols != null)
            {
                symbols = new SymbolTable(rhs.symbols.ScopeName, rhs.symbols.RuntimeIndex);
            }
            defaultArgExprList = new List<AST.AssociativeAST.AssociativeNode>();
            classId = rhs.classId;

            int classRuntimProc = ProtoCore.DSASM.Constants.kInvalidIndex;
            vtable = new ProcedureTable(classRuntimProc);
            if (rhs.vtable != null)
            {
                vtable = new ProcedureTable(rhs.vtable);
            }
            baseList = new List<int>(rhs.baseList);
            ExternLib = rhs.ExternLib;
            typeSystem = rhs.typeSystem;
            coerceTypes = new Dictionary<int, int>(rhs.coerceTypes);
        }
Example #3
0
        public CodeBlock(CodeBlockType type, ProtoCore.Language langId, int codeBlockId, SymbolTable symbols, ProcedureTable procTable, bool isBreakableBlock = false, ProtoCore.Core core = null)
        {
            blockType = type;

            parent = null;
            children = new List<CodeBlock>();

            language = langId;
            this.codeBlockId = codeBlockId;
            instrStream = new InstructionStream(langId, core);

            symbolTable = symbols;
            procedureTable = procTable;

            isBreakable = isBreakableBlock;
        }
Example #4
0
        public ClassNode()
        {
            IsImportedClass = false;
            Name = null;
            Size = 0;
            hasCachedDisposeMethod = false;
            disposeMethod = null;
            Rank = ProtoCore.DSASM.Constants.kDefaultClassRank;
            Symbols = new SymbolTable("classscope", 0);
            ID = (int)PrimitiveType.InvalidType;

            // Jun TODO: how significant is runtime index for class procedures?
            int classRuntimProc = ProtoCore.DSASM.Constants.kInvalidIndex;
            ProcTable = new ProcedureTable(classRuntimProc);
            Base = Constants.kInvalidIndex;
            ExternLib = string.Empty;

            // Set default allowed coerce types
            CoerceTypes = new Dictionary<int, int>();
            CoerceTypes.Add((int)ProtoCore.PrimitiveType.Var, (int)ProtoCore.DSASM.ProcedureDistance.CoerceScore);
            CoerceTypes.Add((int)ProtoCore.PrimitiveType.Array, (int)ProtoCore.DSASM.ProcedureDistance.CoerceScore);
            CoerceTypes.Add((int)ProtoCore.PrimitiveType.Null, (int)ProtoCore.DSASM.ProcedureDistance.CoerceScore);
        }
Example #5
0
        public ClassNode()
        {
            IsImportedClass = false;
            name = null;
            size = 0;
            hasCachedDisposeMethod = false;
            disposeMethod = null;
            rank = ProtoCore.DSASM.Constants.kDefaultClassRank;
            symbols = new SymbolTable("classscope", 0);
            defaultArgExprList = new List<AST.AssociativeAST.BinaryExpressionNode>();
            classId = (int)PrimitiveType.kInvalidType;

            // Jun TODO: how significant is runtime index for class procedures?
            int classRuntimProc = ProtoCore.DSASM.Constants.kInvalidIndex;
            vtable = new ProcedureTable(classRuntimProc);
            baseList = new List<int>();
            ExternLib = string.Empty;

            // Set default allowed coerce types
            coerceTypes = new Dictionary<int, int>();
            coerceTypes.Add((int)ProtoCore.PrimitiveType.kTypeVar, (int)ProtoCore.DSASM.ProcedureDistance.kCoerceScore);
            coerceTypes.Add((int)ProtoCore.PrimitiveType.kTypeArray, (int)ProtoCore.DSASM.ProcedureDistance.kCoerceScore);
            coerceTypes.Add((int)ProtoCore.PrimitiveType.kTypeNull, (int)ProtoCore.DSASM.ProcedureDistance.kCoerceScore);
        }
Example #6
0
        private void BfsBuildSequenceTable(CodeBlock codeBlock, SymbolTable[] runtimeSymbols)
        {
            if (CodeBlockType.Language == codeBlock.blockType
                || CodeBlockType.Function == codeBlock.blockType
                || CodeBlockType.Construct == codeBlock.blockType)
            {
                Validity.Assert(codeBlock.symbolTable.RuntimeIndex < RuntimeTableIndex);
                runtimeSymbols[codeBlock.symbolTable.RuntimeIndex] = codeBlock.symbolTable;
            }

            foreach (CodeBlock child in codeBlock.children)
            {
                BfsBuildSequenceTable(child, runtimeSymbols);
            }
        }
Example #7
0
        private void BfsBuildSequenceTable(CodeBlock codeBlock, SymbolTable[] runtimeSymbols)
        {
            if (DSASM.CodeBlockType.kLanguage == codeBlock.blockType
                || DSASM.CodeBlockType.kFunction == codeBlock.blockType
                || DSASM.CodeBlockType.kConstruct == codeBlock.blockType)
            {
                Debug.Assert(codeBlock.symbolTable.runtimeIndex < RuntimeTableIndex);
                runtimeSymbols[codeBlock.symbolTable.runtimeIndex] = codeBlock.symbolTable;
            }

            foreach (DSASM.CodeBlock child in codeBlock.children)
            {
                BfsBuildSequenceTable(child, runtimeSymbols);
            }
        }
 public CodeBlockNode()
 {
     Body = new List<AssociativeNode>();
     symbols = new ProtoCore.DSASM.SymbolTable("AST generated", ProtoCore.DSASM.Constants.kInvalidIndex);
     procTable = new ProtoCore.DSASM.ProcedureTable(ProtoCore.DSASM.Constants.kInvalidIndex);
 }
Example #9
0
        /// <summary>
        /// A CodeBlock represents a body of DS code
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="type"></param>
        /// <param name="langId"></param>
        /// <param name="cbID"></param>
        /// <param name="symbols"></param>
        /// <param name="procTable"></param>
        /// <param name="isBreakableBlock"></param>
        /// <param name="core"></param>
        public CodeBlock(Guid guid, CodeBlockType type, ProtoCore.Language langId, int cbID, SymbolTable symbols, ProcedureTable procTable, bool isBreakableBlock = false, ProtoCore.Core core = null)
        {
            this.guid = guid;
            blockType = type;

            parent = null;
            children = new List<CodeBlock>();

            language = langId;
            instrStream = new InstructionStream(langId, core);

            symbolTable = symbols;
            procedureTable = procTable;

            isBreakable = isBreakableBlock;
            core.CompleteCodeBlockList.Add(this);
            this.codeBlockId = core.CompleteCodeBlockList.Count - 1;

            symbols.RuntimeIndex = this.codeBlockId;

            if (core.ProcNode != null)
            {
                core.ProcNode.ChildCodeBlocks.Add(codeBlockId);
            }
        }
Example #10
0
        public CodeBlock(CodeBlockType type, ProtoCore.Language langId, int codeBlockId, SymbolTable symbols, ProcedureTable procTable, bool isBreakableBlock = false, ProtoCore.Core core = null)
        {
            blockType = type;

            parent   = null;
            children = new List <CodeBlock>();

            language         = langId;
            this.codeBlockId = codeBlockId;
            instrStream      = new InstructionStream(langId, core);

            symbolTable    = symbols;
            procedureTable = procTable;

            isBreakable = isBreakableBlock;
        }
Example #11
0
        /// <summary>
        /// A CodeBlock represents a body of DS code
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="type"></param>
        /// <param name="langId"></param>
        /// <param name="cbID"></param>
        /// <param name="symbols"></param>
        /// <param name="procTable"></param>
        /// <param name="isBreakableBlock"></param>
        /// <param name="core"></param>
        public CodeBlock(Guid guid, CodeBlockType type, ProtoCore.Language langId, int cbID, SymbolTable symbols, ProcedureTable procTable, bool isBreakableBlock = false, ProtoCore.Core core = null)
        {
            this.guid = guid;
            blockType = type;

            parent   = null;
            children = new List <CodeBlock>();

            language    = langId;
            instrStream = new InstructionStream(langId, core);

            symbolTable    = symbols;
            procedureTable = procTable;

            isBreakable = isBreakableBlock;
            codeBlockId = core.GetRuntimeTableSize();
            core.CompleteCodeBlockDict.Add(codeBlockId, this);

            symbols.RuntimeIndex = codeBlockId;

            if (core.ProcNode != null)
            {
                core.ProcNode.ChildCodeBlocks.Add(codeBlockId);
            }
        }