public override void visit(var_def_statement _var_def_statement) { try { returned_scope = null; if (_var_def_statement.vars_type != null) _var_def_statement.vars_type.visit(this); if (_var_def_statement.vars_type == null && _var_def_statement.inital_value != null || _var_def_statement.inital_value is function_lambda_definition) { _var_def_statement.inital_value.visit(this); } // if (si == null) dn = compiled_type_node.get_type_node(PascalABCCompiler.NetHelper.NetHelper.FindType((_var_def_statement.vars_type as named_type_reference).names[0].name,unl)); if (returned_scope == null) return; if (returned_scope is ProcScope) { if (_var_def_statement.vars_type != null) returned_scope = new ProcType(returned_scope as ProcScope); else returned_scope = (returned_scope as ProcScope).return_type; } if (_var_def_statement.vars != null) foreach (ident s in _var_def_statement.vars.idents) { SymInfo si = new SymInfo(s.name, SymbolKind.Variable,s.name); if (cur_scope is TypeScope) si.kind = SymbolKind.Field; if (_var_def_statement.is_event) si.kind = SymbolKind.Event; ElementScope es = new ElementScope(si, returned_scope,cur_scope); if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_var_def_statement)) es.AddDocumentation(this.converter.controller.docs[_var_def_statement]); es.acc_mod = cur_access_mod; es.is_static = _var_def_statement.var_attr == definition_attribute.Static; es.si.acc_mod = cur_access_mod; es.loc = get_location(s); cur_scope.AddName(s.name,es); es.declaringUnit = cur_scope; } } catch(Exception e) { } }
public override void visit(simple_property _simple_property) { //throw new Exception("The method or operation is not implemented."); _simple_property.property_type.visit(this); if (returned_scope == null) return; ElementScope es = new ElementScope(new SymInfo(_simple_property.property_name.name, SymbolKind.Property,_simple_property.property_name.name), returned_scope, cur_scope); es.declaringUnit = entry_scope; if (_simple_property.array_default != null) { TypeScope ts = cur_scope as TypeScope; if (_simple_property.parameter_list != null) { ts.elementType = returned_scope as TypeScope; for (int i=0; i<_simple_property.parameter_list.parameters.Count; i++) { _simple_property.parameter_list.parameters[i].type.visit(this); if (returned_scope == null || !(returned_scope is TypeScope)) return; for (int j=0; j<_simple_property.parameter_list.parameters[i].names.idents.Count; j++) ts.AddIndexer(returned_scope as TypeScope); } } } if (_simple_property.parameter_list != null) { es.elementType = returned_scope as TypeScope; for (int i=0; i<_simple_property.parameter_list.parameters.Count; i++) { _simple_property.parameter_list.parameters[i].type.visit(this); if (returned_scope == null || !(returned_scope is TypeScope)) return; for (int j=0; j<_simple_property.parameter_list.parameters[i].names.idents.Count; j++) es.AddIndexer(returned_scope as TypeScope); } es.MakeDescription(); } es.loc = get_location(_simple_property); if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_simple_property)) es.AddDocumentation(this.converter.controller.docs[_simple_property]); if (_simple_property.attr == definition_attribute.Static) es.is_static = true; es.acc_mod = cur_access_mod; es.si.acc_mod = cur_access_mod; cur_scope.AddName(_simple_property.property_name.name,es); }
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(typed_const_definition _typed_const_definition) { //throw new Exception("The method or operation is not implemented."); _typed_const_definition.const_type.visit(this); if (returned_scope == null) return; cnst_val.prim_val = null; SymScope cnst_type = returned_scope; try { _typed_const_definition.const_value.visit(this); } catch(Exception e) { } ElementScope es = new ElementScope(new SymInfo(_typed_const_definition.const_name.name, SymbolKind.Constant,_typed_const_definition.const_name.name),cnst_type,cnst_val.prim_val,cur_scope); cur_scope.AddName(_typed_const_definition.const_name.name, es); es.loc = get_location(_typed_const_definition); es.declaringUnit = entry_scope; if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_typed_const_definition)) es.AddDocumentation(this.converter.controller.docs[_typed_const_definition]); cnst_val.prim_val = null; }