예제 #1
0
 public common_unit_node(SymbolTable.UnitInterfaceScope scope,
                         SymbolTable.UnitImplementationScope implementation_scope,
                         common_namespace_function_node main_function,
                         common_namespace_function_node finalization_method)
 {
     _scope = scope;
     _implementation_scope = implementation_scope;
     _main_function        = main_function;
     _finalization_method  = finalization_method;
 }
        public static common_unit_node make_system_unit(SymbolTable.TreeConverterSymbolTable symbol_table,
                                                        initialization_properties initialization_properties)
        {
            //TODO: В качестве location везде в этом методе следует указывать location system_unit-а. Имя файла мы знаем, а место - там где написано, что integer и прочие типы описаны как бы в модуле system.
            location system_unit_location = null;

            SymbolTable.UnitInterfaceScope      main_scope = symbol_table.CreateUnitInterfaceScope(new SymbolTable.Scope[0]);
            SymbolTable.UnitImplementationScope impl_scope = symbol_table.CreateUnitImplementationScope(main_scope,
                                                                                                        new SymbolTable.Scope[0]);
            common_unit_node _system_unit = new common_unit_node(main_scope, impl_scope, null, null);

            common_namespace_node cnn = new common_namespace_node(null, _system_unit, PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_name,
                                                                  symbol_table.CreateScope(main_scope), system_unit_location);

            main_scope.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_name, new PascalABCCompiler.TreeConverter.SymbolInfo(cnn));

            //SymbolTable.Scope sc = cnn.scope;
            SymbolTable.Scope sc = main_scope;

            //Добавляем типы.
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.byte_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.byte_type));
            //sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.decimal_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.decimal_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.sbyte_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.sbyte_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.short_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.short_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.ushort_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.ushort_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.integer_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.uint_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.uint_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.int64_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.ulong_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.uint64_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.float_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.float_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.double_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.char_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.char_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.bool_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.bool_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.string_type));
            //sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.object_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.object_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.pointer_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.pointer_type));
            //sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.base_exception_class_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.exception_base_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.base_array_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.array_base_type));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.base_delegate_type_name, new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.delegate_base_type));

            //TODO: Переделать. Пусть таблица символов создается одна. Как статическая.
            compiled_type_node comp_byte_type      = ((compiled_type_node)SystemLibrary.byte_type);
            compiled_type_node comp_sbyte_type     = ((compiled_type_node)SystemLibrary.sbyte_type);
            compiled_type_node comp_short_type     = ((compiled_type_node)SystemLibrary.short_type);
            compiled_type_node comp_ushort_type    = ((compiled_type_node)SystemLibrary.ushort_type);
            compiled_type_node comp_integer_type   = ((compiled_type_node)SystemLibrary.integer_type);
            compiled_type_node comp_uint_type      = ((compiled_type_node)SystemLibrary.uint_type);
            compiled_type_node comp_long_type      = ((compiled_type_node)SystemLibrary.int64_type);
            compiled_type_node comp_ulong_type     = ((compiled_type_node)SystemLibrary.uint64_type);
            compiled_type_node comp_float_type     = ((compiled_type_node)SystemLibrary.float_type);
            compiled_type_node comp_real_type      = ((compiled_type_node)SystemLibrary.double_type);
            compiled_type_node comp_char_type      = ((compiled_type_node)SystemLibrary.char_type);
            compiled_type_node comp_bool_type      = ((compiled_type_node)SystemLibrary.bool_type);
            compiled_type_node comp_string_type    = ((compiled_type_node)SystemLibrary.string_type);
            compiled_type_node comp_object_type    = ((compiled_type_node)SystemLibrary.object_type);
            compiled_type_node comp_pointer_type   = ((compiled_type_node)SystemLibrary.pointer_type);
            compiled_type_node comp_exception_type = ((compiled_type_node)SystemLibrary.exception_base_type);
            compiled_type_node comp_array_type     = ((compiled_type_node)SystemLibrary.array_base_type);
            compiled_type_node comp_delegate_type  = ((compiled_type_node)SystemLibrary.delegate_base_type);

            comp_byte_type.scope      = new PascalABCCompiler.NetHelper.NetTypeScope(comp_byte_type.compiled_type, symbol_table);
            comp_sbyte_type.scope     = new PascalABCCompiler.NetHelper.NetTypeScope(comp_sbyte_type.compiled_type, symbol_table);
            comp_short_type.scope     = new PascalABCCompiler.NetHelper.NetTypeScope(comp_short_type.compiled_type, symbol_table);
            comp_ushort_type.scope    = new PascalABCCompiler.NetHelper.NetTypeScope(comp_ushort_type.compiled_type, symbol_table);
            comp_integer_type.scope   = new PascalABCCompiler.NetHelper.NetTypeScope(comp_integer_type.compiled_type, symbol_table);
            comp_uint_type.scope      = new PascalABCCompiler.NetHelper.NetTypeScope(comp_uint_type.compiled_type, symbol_table);
            comp_long_type.scope      = new PascalABCCompiler.NetHelper.NetTypeScope(comp_long_type.compiled_type, symbol_table);
            comp_ulong_type.scope     = new PascalABCCompiler.NetHelper.NetTypeScope(comp_ulong_type.compiled_type, symbol_table);
            comp_real_type.scope      = new PascalABCCompiler.NetHelper.NetTypeScope(comp_real_type.compiled_type, symbol_table);
            comp_char_type.scope      = new PascalABCCompiler.NetHelper.NetTypeScope(comp_char_type.compiled_type, symbol_table);
            comp_bool_type.scope      = new PascalABCCompiler.NetHelper.NetTypeScope(comp_bool_type.compiled_type, symbol_table);
            comp_string_type.scope    = new PascalABCCompiler.NetHelper.NetTypeScope(comp_string_type.compiled_type, symbol_table);
            comp_object_type.scope    = new PascalABCCompiler.NetHelper.NetTypeScope(comp_object_type.compiled_type, symbol_table);
            comp_pointer_type.scope   = new PascalABCCompiler.NetHelper.NetTypeScope(comp_pointer_type.compiled_type, symbol_table);
            comp_exception_type.scope = new PascalABCCompiler.NetHelper.NetTypeScope(comp_exception_type.compiled_type, symbol_table);
            comp_array_type.scope     = new PascalABCCompiler.NetHelper.NetTypeScope(comp_array_type.compiled_type, symbol_table);
            comp_delegate_type.scope  = new PascalABCCompiler.NetHelper.NetTypeScope(comp_delegate_type.compiled_type, symbol_table);

            init_temp_methods_and_consts(cnn, sc, initialization_properties, system_unit_location);
            return(_system_unit);
        }
예제 #3
0
 public common_unit_node(SymbolTable.UnitInterfaceScope scope,
     SymbolTable.UnitImplementationScope implementation_scope,
     common_namespace_function_node main_function,
     common_namespace_function_node finalization_method)
 {
     _scope = scope;
     _implementation_scope = implementation_scope;
     _main_function = main_function;
     _finalization_method = finalization_method;
 }