public SymbolInfo(compiled_type_node value) { //_name_information_type=name_information_type.nit_compiled_type; _sym_info = value; _access_level = access_level.al_public; _symbol_kind = symbol_kind.sk_none; }
//End: No v drugom smisle reference. public void make_empty_operator(string name, compiled_type_node ctn) { parameterArrayList pars = new parameterArrayList(); empty_function_node efn = new empty_function_node(pars, ctn); efn.is_overload = true; basic_parameter par = new basic_parameter(compiler_string_consts.unary_param_name, ctn, SemanticTree.parameter_type.value, null); pars.Add(par); ctn.add_additional_name(name, new SymbolInfo(efn)); }
private void make_unary_operator(string operator_name, compiled_type_node to, SemanticTree.basic_function_type bft, type_node ret_value_type) { parameterArrayList pars = new parameterArrayList(); basic_function_node bfn = new basic_function_node(bft, pars, ret_value_type); bfn.is_overload = true; basic_parameter par = new basic_parameter(compiler_string_consts.unary_param_name, to, SemanticTree.parameter_type.value, bfn); pars.Add(par); to.add_additional_name(operator_name, new SymbolInfo(bfn)); }
private basic_function_node make_binary_operator(string operator_name, compiled_type_node to, SemanticTree.basic_function_type bft, type_node ret_value_type) { /*parameterArrayList pars=new parameterArrayList(); * basic_function_node bfn=new basic_function_node(bft,pars,ret_value_type); * basic_parameter par_left=new basic_parameter(compiler_string_consts.left_param_name,to, * SemanticTree.parameter_type.value,bfn); * basic_parameter par_right=new basic_parameter(compiler_string_consts.right_param_name,to, * SemanticTree.parameter_type.value,bfn); * pars.Add(par_left); * pars.Add(par_right); * to.add_additional_name(operator_name,new SymbolInfo(bfn));*/ return(make_common_binary_operation(operator_name, to, to, to, bft, ret_value_type)); }
private void make_type_conversion(compiled_type_node from, compiled_type_node to, type_compare tc, SemanticTree.basic_function_type bft) { parameterArrayList pars = new parameterArrayList(); basic_function_node conv_method = new basic_function_node(bft, pars, to); basic_parameter bp = new basic_parameter(compiler_string_consts.unary_param_name, from, SemanticTree.parameter_type.value, conv_method); pars.Add(bp); type_intersection_node inter_node = new type_intersection_node(tc); inter_node.this_to_another = new type_conversion_factory(conv_method); from.add_intersection_node(to, inter_node); }
private void make_compiled_object_operator(string name, compiled_type_node tp, SemanticTree.basic_function_type bft, SemanticTree.parameter_type first_param_type) { parameterArrayList pars = new parameterArrayList(); basic_function_node bfn = new basic_function_node(bft, pars, tp); bfn.is_overload = true; basic_parameter to = new basic_parameter(compiler_string_consts.left_param_name, tp, first_param_type, bfn); basic_parameter from = new basic_parameter(compiler_string_consts.right_param_name, tp, SemanticTree.parameter_type.value, bfn); pars.Add(to); pars.Add(from); tp.add_additional_name(name, new SymbolInfo(bfn)); }
private basic_function_node make_common_binary_operation(string operator_name, compiled_type_node def_type, compiled_type_node left, compiled_type_node right, SemanticTree.basic_function_type bft, type_node ret_value_type) { parameterArrayList pars = new parameterArrayList(); basic_function_node bfn = new basic_function_node(bft, pars, ret_value_type); bfn.is_overload = true; basic_parameter par_left = new basic_parameter(compiler_string_consts.left_param_name, left, SemanticTree.parameter_type.value, bfn); basic_parameter par_right = new basic_parameter(compiler_string_consts.right_param_name, right, SemanticTree.parameter_type.value, bfn); pars.Add(par_left); pars.Add(par_right); def_type.add_additional_name(operator_name, new SymbolInfo(bfn)); return(bfn); }
/*public override base_scope top_scope * { * get * { * return _up_scope; * } * }*/ public override SymbolInfo Find(string name) { SymbolInfo si = null; if (NetHelper.IsNetNamespace(name.ToLower()) == true) { compiled_namespace_node cnn = new compiled_namespace_node(name); si = new SymbolInfo(cnn); } else { //Type t = Type.GetType("System."+name,false,true); Type t = null; int i = 0; t = NetHelper.FindType(name); if (t != null) { compiled_type_node ctn = compiled_type_node.get_type_node(t); ctn.Scope = new NetTypeScope(ctn.compiled_type); si = new SymbolInfo(ctn); } else { while ((t == null) && (i < _unar.Count)) { t = _assembly.GetType(_unar[i].namespace_name + "." + name, false, true); i++; } if (t != null) { compiled_type_node ctn = compiled_type_node.get_type_node(t); ctn.Scope = new NetTypeScope(ctn.compiled_type); si = new SymbolInfo(ctn); NetHelper.AddType(name, t); } } } return(si); }
private void make_unary_operator(string operator_name, compiled_type_node to, SemanticTree.basic_function_type bft) { make_unary_operator(operator_name, to, bft, to); }
private void make_unary_operator(string operator_name,compiled_type_node to, SemanticTree.basic_function_type bft,type_node ret_value_type) { parameterArrayList pars=new parameterArrayList(); basic_function_node bfn=new basic_function_node(bft,pars,ret_value_type); bfn.is_overload=true; basic_parameter par=new basic_parameter(compiler_string_consts.unary_param_name,to, SemanticTree.parameter_type.value,bfn); pars.Add(par); to.add_additional_name(operator_name,new SymbolInfo(bfn)); }
public void init_reference_type(compiled_type_node ctn) { make_reference_object_assign_operator(ctn); make_reference_object_eq_operator(ctn); make_reference_object_noteq_operator(ctn); }
private void initialize_types() { _integer_type=compiled_type_node.get_type_node(typeof(int)); _bool_type=compiled_type_node.get_type_node(typeof(bool)); _real_type=compiled_type_node.get_type_node(typeof(double)); _char_type=compiled_type_node.get_type_node(typeof(char)); _string_type=compiled_type_node.get_type_node(typeof(string)); _pointer_type=compiled_type_node.get_type_node(Type.GetType("System.Void*")); NetInitialize(); //Преобразования типов. make_type_conversion(_integer_type,_real_type,type_compare.less_type,SemanticTree.basic_function_type.itod); //Операции для типа integer. //Присваивание для integer. make_assign_operator(_integer_type,SemanticTree.basic_function_type.iassign); //Унарные операции. make_unary_operator(compiler_string_consts.minus_name,_integer_type,SemanticTree.basic_function_type.iunmin); make_unary_operator(compiler_string_consts.not_name,_integer_type,SemanticTree.basic_function_type.inot); make_empty_operator(compiler_string_consts.plus_name,_integer_type); //Арифметические операции. _int_add=make_binary_operator(compiler_string_consts.plus_name,_integer_type,SemanticTree.basic_function_type.iadd); _int_sub=make_binary_operator(compiler_string_consts.minus_name,_integer_type,SemanticTree.basic_function_type.isub); make_binary_operator(compiler_string_consts.mul_name,_integer_type,SemanticTree.basic_function_type.imul); make_binary_operator(compiler_string_consts.idiv_name,_integer_type,SemanticTree.basic_function_type.idiv); make_binary_operator(compiler_string_consts.mod_name,_integer_type,SemanticTree.basic_function_type.imod); //Операция / для integer. make_common_binary_operation(compiler_string_consts.div_name,_integer_type,_real_type,_real_type, SemanticTree.basic_function_type.ddiv,_real_type); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name,_integer_type,SemanticTree.basic_function_type.igr,_bool_type); make_binary_operator(compiler_string_consts.greq_name,_integer_type,SemanticTree.basic_function_type.igreq,_bool_type); make_binary_operator(compiler_string_consts.sm_name,_integer_type,SemanticTree.basic_function_type.ism,_bool_type); make_binary_operator(compiler_string_consts.smeq_name,_integer_type,SemanticTree.basic_function_type.ismeq,_bool_type); make_binary_operator(compiler_string_consts.eq_name,_integer_type,SemanticTree.basic_function_type.ieq,_bool_type); make_binary_operator(compiler_string_consts.noteq_name,_integer_type,SemanticTree.basic_function_type.inoteq,_bool_type); //Логические опреции. make_binary_operator(compiler_string_consts.and_name,_integer_type,SemanticTree.basic_function_type.iand); make_binary_operator(compiler_string_consts.or_name,_integer_type,SemanticTree.basic_function_type.ior); make_binary_operator(compiler_string_consts.xor_name,_integer_type,SemanticTree.basic_function_type.ixor); make_binary_operator(compiler_string_consts.shl_name,_integer_type,SemanticTree.basic_function_type.ishl); make_binary_operator(compiler_string_consts.shr_name,_integer_type,SemanticTree.basic_function_type.ishr); //real type. //Assign. make_assign_operator(_real_type,SemanticTree.basic_function_type.dassign); //Унарные операции. make_unary_operator(compiler_string_consts.minus_name,_real_type,SemanticTree.basic_function_type.dunmin); make_empty_operator(compiler_string_consts.plus_name,_real_type); //Арифметические операции. make_binary_operator(compiler_string_consts.plus_name,_real_type,SemanticTree.basic_function_type.dadd); make_binary_operator(compiler_string_consts.minus_name,_real_type,SemanticTree.basic_function_type.dsub); make_binary_operator(compiler_string_consts.mul_name,_real_type,SemanticTree.basic_function_type.dmul); make_binary_operator(compiler_string_consts.div_name,_real_type,SemanticTree.basic_function_type.ddiv); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name,_real_type,SemanticTree.basic_function_type.dgr,_bool_type); make_binary_operator(compiler_string_consts.greq_name,_real_type,SemanticTree.basic_function_type.dgreq,_bool_type); make_binary_operator(compiler_string_consts.sm_name,_real_type,SemanticTree.basic_function_type.dsm,_bool_type); make_binary_operator(compiler_string_consts.smeq_name,_real_type,SemanticTree.basic_function_type.dsmeq,_bool_type); make_binary_operator(compiler_string_consts.eq_name,_real_type,SemanticTree.basic_function_type.deq,_bool_type); make_binary_operator(compiler_string_consts.noteq_name,_real_type,SemanticTree.basic_function_type.dnoteq,_bool_type); //char type. //Assign. make_assign_operator(_char_type,SemanticTree.basic_function_type.charassign); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name,_char_type,SemanticTree.basic_function_type.chargr,_bool_type); make_binary_operator(compiler_string_consts.greq_name,_char_type,SemanticTree.basic_function_type.chargreq,_bool_type); make_binary_operator(compiler_string_consts.sm_name,_char_type,SemanticTree.basic_function_type.charsm,_bool_type); make_binary_operator(compiler_string_consts.smeq_name,_char_type,SemanticTree.basic_function_type.charsmeq,_bool_type); make_binary_operator(compiler_string_consts.eq_name,_char_type,SemanticTree.basic_function_type.chareq,_bool_type); make_binary_operator(compiler_string_consts.noteq_name,_char_type,SemanticTree.basic_function_type.charnoteq,_bool_type); //boolean type. //Assign. make_assign_operator(_bool_type,SemanticTree.basic_function_type.boolassign); //Логические операции. //Унарные операции. make_unary_operator(compiler_string_consts.not_name,_bool_type,SemanticTree.basic_function_type.bnot); //Логическме операции. make_binary_operator(compiler_string_consts.and_name,_bool_type,SemanticTree.basic_function_type.band); make_binary_operator(compiler_string_consts.or_name,_bool_type,SemanticTree.basic_function_type.bor); make_binary_operator(compiler_string_consts.xor_name,_bool_type,SemanticTree.basic_function_type.bxor); make_unary_operator(compiler_string_consts.not_name,_bool_type,SemanticTree.basic_function_type.boolnot); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name,_bool_type,SemanticTree.basic_function_type.boolgr); make_binary_operator(compiler_string_consts.greq_name,_bool_type,SemanticTree.basic_function_type.boolgreq); make_binary_operator(compiler_string_consts.sm_name,_bool_type,SemanticTree.basic_function_type.boolsm); make_binary_operator(compiler_string_consts.smeq_name,_bool_type,SemanticTree.basic_function_type.boolsmeq); make_binary_operator(compiler_string_consts.eq_name,_bool_type,SemanticTree.basic_function_type.booleq); make_binary_operator(compiler_string_consts.noteq_name,_bool_type,SemanticTree.basic_function_type.boolnoteq); mark_int_as_ordinal(); mark_char_as_ordinal(); }
private void make_compiled_object_operator(string name,compiled_type_node tp,SemanticTree.basic_function_type bft, SemanticTree.parameter_type first_param_type) { parameterArrayList pars=new parameterArrayList(); basic_function_node bfn=new basic_function_node(bft,pars,tp); bfn.is_overload=true; basic_parameter to=new basic_parameter(compiler_string_consts.left_param_name,tp, first_param_type,bfn); basic_parameter from=new basic_parameter(compiler_string_consts.right_param_name,tp, SemanticTree.parameter_type.value,bfn); pars.Add(to); pars.Add(from); tp.add_additional_name(name,new SymbolInfo(bfn)); }
private void make_reference_object_assign_operator(compiled_type_node tp) { make_compiled_object_operator(compiler_string_consts.assign_name,tp, SemanticTree.basic_function_type.objassign,SemanticTree.parameter_type.var); }
private void make_reference_object_noteq_operator(compiled_type_node tp) { make_compiled_object_operator(compiler_string_consts.noteq_name, tp, SemanticTree.basic_function_type.objnoteq); }
private void make_type_conversion(compiled_type_node from,compiled_type_node to,type_compare tc, SemanticTree.basic_function_type bft) { parameterArrayList pars=new parameterArrayList(); basic_function_node conv_method=new basic_function_node(bft,pars,to); basic_parameter bp=new basic_parameter(compiler_string_consts.unary_param_name, from,SemanticTree.parameter_type.value,conv_method); pars.Add(bp); type_intersection_node inter_node=new type_intersection_node(tc); inter_node.this_to_another=new type_conversion_factory(conv_method); from.add_intersection_node(to,inter_node); }
private void make_compiled_object_operator(string name, compiled_type_node tp, SemanticTree.basic_function_type bft) { make_compiled_object_operator(name, tp, bft, SemanticTree.parameter_type.value); }
private void make_reference_object_assign_operator(compiled_type_node tp) { make_compiled_object_operator(compiler_string_consts.assign_name, tp, SemanticTree.basic_function_type.objassign, SemanticTree.parameter_type.var); }
//TODO: Сделать поля одиночками. public compiled_variable_definition(System.Reflection.FieldInfo fi) : base(fi.Name, compiled_type_node.get_type_node(fi.FieldType)) { _fi = fi; _cont_type = compiled_type_node.get_type_node(fi.DeclaringType); }
private void make_assign_operator(compiled_type_node ctn, SemanticTree.basic_function_type bft) { make_compiled_object_operator(compiler_string_consts.assign_name, ctn, bft, SemanticTree.parameter_type.var); }
public compiled_static_method_call(compiled_function_node static_method, location loc) : base(static_method, loc) { _compiled_type = static_method.cont_type; }
private basic_function_node make_binary_operator(string operator_name,compiled_type_node to,SemanticTree.basic_function_type bft) { return make_binary_operator(operator_name,to,bft,to); }
private basic_function_node make_binary_operator(string operator_name,compiled_type_node to, SemanticTree.basic_function_type bft,type_node ret_value_type) { /*parameterArrayList pars=new parameterArrayList(); basic_function_node bfn=new basic_function_node(bft,pars,ret_value_type); basic_parameter par_left=new basic_parameter(compiler_string_consts.left_param_name,to, SemanticTree.parameter_type.value,bfn); basic_parameter par_right=new basic_parameter(compiler_string_consts.right_param_name,to, SemanticTree.parameter_type.value,bfn); pars.Add(par_left); pars.Add(par_right); to.add_additional_name(operator_name,new SymbolInfo(bfn));*/ return make_common_binary_operation(operator_name,to,to,to,bft,ret_value_type); }
/// <summary> /// Конструктор класса. /// </summary> public compiled_class_constant_definition(System.Reflection.FieldInfo fi, constant_node cn) : base(fi.Name, cn, null) { _comprehensive_type = compiled_type_node.get_type_node(fi.DeclaringType); _fi = fi; }
private void make_assign_operator(compiled_type_node ctn,SemanticTree.basic_function_type bft) { make_compiled_object_operator(compiler_string_consts.assign_name,ctn,bft,SemanticTree.parameter_type.var); }
public static_compiled_variable_reference(compiled_variable_definition var, location loc) : base(var.type, loc) { _var = var; _type = _var.cont_type; }
private void make_compiled_object_operator(string name,compiled_type_node tp,SemanticTree.basic_function_type bft) { make_compiled_object_operator(name,tp,bft,SemanticTree.parameter_type.value); }
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); }
private void make_reference_object_noteq_operator(compiled_type_node tp) { make_compiled_object_operator(compiler_string_consts.noteq_name,tp,SemanticTree.basic_function_type.objnoteq); }
private basic_function_node make_common_binary_operation(string operator_name,compiled_type_node def_type,compiled_type_node left, compiled_type_node right,SemanticTree.basic_function_type bft,type_node ret_value_type) { parameterArrayList pars=new parameterArrayList(); basic_function_node bfn=new basic_function_node(bft,pars,ret_value_type); bfn.is_overload=true; basic_parameter par_left=new basic_parameter(compiler_string_consts.left_param_name,left, SemanticTree.parameter_type.value,bfn); basic_parameter par_right=new basic_parameter(compiler_string_consts.right_param_name,right, SemanticTree.parameter_type.value,bfn); pars.Add(par_left); pars.Add(par_right); def_type.add_additional_name(operator_name,new SymbolInfo(bfn)); return bfn; }
//End: No v drugom smisle reference. public void make_empty_operator(string name,compiled_type_node ctn) { parameterArrayList pars=new parameterArrayList(); empty_function_node efn=new empty_function_node(pars,ctn); efn.is_overload=true; basic_parameter par=new basic_parameter(compiler_string_consts.unary_param_name,ctn, SemanticTree.parameter_type.value,null); pars.Add(par); ctn.add_additional_name(name,new SymbolInfo(efn)); }
private void make_unary_operator(string operator_name,compiled_type_node to,SemanticTree.basic_function_type bft) { make_unary_operator(operator_name,to,bft,to); }
/// <summary> /// Вывод типа параметров лямбд и типа возвращаемого значения при присваивании лямбды переменной /// </summary> public static void InferTypesFromVarStmt(type_node leftType, function_lambda_definition lambdaDef, syntax_tree_visitor visitor, Operators op = Operators.Undefined) { if (lambdaDef == null) { return; } if (leftType != null) { delegate_internal_interface dii_left = (delegate_internal_interface)leftType.get_internal_interface(internal_interface_kind.delegate_interface); if (dii_left == null) { if (leftType != SystemLibrary.SystemLibrary.system_delegate_type) { if (op != Operators.Undefined) { var sil = leftType.find_in_type(name_reflector.get_name(op)); if (sil != null && sil.Count > 0) { foreach (SymbolInfo si in sil) { if (si.sym_info is function_node) { function_node fn = si.sym_info as function_node; if (fn.parameters.Count == 2) { dii_left = (delegate_internal_interface)fn.parameters[1].type.get_internal_interface(internal_interface_kind.delegate_interface); if (dii_left != null) { break; } if (fn.parameters[1].type.is_generic_parameter) { compiled_type_node ctn = leftType as compiled_type_node; common_type_node ctn2 = leftType as common_type_node; if (ctn != null && ctn.is_generic_type_instance && fn.parameters[0].type.is_generic_type_instance && ctn.original_generic == fn.parameters[0].type.original_generic) { dii_left = (delegate_internal_interface)ctn.generic_params[0].get_internal_interface(internal_interface_kind.delegate_interface); if (dii_left != null) { break; } } if (ctn2 != null && ctn2.is_generic_type_instance && ctn2.instance_params.Count > 0 && fn.parameters[0].type.is_generic_type_instance && ctn2.original_generic == fn.parameters[0].type.original_generic) { dii_left = (delegate_internal_interface)ctn2.instance_params[0].get_internal_interface(internal_interface_kind.delegate_interface); if (dii_left != null) { break; } } } } } } } } if (dii_left == null) { visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_VARIABLE_TYPE"); } } else { return; } } int leftTypeParamsNumber = dii_left.parameters.Count; int lambdaDefParamsCount = 0; if (lambdaDef.formal_parameters != null && lambdaDef.formal_parameters.params_list.Count != 0) { for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++) { lambdaDefParamsCount += lambdaDef.formal_parameters.params_list[i].idents.idents.Count; } if (lambdaDefParamsCount != leftTypeParamsNumber) { visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_PARAMETERS_NUMBER"); } bool flag = true; SyntaxTree.formal_parameters lambdaDefParamsTypes = new formal_parameters(); for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++) { for (int j = 0; j < lambdaDef.formal_parameters.params_list[i].idents.idents.Count; j++) { var param = new SyntaxTree.typed_parameters(); param.idents = new ident_list(); param.idents.Add(lambdaDef.formal_parameters.params_list[i].idents.idents[j]); param.vars_type = lambdaDef.formal_parameters.params_list[i].vars_type; param.source_context = lambdaDef.formal_parameters.source_context; lambdaDefParamsTypes.Add(param); } } for (int i = 0; i < leftTypeParamsNumber && flag; i++) { if (lambdaDefParamsTypes.params_list[i].vars_type is SyntaxTree.lambda_inferred_type) { if ((lambdaDefParamsTypes.params_list[i].vars_type as SyntaxTree.lambda_inferred_type).real_type is lambda_any_type_node) { var curLeftParType = dii_left.parameters[i].type; lambdaDefParamsTypes.params_list[i].vars_type = new SyntaxTree.lambda_inferred_type(); (lambdaDefParamsTypes.params_list[i].vars_type as SyntaxTree.lambda_inferred_type).real_type = curLeftParType; continue; } } var lambdaPar = visitor.convert_strong(lambdaDefParamsTypes.params_list[i].vars_type); if (!convertion_data_and_alghoritms.eq_type_nodes(dii_left.parameters[i].type, lambdaPar)) { visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_VARIABLE_TYPE"); } } lambdaDef.formal_parameters = lambdaDefParamsTypes; } if (lambdaDef.return_type != null && lambdaDef.return_type is lambda_inferred_type) { if (dii_left.return_value_type != null) { (lambdaDef.return_type as lambda_inferred_type).real_type = dii_left.return_value_type; } else // SSM 23/07/16 - попытка бороться с var p: Shape->() := a->a.Print() { // lambdaDef.usedkeyword == 1 // function var b = lambdaDef.usedkeyword == 0 && TryConvertFuncLambdaBodyWithMethodCallToProcLambdaBody(lambdaDef); // пытаться конвертировать только если мы явно не указали, что это функция if (!b) { visitor.AddError(visitor.get_location(lambdaDef), "UNABLE_TO_CONVERT_FUNCTIONAL_TYPE_TO_PROCEDURAL_TYPE"); } } } } else { if (lambdaDef.formal_parameters != null) { for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++) { if (lambdaDef.formal_parameters.params_list[i].vars_type is lambda_inferred_type) { visitor.AddError(visitor.get_location(lambdaDef), "IMPOSSIBLE_TO_INFER_TYPES_IN_LAMBDA"); } } } } }
private basic_function_node make_binary_operator(string operator_name, compiled_type_node to, SemanticTree.basic_function_type bft) { return(make_binary_operator(operator_name, to, bft, to)); }
public void create_main_function(string[] used_stand_modules, Dictionary <string, object> config) { add_needed_cctors(); common_namespace_function_node temp = _main_function; _main_function = new common_namespace_function_node("Main", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null); location loc = temp.loc; statements_list sl = new statements_list(loc); _main_function.function_code = sl; // if (units[0].MainArgsParameter!=null) // { // _main_function.parameters.AddElement(units[0].MainArgsParameter); // sl.statements.AddElement(units[0].MainArgsAssignExpr); // } // if (units[0].IsConsoleApplicationVariableAssignExpr!=null) // { // sl.statements.AddElement(units[0].IsConsoleApplicationVariableAssignExpr); // } statements_list sl2 = sl; sl = new statements_list(null); common_namespace_function_node init_func = new common_namespace_function_node("$_Init_", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null); ((common_namespace_node)_main_function.comprehensive_namespace).functions.AddElement(init_func); namespace_variable init_var = new namespace_variable("$is_init", SystemLibrary.SystemLibrary.bool_type, (common_namespace_node)_main_function.comprehensive_namespace, null); ((common_namespace_node)_main_function.comprehensive_namespace).variables.AddElement(init_var); if (SystemLibrary.SystemLibInitializer.ConfigVariable != null && SystemLibrary.SystemLibInitializer.ConfigVariable.Found) { namespace_variable conf_nv = null; compiled_variable_definition conf_cf = null; if (SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info is namespace_variable) { conf_nv = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as namespace_variable; } else { conf_cf = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as compiled_variable_definition; } foreach (string config_var in config.Keys) { var config_value = config[config_var]; compiled_function_call cfc = new compiled_function_call(compiled_function_node.get_compiled_method(NetHelper.NetHelper.AddToDictionaryMethod), (conf_nv != null) ? (expression_node) new namespace_variable_reference(conf_nv, null) : (expression_node) new static_compiled_variable_reference(conf_cf, null), null); cfc.parameters.AddElement(new string_const_node(config_var, null)); switch (Type.GetTypeCode(config_value.GetType())) { case TypeCode.String: cfc.parameters.AddElement(new string_const_node((string)config_value, null)); break; case TypeCode.Int32: cfc.parameters.AddElement(new int_const_node((int)config_value, null)); break; case TypeCode.Boolean: cfc.parameters.AddElement(new bool_const_node((bool)config_value, null)); break; case TypeCode.Double: cfc.parameters.AddElement(new double_const_node((double)config_value, null)); break; default: throw new NotSupportedException("Config value type is nort supported"); } sl.statements.AddElement(cfc); } } if (units[0].MainArgsParameter != null) { _main_function.parameters.AddElement(units[0].MainArgsParameter); sl.statements.AddElementFirst(units[0].MainArgsAssignExpr); } if (units[0].IsConsoleApplicationVariableAssignExpr != null) { sl.statements.AddElementFirst(units[0].IsConsoleApplicationVariableAssignExpr); } for (int i = 0; i < units.Count; i++) { if (units[i].main_function != null) { if (units[i].main_function.name != TreeConverter.compiler_string_consts.temp_main_function_name) { common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc); sl.statements.AddElement(cnfc); } else { common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc); sl2.statements.AddElement(cnfc); } } } //if (units.Count == 1) for (int i = 0; i < used_stand_modules.Length; i++) { Type t = NetHelper.NetHelper.FindRtlType(used_stand_modules[i] + "." + used_stand_modules[i]); if (t == null) { continue; } compiled_type_node ctn = compiled_type_node.get_type_node(t); System.Reflection.MethodInfo mi = ctn.compiled_type.GetMethod("__InitModule__"); if (mi == null) { continue; } compiled_static_method_call csmc = new compiled_static_method_call(compiled_function_node.get_compiled_method(mi), null); sl.statements.AddElement(csmc); } for (int i = units.Count - 1; i >= 0; i--) { if (units[i].finalization_method != null) { common_namespace_function_call cnfc = new common_namespace_function_call(units[i].finalization_method, loc); sl2.statements.AddElement(cnfc); } } //if (units.Count == 1) for (int i = 0; i < used_stand_modules.Length; i++) { Type t = NetHelper.NetHelper.FindRtlType(used_stand_modules[i] + "." + used_stand_modules[i]); if (t == null) { continue; } compiled_type_node ctn = compiled_type_node.get_type_node(t); System.Reflection.MethodInfo mi = ctn.compiled_type.GetMethod("__FinalizeModule__"); if (mi == null) { continue; } compiled_static_method_call csmc = new compiled_static_method_call(compiled_function_node.get_compiled_method(mi), null); sl2.statements.AddElement(csmc); } sl2 = new statements_list(loc); basic_function_call bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_assign as basic_function_node, null); bfc.parameters.AddElement(new namespace_variable_reference(init_var, null)); bfc.parameters.AddElement(new bool_const_node(true, null)); sl.statements.AddElementFirst(bfc); bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_not as basic_function_node, null); bfc.parameters.AddElement(new namespace_variable_reference(init_var, null)); sl2.statements.AddElement(new if_node(bfc, sl, null, null)); init_func.function_code = sl2; sl = new statements_list(null); sl.statements.AddElement(new common_namespace_function_call(init_func, null)); common_namespace_function_node init_variables_func = new common_namespace_function_node("$_InitVariables_", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null); init_variables_func.function_code = new statements_list(null); ((common_namespace_node)_main_function.comprehensive_namespace).functions.AddElement(init_variables_func); sl.statements.AddElement(new common_namespace_function_call(init_variables_func, null)); _init_code = sl; }
private void initialize_types() { _integer_type = compiled_type_node.get_type_node(typeof(int)); _bool_type = compiled_type_node.get_type_node(typeof(bool)); _real_type = compiled_type_node.get_type_node(typeof(double)); _char_type = compiled_type_node.get_type_node(typeof(char)); _string_type = compiled_type_node.get_type_node(typeof(string)); _pointer_type = compiled_type_node.get_type_node(Type.GetType("System.Void*")); NetInitialize(); //Преобразования типов. make_type_conversion(_integer_type, _real_type, type_compare.less_type, SemanticTree.basic_function_type.itod); //Операции для типа integer. //Присваивание для integer. make_assign_operator(_integer_type, SemanticTree.basic_function_type.iassign); //Унарные операции. make_unary_operator(compiler_string_consts.minus_name, _integer_type, SemanticTree.basic_function_type.iunmin); make_unary_operator(compiler_string_consts.not_name, _integer_type, SemanticTree.basic_function_type.inot); make_empty_operator(compiler_string_consts.plus_name, _integer_type); //Арифметические операции. _int_add = make_binary_operator(compiler_string_consts.plus_name, _integer_type, SemanticTree.basic_function_type.iadd); _int_sub = make_binary_operator(compiler_string_consts.minus_name, _integer_type, SemanticTree.basic_function_type.isub); make_binary_operator(compiler_string_consts.mul_name, _integer_type, SemanticTree.basic_function_type.imul); make_binary_operator(compiler_string_consts.idiv_name, _integer_type, SemanticTree.basic_function_type.idiv); make_binary_operator(compiler_string_consts.mod_name, _integer_type, SemanticTree.basic_function_type.imod); //Операция / для integer. make_common_binary_operation(compiler_string_consts.div_name, _integer_type, _real_type, _real_type, SemanticTree.basic_function_type.ddiv, _real_type); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name, _integer_type, SemanticTree.basic_function_type.igr, _bool_type); make_binary_operator(compiler_string_consts.greq_name, _integer_type, SemanticTree.basic_function_type.igreq, _bool_type); make_binary_operator(compiler_string_consts.sm_name, _integer_type, SemanticTree.basic_function_type.ism, _bool_type); make_binary_operator(compiler_string_consts.smeq_name, _integer_type, SemanticTree.basic_function_type.ismeq, _bool_type); make_binary_operator(compiler_string_consts.eq_name, _integer_type, SemanticTree.basic_function_type.ieq, _bool_type); make_binary_operator(compiler_string_consts.noteq_name, _integer_type, SemanticTree.basic_function_type.inoteq, _bool_type); //Логические опреции. make_binary_operator(compiler_string_consts.and_name, _integer_type, SemanticTree.basic_function_type.iand); make_binary_operator(compiler_string_consts.or_name, _integer_type, SemanticTree.basic_function_type.ior); make_binary_operator(compiler_string_consts.xor_name, _integer_type, SemanticTree.basic_function_type.ixor); make_binary_operator(compiler_string_consts.shl_name, _integer_type, SemanticTree.basic_function_type.ishl); make_binary_operator(compiler_string_consts.shr_name, _integer_type, SemanticTree.basic_function_type.ishr); //real type. //Assign. make_assign_operator(_real_type, SemanticTree.basic_function_type.dassign); //Унарные операции. make_unary_operator(compiler_string_consts.minus_name, _real_type, SemanticTree.basic_function_type.dunmin); make_empty_operator(compiler_string_consts.plus_name, _real_type); //Арифметические операции. make_binary_operator(compiler_string_consts.plus_name, _real_type, SemanticTree.basic_function_type.dadd); make_binary_operator(compiler_string_consts.minus_name, _real_type, SemanticTree.basic_function_type.dsub); make_binary_operator(compiler_string_consts.mul_name, _real_type, SemanticTree.basic_function_type.dmul); make_binary_operator(compiler_string_consts.div_name, _real_type, SemanticTree.basic_function_type.ddiv); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name, _real_type, SemanticTree.basic_function_type.dgr, _bool_type); make_binary_operator(compiler_string_consts.greq_name, _real_type, SemanticTree.basic_function_type.dgreq, _bool_type); make_binary_operator(compiler_string_consts.sm_name, _real_type, SemanticTree.basic_function_type.dsm, _bool_type); make_binary_operator(compiler_string_consts.smeq_name, _real_type, SemanticTree.basic_function_type.dsmeq, _bool_type); make_binary_operator(compiler_string_consts.eq_name, _real_type, SemanticTree.basic_function_type.deq, _bool_type); make_binary_operator(compiler_string_consts.noteq_name, _real_type, SemanticTree.basic_function_type.dnoteq, _bool_type); //char type. //Assign. make_assign_operator(_char_type, SemanticTree.basic_function_type.charassign); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name, _char_type, SemanticTree.basic_function_type.chargr, _bool_type); make_binary_operator(compiler_string_consts.greq_name, _char_type, SemanticTree.basic_function_type.chargreq, _bool_type); make_binary_operator(compiler_string_consts.sm_name, _char_type, SemanticTree.basic_function_type.charsm, _bool_type); make_binary_operator(compiler_string_consts.smeq_name, _char_type, SemanticTree.basic_function_type.charsmeq, _bool_type); make_binary_operator(compiler_string_consts.eq_name, _char_type, SemanticTree.basic_function_type.chareq, _bool_type); make_binary_operator(compiler_string_consts.noteq_name, _char_type, SemanticTree.basic_function_type.charnoteq, _bool_type); //boolean type. //Assign. make_assign_operator(_bool_type, SemanticTree.basic_function_type.boolassign); //Логические операции. //Унарные операции. make_unary_operator(compiler_string_consts.not_name, _bool_type, SemanticTree.basic_function_type.bnot); //Логическме операции. make_binary_operator(compiler_string_consts.and_name, _bool_type, SemanticTree.basic_function_type.band); make_binary_operator(compiler_string_consts.or_name, _bool_type, SemanticTree.basic_function_type.bor); make_binary_operator(compiler_string_consts.xor_name, _bool_type, SemanticTree.basic_function_type.bxor); make_unary_operator(compiler_string_consts.not_name, _bool_type, SemanticTree.basic_function_type.boolnot); //Опрерации сравнения. make_binary_operator(compiler_string_consts.gr_name, _bool_type, SemanticTree.basic_function_type.boolgr); make_binary_operator(compiler_string_consts.greq_name, _bool_type, SemanticTree.basic_function_type.boolgreq); make_binary_operator(compiler_string_consts.sm_name, _bool_type, SemanticTree.basic_function_type.boolsm); make_binary_operator(compiler_string_consts.smeq_name, _bool_type, SemanticTree.basic_function_type.boolsmeq); make_binary_operator(compiler_string_consts.eq_name, _bool_type, SemanticTree.basic_function_type.booleq); make_binary_operator(compiler_string_consts.noteq_name, _bool_type, SemanticTree.basic_function_type.boolnoteq); mark_int_as_ordinal(); mark_char_as_ordinal(); }