예제 #1
0
        public static void New()
        {
            CompilationScope mainScope = new CompilationScope
            {
                instructions        = new Instructions {
                },
                lastInstruction     = new EmittedInstruction {
                },
                previousInstruction = new EmittedInstruction {
                },
            };

            symbol_table.SymbolTable symbolTable = symbol_table.NewSymbolTable();

            for (int i = 0; i < Object.builtins.Builtins.Length; i++)
            {
                Object._BuiltinDefinition v = Object.builtins.Builtins[i];
                symbol_table.DefineBuiltin(ref symbolTable, i, v.Name);
            }

            compiler = new Compiler_t
            {
                constants   = new List <Object.Object>(),
                symbolTable = symbolTable,
                scopes      = new List <CompilationScope> {
                    mainScope
                },
                scopeIndex = 0,
            };
        }
예제 #2
0
        public static Compiler_t NewWithState(ref symbol_table.SymbolTable s, List <Object.Object> constants)
        {
            Compiler_t compiler = New();

            compiler.symbolTable = s;
            compiler.constants   = constants;
            return(compiler);
        }
예제 #3
0
 public static void NewWithState(ref symbol_table.SymbolTable s, List <Object.Object> constants)
 {
     New();
     compiler.symbolTable = s;
     compiler.constants   = constants;
 }