private void VisitEventDefinition(common_event _event, int offset) { SavePositionAndConstPool(_event); bw.Write((byte)_event.semantic_node_type); bw.Write(GetNameIndex(_event)); WriteTypeReference(_event.delegate_type); if (CanWriteObject(_event.add_method)) bw.Write(GetMemberOffset(_event.add_method)); if (CanWriteObject(_event.remove_method)) bw.Write(GetMemberOffset(_event.remove_method)); if (CanWriteObject(_event.raise_method)) bw.Write(GetMemberOffset(_event.raise_method)); bw.Write(GetMemberOffset(_event.field)); bw.Write(offset); bw.Write((byte)_event.field_access_level); bw.Write((byte)_event.polymorphic_state); SaveOffsetForAttribute(_event); bw.Write(0);//attributes; WriteDebugInfo(_event.loc); }
private definition_node CreateInterfaceEvent(string name, int offset) { definition_node dn = null; if (members.TryGetValue(offset, out dn)) return dn as common_event; common_event ce = null; int name_ref = br.ReadInt32(); type_node type = GetTypeReference(); common_method_node add_meth = null; if (CanReadObject()) add_meth = GetClassMethod(br.ReadInt32()); common_method_node remove_meth = null; if (CanReadObject()) remove_meth = GetClassMethod(br.ReadInt32()); common_method_node raise_meth = null; if (CanReadObject()) raise_meth = GetClassMethod(br.ReadInt32()); class_field cf = GetClassField(br.ReadInt32()); common_type_node cont = (common_type_node)GetTypeReference(br.ReadInt32()); if (name==null) name = GetStringInClass(cont, name_ref); SemanticTree.field_access_level fal = (SemanticTree.field_access_level)br.ReadByte(); SemanticTree.polymorphic_state ps = (SemanticTree.polymorphic_state)br.ReadByte(); attributes_list attrs = GetAttributes(); location loc = ReadDebugInfo(); ce = new common_event(name,type,cont,add_meth,remove_meth,raise_meth,fal,ps,loc); ce.field = cf; ce.attributes.AddRange(attrs); cont.events.AddElement(ce); AddMember(ce, offset); return ce; }
public SymbolInfo(common_event value) { _sym_info = value; _access_level = get_class_member_access_level(value); _symbol_kind = symbol_kind.sk_none; }
private void SaveEvent(common_event cfn) { if (!string.IsNullOrEmpty(cfn.documentation)) { if (!cfn.documentation.Trim(' ','\t').StartsWith("<summary>")) { xtw.WriteStartElement("member"); xtw.WriteStartAttribute("name"); if (is_assembly) xtw.WriteString("E:"+get_name(cfn.cont_type)+"."+cfn.name); else xtw.WriteString("E:"+cfn.cont_type.name+"."+cfn.name); xtw.WriteEndAttribute(); xtw.WriteStartElement("summary"); xtw.WriteString(cfn.documentation); xtw.WriteEndElement(); xtw.WriteEndElement(); } else { string doc = string.Concat("<member name=\""+(is_assembly?("E:"+get_name(cfn.cont_type)+"."+cfn.name):("E:"+cfn.cont_type.name+"."+cfn.name))+"\">",cfn.documentation,"</member>"); StringReader sr = new StringReader(doc); XmlReader xr = XmlTextReader.Create(sr); xr.Read(); xtw.WriteNode(xr.ReadSubtree(),false); sr.Close(); xr.Close(); } } }
public common_event add_event_definition(string name, location loc, type_node tn, SemanticTree.polymorphic_state ps, bool is_abstract) { class_field cf = new class_field(name + "$", tn, converted_type, ps, _fal, loc); common_event ce = new common_event(name, tn, converted_type, null, null, null, _fal, ps, loc); //add common_method_node add_meth = new common_method_node(compiler_string_consts.GetAddHandler(name), null, this.converted_type, ps, SemanticTree.field_access_level.fal_public, null); common_parameter cp = new common_parameter("value", tn, SemanticTree.parameter_type.value, add_meth, concrete_parameter_type.cpt_none, null, null); add_meth.parameters.AddElement(cp); expression_node fld_ref = null; if (!cf.IsStatic) fld_ref = new class_field_reference(cf, new this_node(converted_type, null), null); else fld_ref = new static_class_field_reference(cf, null); expression_node en = this.syntax_tree_visitor.convertion_data_and_alghoritms.type_constructor.delegate_add_assign_compile_time_executor (null, new expression_node[2] { fld_ref, new common_parameter_reference(cp, 0, null) }); if (!is_abstract) { add_meth.function_code = new statements_list(null); (add_meth.function_code as statements_list).statements.AddElement(en); } converted_type.scope.AddSymbol(add_meth.name, new SymbolInfo(add_meth)); //remove common_method_node remove_meth = new common_method_node(compiler_string_consts.GetRemoveHandler(name), null, this.converted_type, ps, SemanticTree.field_access_level.fal_public, null); cp = new common_parameter("value", tn, SemanticTree.parameter_type.value, add_meth, concrete_parameter_type.cpt_none, null, null); remove_meth.parameters.AddElement(cp); en = this.syntax_tree_visitor.convertion_data_and_alghoritms.type_constructor.delegate_sub_assign_compile_time_executor (null, new expression_node[2] { fld_ref, new common_parameter_reference(cp, 0, null) }); if (!is_abstract) { remove_meth.function_code = new statements_list(null); (remove_meth.function_code as statements_list).statements.AddElement(en); } converted_type.scope.AddSymbol(remove_meth.name, new SymbolInfo(remove_meth)); this.converted_type.methods.AddElement(add_meth); this.converted_type.methods.AddElement(remove_meth); ce.set_add_method(add_meth); ce.set_remove_method(remove_meth); ce.field = cf; this.converted_type.events.AddElement(ce); if (!is_abstract) this.converted_type.fields.AddElement(cf); converted_type.scope.AddSymbol(name, new SymbolInfo(ce)); return ce; }