private void VisitThisNode(this_node expr) { WriteTypeReference(expr.type); }
public override void visit(SyntaxTree.indexer _indexer) { //SSM 11/02/16 - нет, это глупость /*if (_indexer.dereferencing_value is SyntaxTree.question_colon_expression) // то разбросать индекс по компонентам { var q = _indexer.dereferencing_value as SyntaxTree.question_colon_expression; var nodeToVisit = new SyntaxTree.question_colon_expression(q.condition, new indexer(q.ret_if_true as addressed_value, _indexer.indexes, _indexer.source_context), new indexer(q.ret_if_false as addressed_value, _indexer.indexes, _indexer.source_context), _indexer.source_context); visit(nodeToVisit); return; }*/ //end SSM 11/02/16 //lroman if (_indexer.dereferencing_value is closure_substituting_node) { var nodeToVisit = new indexer(((closure_substituting_node) _indexer.dereferencing_value).substitution, _indexer.indexes); visit(nodeToVisit); return; } motivation mot = motivation_keeper.motivation; SyntaxTree.ident idi = _indexer.dereferencing_value as SyntaxTree.ident; if (idi != null) { SymbolInfo si = context.find(idi.name); if (si == null) { AddError(new UndefinedNameReference(idi.name, get_location(idi))); } if (si.sym_info.general_node_type == general_node_type.type_node) { indexer_as_type_indexes((type_node)si.sym_info, _indexer.indexes, mot, get_location(idi)); return; } if (si.sym_info.general_node_type == general_node_type.property_node) { property_node pn = (property_node)si.sym_info; if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static) { static_property_reference spr = new static_property_reference(pn, get_location(idi)); indexer_as_property_indexes(spr, _indexer.indexes, mot, get_location(idi)); return; } else { this_node thisnode = new this_node(pn.comprehensive_type, get_location(_indexer)); location loc111 = get_location(idi); non_static_property_reference nspr = new non_static_property_reference(pn, thisnode, loc111); indexer_as_property_indexes(nspr, _indexer.indexes, mot, loc111); return; } } expression_node en = ident_value_reciving(si, idi); indexer_as_expression_index(en, _indexer.indexes, mot, get_location(idi)); return; } else { SyntaxTree.dot_node dotnd = _indexer.dereferencing_value as SyntaxTree.dot_node; if (dotnd != null) { SyntaxTree.ident id = dotnd.right as SyntaxTree.ident; semantic_node sn = convert_semantic_strong(dotnd.left); switch (sn.general_node_type) { case general_node_type.type_node: { type_node ttp = (type_node)sn; SymbolInfo si = ttp.find_in_type(id.name, context.CurrentScope); if (si == null) { AddError(new UndefinedNameReference(id.name, get_location(id))); } if (si.sym_info.general_node_type == general_node_type.property_node) { property_node pn = (property_node)si.sym_info; static_property_reference spr = new static_property_reference(pn, get_location(id)); indexer_as_property_indexes(spr, _indexer.indexes, mot, get_location(dotnd)); return; } expression_node exp1 = create_static_expression(ttp, id, si); indexer_as_expression_index(exp1, _indexer.indexes, mot, get_location(id)); return; } case general_node_type.namespace_node: case general_node_type.unit_node: { SymbolInfo si = null; if (sn is namespace_node) si = ((namespace_node)sn).find(id.name); else si = ((unit_node)sn).find_only_in_namespace(id.name); if (si == null) { AddError(new UndefinedNameReference(id.name, get_location(id))); } location lloc = get_location(id); if (si.sym_info.general_node_type == general_node_type.type_node) { type_node tn = (type_node)si.sym_info; indexer_as_type_indexes(tn, _indexer.indexes, mot, lloc); return; } expression_node exp2 = ident_value_reciving(si, id); indexer_as_expression_index(exp2, _indexer.indexes, mot, get_location(id)); return; } case general_node_type.expression: { expression_node ex = (expression_node)sn; SymbolInfo si = ex.type.find_in_type(id.name, context.CurrentScope); if (si == null) { AddError(new UndefinedNameReference(id.name, get_location(id))); } if (si.sym_info.general_node_type == general_node_type.property_node) { property_node pn = (property_node)si.sym_info; if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static) { AddError(new CanNotReferenceToStaticPropertyWithExpression(pn, get_location(dotnd), ex.type)); } location lloc11 = get_location(dotnd); try_convert_typed_expression_to_function_call(ref ex); non_static_property_reference nspr = new non_static_property_reference(pn, ex, lloc11); indexer_as_property_indexes(nspr, _indexer.indexes, mot, lloc11); return; } expression_node en2 = expression_value_reciving(id, si, ex, false); indexer_as_expression_index(en2, _indexer.indexes, mot, get_location(id)); return; } } } else { expression_node expr = convert_strong(_indexer.dereferencing_value); indexer_as_expression_index(expr, _indexer.indexes, mot, get_location(_indexer.dereferencing_value)); return; } } /*expression_node left=convert_strong(_indexer.dereferencing_value); foreach(SyntaxTree.expression exp in _indexer.indexes.expressions) { expression_node right=convert_strong(exp); SymbolInfo si=left.type.find_in_type(compiler_string_consts.indexer_name); definition_node dn=check_name_node_type(compiler_string_consts.indexer_name,si,get_location(exp), general_node_type.function_node); expression_nodeArrayList exprs=new expression_nodeArrayList(); exprs.Add(right); function_node fn=convertion_data_and_alghoritms.select_function(exprs,si,get_location(exp)); base_function_call_with_method bfc=create_not_static_method_call(fn,left,get_location(exp),false); bfc.parameters.AddRange(exprs); left=bfc; }*/ /*switch (mot) { case motivation.address_reciving: { return_addressed_value(left); return; } case motivation.expression_evaluation: { return_value(left); return; } case motivation.semantic_node_reciving: { return_semantic_value(left); return; } }*/ }
//\ssyy //ssyy public void generate_inherited_from_base_and_interface_function(common_type_node ctype, function_node func) { common_method_node gen_func = context.create_function(func.name, null) as common_method_node; gen_func.polymorphic_state = SemanticTree.polymorphic_state.ps_common; gen_func.newslot_awaited = true; gen_func.is_final = true; gen_func.is_overload = true; gen_func.field_access_level = SemanticTree.field_access_level.fal_public; gen_func.return_value_type = func.return_value_type; //gen_func.return_variable = func.retu foreach (parameter par in func.parameters) { concrete_parameter_type cpt = (par.parameter_type == SemanticTree.parameter_type.value) ? concrete_parameter_type.cpt_const : concrete_parameter_type.cpt_var; common_parameter c_p = new common_parameter(par.name, par.parameter_type, gen_func, cpt, null); c_p.type = par.type; c_p.set_param_is_params(par.is_params); c_p.inital_value = par.inital_value; gen_func.parameters.AddElement(c_p); } local_variable lv = new local_variable(compiler_string_consts.self_word, gen_func.cont_type, gen_func, null); gen_func.scope.AddSymbol(compiler_string_consts.self_word, new SymbolInfo(lv)); gen_func.self_variable = lv; base_function_call bfc; this_node tn = null; common_method_node commn = func as common_method_node; if (commn != null) { tn = new this_node(commn.comperehensive_type as type_node, null); bfc = new common_method_call(commn, tn, null); } else { compiled_function_node compn = func as compiled_function_node; tn = new this_node(compn.comperehensive_type as type_node, null); bfc = new compiled_function_call(compn, tn, null); } foreach (parameter p in gen_func.parameters) { bfc.parameters.AddElement( create_variable_reference(p, null)); } //Это запретит чистку стека bfc.last_result_function_call = true; statements_list snlist = new statements_list(null); snlist.statements.AddElement(bfc); snlist.statements.AddElement(new empty_statement(null)); gen_func.function_code = snlist; context.pop_top_function(); //context.leave_block(); }
public void leave_block() { switch (converting_block()) { case block_type.function_block: { common_function_node top_func = _func_stack.top(); location loc; if (top_func.function_code == null) { loc = top_func.loc; } else if ((top_func.function_code as statements_list) != null) { statements_list stl = (statements_list)top_func.function_code; if (stl.statements.Count > 0) { loc = stl.statements[stl.statements.Count - 1].location; } else { loc = top_func.loc; } } else { loc = top_func.function_code.location; } if (top_func.function_code != null) { if (top_func.return_variable != null) { //TODO: Обратить внимание на преобразования типов. Можно сделать метод, который если тело функции не statement создает список statement-ов и добавляет в него существующий statement. statements_list stl = (statements_list)top_func.function_code; local_variable_reference lvr = new local_variable_reference(top_func.return_variable, 0, loc); stl.statements.AddElement(new return_node(lvr, loc)); } else if ((top_func.return_value_type != null) && (_ctn != null)) { //TODO: Обратить внимание на преобразования типов. Можно сделать метод, который если тело функции не statement создает список statement-ов и добавляет в него существующий statement. statements_list stl = (statements_list)top_func.function_code; this_node thn = new this_node(_ctn, loc); stl.statements.AddElement(new return_node(thn, loc)); } } check_predefinition_defined(); _func_stack.pop(); break; } case block_type.type_block: { //TODO: Может и сюда вставить check_predefinition_defined, несмотря на то, что в данный момент он ничего не делает. _cmn.types.AddElement(_ctn); _ctn=null; break; } case block_type.namespace_block: { check_predefinition_defined(); _cmn=null; break; } } }
public void make_constructor() { #if (DEBUG) if (converting_block()!=block_type.function_block) { throw new CompilerInternalError("Create constructor call without function"); } if (_func_stack.top().node_location_kind!=SemanticTree.node_location_kind.in_class_location) { throw new CompilerInternalError("Create constructor applied to non class method"); } #endif common_function_node top_func=_func_stack.top(); top_func.return_value_type=_ctn; common_method_node top_method=(common_method_node)top_func; common_method_node cmn=new common_method_node(top_func.name,_ctn,top_method.loc,_ctn, SemanticTree.polymorphic_state.ps_static,_fal,top_func.scope); cmn.is_constructor=true; cmn.is_overload=top_function.is_overload; //parameter_list pl = new parameter_list(); foreach (common_parameter pr in top_method.parameters) { common_parameter new_par = new common_parameter(pr.name, pr.type, pr.parameter_type, cmn, pr.concrete_parameter_type, pr.default_value, pr.loc); cmn.parameters.AddElement(new_par); } //cmn.parameters.AddRange(top_method.parameters); statements_list stl=new statements_list(top_func.loc); cmn.function_code=stl; this_node thn=new this_node(_ctn,top_func.loc); common_method_call csmc=new common_method_call(top_method,thn,top_func.loc); foreach(common_parameter cp in cmn.parameters) { common_parameter_reference cpr=new common_parameter_reference(cp,0,top_func.loc); csmc.parametres.AddElement(cpr); } stl.statements.AddElement(csmc); _ctn.methods.AddElement(cmn); top_method.pascal_associated_constructor=cmn; }
public void leave_block() { switch (converting_block()) { case block_type.function_block: { common_function_node top_func = _func_stack.top(); location loc; if (top_func.function_code == null) { loc = top_func.loc; } else if ((top_func.function_code as statements_list) != null) { statements_list stl = (statements_list)top_func.function_code; if (stl.statements.Count > 0) { loc = stl.statements[stl.statements.Count - 1].location; loc = null; //ivan } else { loc = top_func.loc; } } else { loc = top_func.function_code.location; } if (top_func.function_code != null) { if (top_func.return_variable != null) { //TODO: Обратить внимание на преобразования типов. Можно сделать метод, который если тело функции не statement создает список statement-ов и добавляет в него существующий statement. statements_list stl = (statements_list)top_func.function_code; local_variable_reference lvr = new local_variable_reference(top_func.return_variable, 0, loc); stl.statements.AddElement(new return_node(lvr, loc)); } else if ((top_func.return_value_type != null) && (_ctn != null)) { //TODO: Обратить внимание на преобразования типов. Можно сделать метод, который если тело функции не statement создает список statement-ов и добавляет в него существующий statement. statements_list stl = (statements_list)top_func.function_code; this_node thn = new this_node(_ctn, loc); stl.statements.AddElement(new return_node(thn, loc)); } } check_predefinition_defined(); _func_stack.pop(); break; } case block_type.type_block: { if (_cmn.types.IndexOf(_ctn) < 0) { _cmn.types.AddElement(_ctn); } //(ssyy) Проверим тип на реализацию функций интерфейсов check_predefinition_defined(); if (_ctn.is_generic_type_definition && !_ctn.IsInterface && _ctn.static_constr == null) { _ctn.static_constr = new common_method_node(PascalABCCompiler.TreeConverter.compiler_string_consts.static_ctor_prefix + "Create", null, _ctn, SemanticTree.polymorphic_state.ps_static, SemanticTree.field_access_level.fal_private, null); _ctn.static_constr.is_constructor = true; statements_list st = new statements_list(null); st.statements.AddElement(new return_node(new null_const_node(SystemLibrary.SystemLibrary.object_type, null), null)); _ctn.static_constr.function_code = st; _ctn.methods.AddElement(_ctn.static_constr); } _ctn=null; break; } case block_type.namespace_block: { check_predefinition_defined(); _cmn=null; break; } } }
public override void visit(SyntaxTree.indexer _indexer) { //SSM 11/02/16 - нет, это глупость /*if (_indexer.dereferencing_value is SyntaxTree.question_colon_expression) // то разбросать индекс по компонентам { var q = _indexer.dereferencing_value as SyntaxTree.question_colon_expression; var nodeToVisit = new SyntaxTree.question_colon_expression(q.condition, new indexer(q.ret_if_true as addressed_value, _indexer.indexes, _indexer.source_context), new indexer(q.ret_if_false as addressed_value, _indexer.indexes, _indexer.source_context), _indexer.source_context); visit(nodeToVisit); return; }*/ //end SSM 11/02/16 // SSM 18.08.16 - пробуем обработать захват enn[i] в yieldах где enn - поле класса и нуждается в переименовании // Так же ниже делает lroman if (_indexer.dereferencing_value is yield_unknown_ident) { var yui = (yield_unknown_ident)_indexer.dereferencing_value; var av = ProcessUnknownIdent(yui); var nodeToVisit = new indexer(av,_indexer.indexes); visit(nodeToVisit); return; } //lroman if (_indexer.dereferencing_value is closure_substituting_node) { var nodeToVisit = new indexer(((closure_substituting_node) _indexer.dereferencing_value).substitution, _indexer.indexes); visit(nodeToVisit); return; } var mot = motivation_keeper.motivation; motivation_keeper.reset(); SyntaxTree.ident idi = _indexer.dereferencing_value as SyntaxTree.ident; if (idi != null) { SymbolInfo si = context.find(idi.name); if (si == null) { AddError(new UndefinedNameReference(idi.name, get_location(idi))); } if (si.sym_info.general_node_type == general_node_type.type_node) { indexer_as_type_indexes((type_node)si.sym_info, _indexer.indexes, mot, get_location(idi)); return; } if (si.sym_info.general_node_type == general_node_type.property_node) { property_node pn = (property_node)si.sym_info; if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static) { static_property_reference spr = new static_property_reference(pn, get_location(idi)); indexer_as_property_indexes(spr, _indexer.indexes, mot, get_location(idi)); return; } else { this_node thisnode = new this_node(pn.comprehensive_type, get_location(_indexer)); location loc111 = get_location(idi); non_static_property_reference nspr = new non_static_property_reference(pn, thisnode, loc111); indexer_as_property_indexes(nspr, _indexer.indexes, mot, loc111); return; } } expression_node en = ident_value_reciving(si, idi); indexer_as_expression_index(en, _indexer.indexes, mot, get_location(idi)); return; } else { SyntaxTree.dot_node dotnd = _indexer.dereferencing_value as SyntaxTree.dot_node; if (dotnd != null) { SyntaxTree.ident id = dotnd.right as SyntaxTree.ident; semantic_node sn = convert_semantic_strong(dotnd.left); switch (sn.general_node_type) { case general_node_type.type_node: { type_node ttp = (type_node)sn; SymbolInfo si = ttp.find_in_type(id.name, context.CurrentScope); if (si == null) { AddError(new UndefinedNameReference(id.name, get_location(id))); } if (si.sym_info.general_node_type == general_node_type.property_node) { property_node pn = (property_node)si.sym_info; static_property_reference spr = new static_property_reference(pn, get_location(id)); indexer_as_property_indexes(spr, _indexer.indexes, mot, get_location(dotnd)); return; } expression_node exp1 = create_static_expression(ttp, id, si); indexer_as_expression_index(exp1, _indexer.indexes, mot, get_location(id)); return; } case general_node_type.namespace_node: case general_node_type.unit_node: { SymbolInfo si = null; if (sn is namespace_node) si = ((namespace_node)sn).find(id.name); else si = ((unit_node)sn).find_only_in_namespace(id.name); if (si == null) { AddError(new UndefinedNameReference(id.name, get_location(id))); } location lloc = get_location(id); if (si.sym_info.general_node_type == general_node_type.type_node) { type_node tn = (type_node)si.sym_info; indexer_as_type_indexes(tn, _indexer.indexes, mot, lloc); return; } expression_node exp2 = ident_value_reciving(si, id); indexer_as_expression_index(exp2, _indexer.indexes, mot, get_location(id)); return; } case general_node_type.expression: { expression_node ex = (expression_node)sn; SymbolInfo si = ex.type.find_in_type(id.name, context.CurrentScope); if (si == null) { AddError(new UndefinedNameReference(id.name, get_location(id))); } if (si.sym_info.general_node_type == general_node_type.property_node) { property_node pn = (property_node)si.sym_info; if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static) { AddError(new CanNotReferenceToStaticPropertyWithExpression(pn, get_location(dotnd), ex.type)); } location lloc11 = get_location(dotnd); try_convert_typed_expression_to_function_call(ref ex); non_static_property_reference nspr = new non_static_property_reference(pn, ex, lloc11); indexer_as_property_indexes(nspr, _indexer.indexes, mot, lloc11); return; } expression_node en2 = expression_value_reciving(id, si, ex, false); indexer_as_expression_index(en2, _indexer.indexes, mot, get_location(id)); return; } } } else { expression_node expr = convert_strong(_indexer.dereferencing_value); indexer_as_expression_index(expr, _indexer.indexes, mot, get_location(_indexer.dereferencing_value)); return; } } }
private type_node create_array_type(ordinal_type_interface oti_indexer, type_node element_type,common_namespace_node _cmn, location loc) { int arr_length = oti_indexer.ordinal_type_to_int(oti_indexer.upper_value) - oti_indexer.ordinal_type_to_int(oti_indexer.lower_value) + 1; if (arr_length <= 0) { throw new SimpleSemanticError(loc, "NEGATIVE_ARRAY_LENGTH_({0})_NOT_ALLOWED", arr_length); } simple_array sa = new simple_array(element_type, arr_length); //sa.length = arr_length; //sa.element_type = element_type; SymbolTable.Scope top_scope = null; if (_cmn != null) { top_scope = _cmn.scope; } string name = get_pascal_array_name(); //if (_cmn.namespace_name != null) // name = _cmn.namespace_name + name; common_type_node ctn = new common_type_node(null, name, SemanticTree.type_access_level.tal_public, _cmn, convertion_data_and_alghoritms.symbol_table.CreateClassScope(top_scope, null), loc); ctn.SetBaseType(SystemLibrary.SystemLibrary.object_type); //DarkStar Add //loc не нужно мне это! и некому не нужно! //loc = null; //ctn.internal_is_value = true; class_constant_definition cdn1 = new class_constant_definition(compiler_string_consts.lower_array_const_name, oti_indexer.lower_value, loc, ctn, SemanticTree.field_access_level.fal_public); ctn.scope.AddSymbol(cdn1.name, new SymbolInfo(cdn1)); class_constant_definition cdn2 = new class_constant_definition(compiler_string_consts.upper_array_const_name, oti_indexer.upper_value, loc, ctn, SemanticTree.field_access_level.fal_public); ctn.scope.AddSymbol(cdn2.name, new SymbolInfo(cdn2)); class_field int_arr = new class_field(compiler_string_consts.internal_array_name, sa, ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_public,loc); ctn.scope.AddSymbol(int_arr.name, new SymbolInfo(int_arr)); ctn.fields.AddElement(int_arr); SystemLibrary.SystemLibrary.init_reference_type(ctn); ctn.const_defs.AddElement(cdn1); ctn.const_defs.AddElement(cdn2); common_method_node get_func = new common_method_node(compiler_string_consts.get_val_pascal_array_name, element_type, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private, convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope)); common_parameter get_param = new common_parameter(compiler_string_consts.unary_param_name, oti_indexer.lower_value.type, SemanticTree.parameter_type.value, get_func, concrete_parameter_type.cpt_none, null, loc); get_func.parameters.AddElement(get_param); common_parameter_reference cpr = new common_parameter_reference(get_param, 0, loc); expression_node en1 = convertion_data_and_alghoritms.create_simple_function_call(oti_indexer.value_to_int, loc, cpr); expression_node en2 = new int_const_node(oti_indexer.ordinal_type_to_int(oti_indexer.lower_value), loc); expression_node sub_expr = convertion_data_and_alghoritms.create_simple_function_call( SystemLibrary.SystemLibrary.int_sub, loc, en1, en2); this_node thisnode = new this_node(ctn, loc); class_field_reference cfr1 = new class_field_reference(int_arr, thisnode, loc); expression_node index_expr = new simple_array_indexing(cfr1, sub_expr, element_type, loc); statement_node sn = new return_node(index_expr, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc)); get_func.function_code = sn; common_method_node set_func = new common_method_node(compiler_string_consts.set_val_pascal_array_name, null, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private, convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope)); common_parameter set_ind = new common_parameter(compiler_string_consts.left_param_name, oti_indexer.lower_value.type, SemanticTree.parameter_type.value, set_func, concrete_parameter_type.cpt_none, null, loc); set_func.parameters.AddElement(set_ind); common_parameter set_val = new common_parameter(compiler_string_consts.right_param_name, element_type, SemanticTree.parameter_type.value, set_func, concrete_parameter_type.cpt_none, null, loc); set_func.parameters.AddElement(set_val); common_parameter_reference cpr2 = new common_parameter_reference(set_ind, 0, loc); expression_node en3 = convertion_data_and_alghoritms.create_simple_function_call(oti_indexer.value_to_int, loc, cpr2); expression_node en4 = new int_const_node(oti_indexer.ordinal_type_to_int(oti_indexer.lower_value), loc); expression_node sub_expr2 = convertion_data_and_alghoritms.create_simple_function_call( SystemLibrary.SystemLibrary.int_sub, loc, en3, en4); class_field_reference cfr2 = new class_field_reference(int_arr, thisnode, loc); expression_node index_expr2 = new simple_array_indexing(cfr2, sub_expr2, element_type,loc); SymbolInfo si = element_type.find_in_type(compiler_string_consts.assign_name); if (si == null) { throw new NotSupportedError(loc); throw new CompilerInternalError("Varable of this type can not be assigned"); } if (si.sym_info.general_node_type != general_node_type.function_node) { throw new CompilerInternalError("Invalid assign operator"); } expression_node val_ref = new common_parameter_reference(set_val, 0, loc); function_node assign = (function_node)si.sym_info; statement_node assign_call = convertion_data_and_alghoritms.create_simple_function_call(assign, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), index_expr2, val_ref); set_func.function_code = assign_call; ctn.methods.AddElement(get_func); ctn.methods.AddElement(set_func); common_property_node cpn = new common_property_node(compiler_string_consts.index_property_pascal_array_name, ctn, element_type, get_func, set_func, loc, SemanticTree.field_access_level.fal_public, SemanticTree.polymorphic_state.ps_common); common_parameter prop_cp = new common_parameter(compiler_string_consts.unary_param_name, oti_indexer.lower_value.type, SemanticTree.parameter_type.value, null, concrete_parameter_type.cpt_none, null, loc); cpn.parameters.AddElement(prop_cp); ctn.properties.AddElement(cpn); ctn.default_property = cpn; if (_cmn != null) { _cmn.types.AddElement(ctn); } bounded_array_interface bai = new bounded_array_interface(oti_indexer, element_type, cpn, oti_indexer.lower_value.type, int_arr); ctn.add_internal_interface(bai); ctn.type_special_kind = SemanticTree.type_special_kind.array_wrapper; if (element_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper) { ctn.ImplementingInterfaces.Add(compiled_type_node.get_type_node(NetHelper.NetHelper.FindType(compiler_string_consts.IEnumerableInterfaceName))); common_method_node en_cmn = new common_method_node(compiler_string_consts.GetEnumeratorMethodName, compiled_type_node.get_type_node(NetHelper.NetHelper.FindType(compiler_string_consts.IEnumeratorInterfaceName)), null, ctn, SemanticTree.polymorphic_state.ps_virtual, SemanticTree.field_access_level.fal_public, null); compiled_function_node en_fnc = NetHelper.NetHelper.FindName(NetHelper.NetHelper.FindType(compiler_string_consts.IEnumerableInterfaceName), compiler_string_consts.GetEnumeratorMethodName).sym_info as compiled_function_node; statements_list sl = new statements_list(null); sl.statements.AddElement(new return_node( new compiled_function_call(en_fnc, new class_field_reference(int_arr, new this_node(ctn, null), null), null), null)); en_cmn.function_code = sl; en_cmn.newslot_awaited = true; ctn.methods.AddElement(en_cmn); if (!element_type.IsPointer) { List<type_node> generic_args = new List<type_node>(); generic_args.Add(element_type); type_node en_tn = compiled_type_node.get_type_node(NetHelper.NetHelper.FindType(compiler_string_consts.IGenericEnumerableInterfaceName)).get_instance(generic_args); ctn.ImplementingInterfaces.Add(en_tn); en_cmn = new common_method_node(compiler_string_consts.GetEnumeratorMethodName, compiled_type_node.get_type_node(NetHelper.NetHelper.FindType(compiler_string_consts.IGenericEnumeratorInterfaceName)).get_instance(generic_args), null, ctn, SemanticTree.polymorphic_state.ps_virtual, SemanticTree.field_access_level.fal_public, null); //en_fnc = en_tn.find_in_type("GetEnumerator").sym_info as function_node;//NetHelper.NetHelper.FindName(NetHelper.NetHelper.FindType(compiler_string_consts.IGenericEnumerableInterfaceName), compiler_string_consts.GetEnumeratorMethodName).sym_info as compiled_function_node; SymbolInfo en_si = en_tn.find_in_type("GetEnumerator"); if (en_si.Next != null && (en_si.Next.sym_info as function_node).return_value_type.is_generic_type_instance) en_si = en_si.Next; function_node en_fnc_inst = en_si.sym_info as function_node; ;//.get_instance(generic_args, true, loc); sl = new statements_list(null); if (en_fnc_inst is compiled_function_node) sl.statements.AddElement(new return_node( new compiled_function_call(en_fnc_inst as compiled_function_node, new class_field_reference(int_arr, new this_node(ctn, null), null), null), null)); else sl.statements.AddElement(new return_node( new common_method_call(en_fnc_inst as common_method_node, new class_field_reference(int_arr, new this_node(ctn, null), null), null), null)); en_cmn.function_code = sl; en_cmn.newslot_awaited = true; ctn.methods.AddElement(en_cmn); } } //= operation SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,ctn.scope); common_method_node cmn_eq = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.eq_name),SystemLibrary.SystemLibrary.bool_type,null,ctn, SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope); cmn_eq.IsOperator = true; common_parameter prm1 = new common_parameter("a",ctn,SemanticTree.parameter_type.value,cmn_eq,concrete_parameter_type.cpt_none,null,null); common_parameter prm2 = new common_parameter("b",ctn,SemanticTree.parameter_type.value,cmn_eq,concrete_parameter_type.cpt_none,null,null); cmn_eq.parameters.AddElement(prm1); cmn_eq.parameters.AddElement(prm2); statements_list body = new statements_list(null); local_variable vdn = new local_variable("$i",SystemLibrary.SystemLibrary.integer_type,cmn_eq,null);//this.convertion_data_and_alghoritms.syntax_tree_visitor.context.create_for_temp_variable(SystemLibrary.SystemLibrary.integer_type, null); cmn_eq.var_definition_nodes_list.AddElement(vdn); expression_node var_ref = new local_variable_reference(vdn,0,null);//this.convertion_data_and_alghoritms.syntax_tree_visitor.create_variable_reference(vdn,null); basic_function_call cond = new basic_function_call(SystemLibrary.SystemLibrary.int_sm as basic_function_node,null); cond.parameters.AddElement(var_ref); cond.parameters.AddElement(new int_const_node(arr_length,null)); while_node while_stmt = new while_node(cond,null); statements_list while_body = new statements_list(null); while_stmt.body = while_body; simple_array_indexing left_sar = new simple_array_indexing(new class_field_reference(int_arr, new common_parameter_reference(prm1,0,null), null),var_ref,element_type,null); simple_array_indexing right_sar = new simple_array_indexing(new class_field_reference(int_arr, new common_parameter_reference(prm2,0,null), null),var_ref,element_type,null); expression_node cond2 = SystemLibrary.SystemLibrary.syn_visitor.find_operator(compiler_string_consts.noteq_name, left_sar,right_sar,null); if_node if_stmt = new if_node(cond2,new return_node(new bool_const_node(false,null),null),null,null); while_body.statements.AddElement(if_stmt); while_body.statements.AddElement(new basic_function_call(SystemLibrary.SystemLibrary.int_assign as basic_function_node,null ,var_ref,new basic_function_call(SystemLibrary.SystemLibrary.int_add as basic_function_node,null,var_ref,new int_const_node(1,null)))); body.statements.AddElement(while_stmt); body.statements.AddElement(new return_node(new bool_const_node(true,null),null)); cmn_eq.function_code = body; cmn_eq.is_overload = true; ctn.methods.AddElement(cmn_eq); ctn.Scope.AddSymbol(compiler_string_consts.eq_name,new SymbolInfo(cmn_eq)); //<> operation scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,ctn.scope); common_method_node cmn_noteq = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.noteq_name),SystemLibrary.SystemLibrary.bool_type,null,ctn, SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope); cmn_noteq.IsOperator = true; prm1 = new common_parameter("a",ctn,SemanticTree.parameter_type.value,cmn_noteq,concrete_parameter_type.cpt_none,null,null); prm2 = new common_parameter("b",ctn,SemanticTree.parameter_type.value,cmn_noteq,concrete_parameter_type.cpt_none,null,null); cmn_noteq.parameters.AddElement(prm1); cmn_noteq.parameters.AddElement(prm2); body = new statements_list(null); vdn = new local_variable("$i",SystemLibrary.SystemLibrary.integer_type,cmn_noteq,null);//this.convertion_data_and_alghoritms.syntax_tree_visitor.context.create_for_temp_variable(SystemLibrary.SystemLibrary.integer_type, null); cmn_noteq.var_definition_nodes_list.AddElement(vdn); var_ref = new local_variable_reference(vdn,0,null);//this.convertion_data_and_alghoritms.syntax_tree_visitor.create_variable_reference(vdn,null); cond = new basic_function_call(SystemLibrary.SystemLibrary.int_sm as basic_function_node,null); cond.parameters.AddElement(var_ref); cond.parameters.AddElement(new int_const_node(arr_length,null)); while_stmt = new while_node(cond,null); while_body = new statements_list(null); while_stmt.body = while_body; left_sar = new simple_array_indexing(new class_field_reference(int_arr, new common_parameter_reference(prm1,0,null), null),var_ref,element_type,null); right_sar = new simple_array_indexing(new class_field_reference(int_arr, new common_parameter_reference(prm2,0,null), null),var_ref,element_type,null); cond2 = SystemLibrary.SystemLibrary.syn_visitor.find_operator(compiler_string_consts.noteq_name, left_sar,right_sar,null); if_stmt = new if_node(cond2,new return_node(new bool_const_node(true,null),null),null,null); while_body.statements.AddElement(if_stmt); while_body.statements.AddElement(new basic_function_call(SystemLibrary.SystemLibrary.int_assign as basic_function_node,null ,var_ref,new basic_function_call(SystemLibrary.SystemLibrary.int_add as basic_function_node,null,var_ref,new int_const_node(1,null)))); body.statements.AddElement(while_stmt); body.statements.AddElement(new return_node(new bool_const_node(false,null),null)); cmn_noteq.function_code = body; cmn_noteq.is_overload = true; ctn.methods.AddElement(cmn_noteq); ctn.Scope.AddSymbol(compiler_string_consts.noteq_name,new SymbolInfo(cmn_noteq)); //Equals /*scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,ctn.scope); common_method_node cmn_equals = new common_method_node("Equals",SystemLibrary.SystemLibrary.bool_type,null,ctn, SemanticTree.polymorphic_state.ps_virtual,SemanticTree.field_access_level.fal_public,scope); prm1 = new common_parameter("a",SystemLibrary.SystemLibrary.object_type,SemanticTree.parameter_type.value,cmn_equals,concrete_parameter_type.cpt_none,null,null); cmn_equals.parameters.AddElement(prm1); body = new statements_list(null); vdn = new local_variable("$i",ctn,cmn_equals,null);//this.convertion_data_and_alghoritms.syntax_tree_visitor.context.create_for_temp_variable(SystemLibrary.SystemLibrary.integer_type, null); cmn_equals.var_definition_nodes_list.AddElement(vdn); var_ref = new local_variable_reference(vdn,0,null);//this.convertion_data_and_alghoritms.syntax_tree_visitor.create_variable_reference(vdn,null); as_node _as = new as_node(new common_parameter_reference(prm1,0,null),ctn,null); base_function_call ass_bfc = new basic_function_call(SystemLibrary.SystemLibrary.object_type.find(compiler_string_consts.assign_name).sym_info as basic_function_node,null); ass_bfc.parameters.AddElement(var_ref); ass_bfc.parameters.AddElement(_as); body.statements.AddElement(ass_bfc); common_static_method_call csmc = new common_static_method_call(ctn.find_in_type(compiler_string_consts.eq_name).sym_info as common_method_node,null); csmc.parameters.AddElement(new this_node(ctn,null)); csmc.parameters.AddElement(var_ref); body.statements.AddElement(new return_node(csmc,null)); ctn.methods.AddElement(cmn_equals); ctn.Scope.AddSymbol("Equals",new SymbolInfo(cmn_equals));*/ return ctn; }