public syntax_tree_visitor() { convertion_data_and_alghoritms = new convertion_data_and_alghoritms(this); ret = new returner(this); context = new compilation_context(convertion_data_and_alghoritms, this); contextChanger = new ContextChanger(context); internal_reset(); }
public override void visit(SyntaxTree.array_type _array_type) { int rank = 1; if (is_unsized_array(_array_type.indexers, out rank)) { type_node ret = null; type_node et = convert_strong(_array_type.elements_type); //if (et == SystemLibrary.SystemLibrary.void_type) //AddError(new VoidNotValid(get_location(_array_type.elemets_types))); check_for_type_allowed(et,get_location(_array_type.elements_type)); ret = convertion_data_and_alghoritms.type_constructor.create_unsized_array(et, context.converted_namespace, rank, get_location(_array_type)); return_value(ret); return; } type_node_list ind_types = new type_node_list(); foreach (SyntaxTree.type_definition td in _array_type.indexers.indexers) { type_node tn = convert_strong(td); internal_interface ii = tn.get_internal_interface(internal_interface_kind.ordinal_interface); if (ii == null /*|| ((tn is common_type_node) && (tn as common_type_node).IsEnum)*/) { AddError(new OrdinalTypeExpected(get_location(td))); } if (tn.type_special_kind == SemanticTree.type_special_kind.diap_type) { if (tn.base_type == SystemLibrary.SystemLibrary.uint_type || tn.base_type == SystemLibrary.SystemLibrary.int64_type || tn.base_type == SystemLibrary.SystemLibrary.uint64_type) //ordinal_type_interface oti = tn.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface; AddError(get_location(td), "RANGE_TOO_LARGE"); } else if (tn == SystemLibrary.SystemLibrary.uint_type || tn == SystemLibrary.SystemLibrary.int64_type || tn == SystemLibrary.SystemLibrary.uint64_type) AddError(get_location(td), "RANGE_TOO_LARGE"); ind_types.AddElement(tn); } type_node elem_type = convert_strong(_array_type.elements_type); //TODO: Сделать и массивы, связанные с generics! if (depended_from_generic_parameter(elem_type)) { throw new NotSupportedError(get_location(_array_type.elements_type)); } //if (elem_type == SystemLibrary.SystemLibrary.void_type) // AddError(new VoidNotValid(get_location(_array_type.elemets_types))); check_for_type_allowed(elem_type,get_location(_array_type.elements_type)); for (int i = ind_types.Count - 1; i >= 0; i--) { internal_interface ii = ind_types[i].get_internal_interface(internal_interface_kind.ordinal_interface); ordinal_type_interface oti_ind = (ordinal_type_interface)ii; elem_type = convertion_data_and_alghoritms.type_constructor.get_array_type(oti_ind, elem_type, context.converted_namespace, get_location(_array_type)); } return_value(elem_type); }