public override void visit(enum_type_definition _enum_type_definition) { bool is_tuple = false; template_type_reference tuple = new template_type_reference(); tuple.name = new named_type_reference(new ident_list(new ident("System"), new ident("Tuple")).idents); template_param_list tpl = new template_param_list(); tuple.params_list = tpl; if (_enum_type_definition.enumerators != null) foreach (enumerator en in _enum_type_definition.enumerators.enumerators) { if (!(en.name is named_type_reference)) { is_tuple = true; } else { named_type_reference ntr = en.name as named_type_reference; if (ntr.names.Count > 1 || ntr.names.Count == 0) { is_tuple = true; } else { SymScope ss = cur_scope.FindName(ntr.FirstIdent.name); if (ss != null && ss is TypeScope) { is_tuple = true; } } } tpl.Add(en.name); } if (is_tuple) { tuple.visit(this); return; } //throw new Exception("The method or operation is not implemented."); EnumScope enum_scope = new EnumScope(SymbolKind.Enum, cur_scope, TypeTable.get_compiled_type(new SymInfo(typeof(Enum).Name, SymbolKind.Enum, typeof(Enum).FullName), typeof(Enum))); enum_scope.loc = get_location(_enum_type_definition); enum_scope.topScope = cur_scope; List<ElementScope> elems = new List<ElementScope>(); if (_enum_type_definition.enumerators != null) foreach (enumerator en in _enum_type_definition.enumerators.enumerators) { var name = (en.name as named_type_reference).FirstIdent.name; ElementScope ss = new ElementScope(new SymInfo(name, SymbolKind.Constant, name),/*cur_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name)*/enum_scope, cur_scope); ss.is_static = true; ss.cnst_val = name; elems.Add(ss); ss.loc = get_location(en); cur_scope.AddName(name, ss); enum_scope.AddName(name, ss); enum_scope.AddEnumConstant(name); if (this.converter.controller.docs.ContainsKey(en)) ss.AddDocumentation(this.converter.controller.docs[en]); } for (int i = 0; i < elems.Count; i++) elems[i].MakeDescription(); returned_scope = enum_scope; }
public override void visit(enum_type_definition _enum_type_definition) { //throw new Exception("The method or operation is not implemented."); EnumScope enum_scope = new EnumScope(SymbolKind.Enum,cur_scope, TypeTable.get_compiled_type(new SymInfo(typeof(Enum).Name, SymbolKind.Enum,typeof(Enum).FullName),typeof(Enum))); enum_scope.loc = get_location(_enum_type_definition); enum_scope.topScope = cur_scope; List<ElementScope> elems = new List<ElementScope>(); if (_enum_type_definition.enumerators != null) foreach (enumerator en in _enum_type_definition.enumerators.enumerators) { ElementScope ss = new ElementScope(new SymInfo(en.name.name, SymbolKind.Constant, en.name.name),/*cur_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name)*/enum_scope,cur_scope); ss.is_static = true; ss.cnst_val = en.name.name; elems.Add(ss); ss.loc = get_location(en); cur_scope.AddName(en.name.name, ss); enum_scope.AddName(en.name.name, ss); enum_scope.AddEnumConstant(en.name.name); } for (int i=0; i<elems.Count; i++) elems[i].MakeDescription(); ret_tn = enum_scope; }