public static class_members BuildClassFieldsSection(List<ident> names, List<type_definition> types) { var cm = new class_members(access_modifer.private_modifer); for (int i = 0; i < names.Count; i++) cm.Add(new var_def_statement(names[i], types[i])); return cm; }
public class_body Add(class_members _class_members) { class_def_blocks.Add(_class_members); return this; }
public void visit(class_members _class_members) { bw.Write((Int16)76); write_class_members(_class_members); }
public static class_members BuildSimpleConstructorSection(List<ident> fields, List<ident> formal_names, List<type_definition> types) { var cm = new class_members(access_modifer.public_modifer); cm.Add(BuildSimpleConstructor(fields,formal_names,types)); return cm; }
public override void visit(class_members _class_members) { //throw new Exception("The method or operation is not implemented."); }
public void read_class_members(class_members _class_members) { read_syntax_tree_node(_class_members); if (br.ReadByte() == 0) { _class_members.members = null; } else { _class_members.members = new List<declaration>(); Int32 ssyy_count = br.ReadInt32(); for(Int32 ssyy_i = 0; ssyy_i < ssyy_count; ssyy_i++) { _class_members.members.Add(_read_node() as declaration); } } _class_members.access_mod = _read_node() as access_modifer_node; }
private Tuple<type_declaration, List<procedure_definition>> CreateTypeDeclarationWithForwardDeclaration(type_declaration cl) { var oldClDef = (class_definition) cl.type_def; var classDef = SyntaxTreeBuilder.BuildClassDefinition(); var typeDeclaration = new type_declaration(cl.type_name, classDef); classDef.where_section = oldClDef.where_section; var procedures = new List<procedure_definition>(); var classMembers = new class_members(access_modifer.public_modifer); classDef.body.class_def_blocks.Add(classMembers); foreach (var member in oldClDef.body.class_def_blocks.SelectMany(x => x.members)) { if (member is var_def_statement) { classMembers.Add(member); } else { var procDef = (procedure_definition) member; if (procDef.proc_header is constructor) { classMembers.Add(procDef); continue; } procedure_header procHeader; if (procDef.proc_header is function_header) { var fh = (function_header) procDef.proc_header; procHeader = new function_header { name = new method_name(fh.name.meth_name.name), source_context = fh.source_context, parameters = fh.parameters, of_object = fh.of_object, class_keyword = fh.class_keyword }; ((function_header)procHeader).return_type = fh.return_type; } else { procHeader = new procedure_header { name = new method_name(procDef.proc_header.name.meth_name.name), source_context = procDef.proc_header.source_context, parameters = procDef.proc_header.parameters, of_object = procDef.proc_header.of_object, class_keyword = procDef.proc_header.class_keyword }; } procDef.proc_header.name.class_name = cl.type_name; procedures.Add(procDef); classMembers.Add(procHeader); } } return new Tuple<type_declaration, List<procedure_definition>>(typeDeclaration, procedures); }
public void AddFirst(class_members el) { class_def_blocks.Insert(0, el); }
private int FindIndexInList(class_members el) { var ind = class_def_blocks.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; }
// Конструкторы списка public class_body(class_members elem, SourceContext sc = null) { Add(elem, sc); }
// Методы списка public class_body Add(class_members elem, SourceContext sc = null) { class_def_blocks.Add(elem); if (sc != null) source_context = sc; return this; }
public void CompareInternal(class_members left, class_members right) { if (left == null && right != null || left != null && right == null) throw_not_equal(left, right); if (left != null && right != null) { CompareInternal(left.access_mod, right.access_mod); if (left.members.Count != right.members.Count) throw_not_equal(left, right); for (int i = 0; i < left.members.Count; i++) CompareInternal(left.members[i], right.members[i]); } }
public override void visit(class_members _class_members) { visit_collection(_class_members.members); }
public class_body Add(class_members _class_members, SourceContext sc) { class_def_blocks.Add(_class_members); source_context = sc; return this; }
public override void visit(class_members _class_members) { prepare_node(_class_members.access_mod,"access_modifer"); prepare_collection(_class_members.members,"members"); }
public void InsertAfter(class_members el, class_members newel) { class_def_blocks.Insert(FindIndex(el) + 1, newel); }
public void visit(class_members _class_members) { read_class_members(_class_members); }
public void InsertBefore(class_members el, class_members newel) { class_def_blocks.Insert(FindIndex(el), newel); }
public override void visit(class_members _class_members) { throw new NotImplementedException(); }
public void InsertBefore(class_members el, IEnumerable<class_members> newels) { class_def_blocks.InsertRange(FindIndex(el), newels); }
private class_members get_class_member(ICSharpCode.NRefactory.Ast.INode node) { class_members cmem = new class_members(); if (node is ICSharpCode.NRefactory.Ast.FieldDeclaration) { ICSharpCode.NRefactory.Ast.FieldDeclaration fld = node as ICSharpCode.NRefactory.Ast.FieldDeclaration; cmem.access_mod = get_access_modifier(fld.Modifier); //if ((fld.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Const) == ICSharpCode.NRefactory.Ast.Modifiers.Const) //cmem.members.AddRange(get_const_declaration(fld)); //else cmem.members.AddRange(get_field_declaration(fld)); } else if (node is ICSharpCode.NRefactory.Ast.ConstructorDeclaration) { ICSharpCode.NRefactory.Ast.ConstructorDeclaration meth = node as ICSharpCode.NRefactory.Ast.ConstructorDeclaration; cmem.access_mod = get_access_modifier(meth.Modifier); cmem.members.Add(get_constructor_declaration(meth)); } else if (node is ICSharpCode.NRefactory.Ast.MethodDeclaration) { ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node as ICSharpCode.NRefactory.Ast.MethodDeclaration; cmem.access_mod = get_access_modifier(meth.Modifier); if (!meth.Body.IsNull) cmem.members.Add(get_method_declaration(meth)); else cmem.members.Add(get_method_header(meth)); } return cmem; /*else if (node is ICSharpCode.NRefactory.Ast.EventDeclaration) { ICSharpCode.NRefactory.Ast.EventDeclaration meth = node as ICSharpCode.NRefactory.Ast.EventDeclaration; cmem.access_mod = get_access_modifier(meth.Modifier); cmem.members.Add(get_event_declaration(meth)); }*/ }
public bool Remove(class_members el) { return class_def_blocks.Remove(el); }
public override void visit(class_members _class_members) { foreach (declaration decl in _class_members.members) decl.visit(this); }
public void ReplaceInList(class_members el, class_members newel) { class_def_blocks[FindIndexInList(el)] = newel; }
public static class_members BuildOneMemberSection(declaration m) { var cm = new class_members(access_modifer.public_modifer); cm.Add(m); return cm; }
public void ReplaceInList(class_members el, IEnumerable<class_members> newels) { var ind = FindIndexInList(el); class_def_blocks.RemoveAt(ind); class_def_blocks.InsertRange(ind, newels); }
public static class_members BuildSimpleReadPropertiesSection(List<ident> names, List<ident> fields, List<type_definition> types) { var cm = new class_members(access_modifer.public_modifer); for (int i = 0; i < names.Count; i++) cm.Add(BuildSimpleReadWriteProperty(names[i], fields[i], types[i])); return cm; }
public override void visit(class_members _class_members) { if (_class_members.access_mod != null && _class_members.access_mod.source_context != null) { bool already_off = true; if (_class_members.members.Count > 0 && _class_members.members[0].source_context != null && _class_members.access_mod.source_context.end_position.line_num == _class_members.members[0].source_context.begin_position.line_num) IncOffset(); else already_off = false; visit_node(_class_members.access_mod); if (_class_members.members.Count > 0) sb.Append(" "); if (!already_off) IncOffset(); } else IncOffset(); foreach (declaration decl in _class_members.members) { visit_node(decl); } DecOffset(); }
public void write_class_members(class_members _class_members) { write_syntax_tree_node(_class_members); if (_class_members.members == null) { bw.Write((byte)0); } else { bw.Write((byte)1); bw.Write(_class_members.members.Count); for(Int32 ssyy_i = 0; ssyy_i < _class_members.members.Count; ssyy_i++) { if (_class_members.members[ssyy_i] == null) { bw.Write((byte)0); } else { bw.Write((byte)1); _class_members.members[ssyy_i].visit(this); } } } if (_class_members.access_mod == null) { bw.Write((byte)0); } else { bw.Write((byte)1); _class_members.access_mod.visit(this); } }
public class_body(class_members _class_members, SourceContext sc) { Add(_class_members,sc); }