예제 #1
0
 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;
 }
예제 #2
0
		public class_body Add(class_members _class_members)
		{
		    class_def_blocks.Add(_class_members);
		    return this;
		}
예제 #3
0
		public void visit(class_members _class_members)
		{
			bw.Write((Int16)76);
			write_class_members(_class_members);
		}
예제 #4
0
 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;
 }
예제 #5
0
 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);
        }
예제 #8
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void AddFirst(class_members el)
		{
			class_def_blocks.Insert(0, el);
		}
예제 #9
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		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;
		}
예제 #10
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		// Конструкторы списка
		public class_body(class_members elem, SourceContext sc = null)
		{
			Add(elem, sc);
		}
예제 #11
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		// Методы списка
		public class_body Add(class_members elem, SourceContext sc = null)
		{
			class_def_blocks.Add(elem);
			if (sc != null)
				source_context = sc;
			return this;
		}
예제 #12
0
 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);
 }
예제 #14
0
		public class_body Add(class_members _class_members, SourceContext sc)
		{
		    class_def_blocks.Add(_class_members);
		    source_context = sc;
		    return this;
		}
예제 #15
0
		public override void visit(class_members _class_members)
		{
			prepare_node(_class_members.access_mod,"access_modifer");
			prepare_collection(_class_members.members,"members");
		}
예제 #16
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		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);
		}
예제 #18
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void InsertBefore(class_members el, class_members newel)
		{
			class_def_blocks.Insert(FindIndex(el), newel);
		}
예제 #19
0
		public override void visit(class_members _class_members)
		{
			throw new NotImplementedException();
		}
예제 #20
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void InsertBefore(class_members el, IEnumerable<class_members> newels)
		{
			class_def_blocks.InsertRange(FindIndex(el), newels);
		}
예제 #21
0
		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));
			}*/
		}
예제 #22
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public bool Remove(class_members el)
		{
			return class_def_blocks.Remove(el);
		}
예제 #23
0
 public override void visit(class_members _class_members)
 {
     foreach (declaration decl in _class_members.members)
         decl.visit(this);
 }
예제 #24
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void ReplaceInList(class_members el, class_members newel)
		{
			class_def_blocks[FindIndexInList(el)] = newel;
		}
예제 #25
0
 public static class_members BuildOneMemberSection(declaration m)
 {
     var cm = new class_members(access_modifer.public_modifer);
     cm.Add(m);
     return cm;
 }
예제 #26
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		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);
		}
예제 #27
0
 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();
 }
예제 #29
0
		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);
			}
		}
예제 #30
0
		public class_body(class_members _class_members, SourceContext sc)
		{
		    Add(_class_members,sc);
		}