public ClassInfo(int names_pos, int def_prop_off, int base_class_off, int interf_impl_off, NameRef[] names)
 {
     this.names_pos = names_pos;
     this.def_prop_off = def_prop_off;
     this.base_class_off = base_class_off;
     this.interf_impl_off = interf_impl_off;
     this.names = names;
 }
 //ssyy
 private void FillNames(NameRef[] name_array, Dictionary<definition_node, NameRef> pools)
 {
     int j = 0, i = 0;
     for (i = j; i < cur_cnn.constants.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.constants[i - j].name, i);
         pools[cur_cnn.constants[i - j]] = name_array[i];
     }
     j = i;
     for (i = j; i < cur_cnn.templates.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.templates[i - j].name, i);
         pools[cur_cnn.templates[i - j]] = name_array[i];
     }
     j = i;
     for (i = j; i < cur_cnn.functions.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.functions[i - j].name, i);
         if (cur_cnn.functions[i - j].ConnectedToType != null)
             name_array[i].special_scope = 1;
         pools[cur_cnn.functions[i - j]] = name_array[i];
     }
     j = i;
     for (i = j; i < cur_cnn.non_template_types.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.non_template_types[i - j].name, i);
         pools[cur_cnn.non_template_types[i - j]] = name_array[i];
     }
     j = i;
     for (i = j; i < cur_cnn.runtime_types.Count + j; i++)
     {
         name_array[i] = new NameRef(GetSynonimName(cur_cnn,cur_cnn.runtime_types[i - j]), i);
         //name_array[i] = new NameRef(cur_cnn.runtime_types[i - j].name, i);
         pools[cur_cnn.runtime_types[i - j]] = name_array[i];
     }
    
     j = i;
     for (i = j; i < cur_cnn.ref_types.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.ref_types[i - j].name, i);
         pools[cur_cnn.ref_types[i - j]] = name_array[i];
     }
     j = i;
     for (i = j; i < cur_cnn.variables.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.variables[i - j].name, i);
         pools[cur_cnn.variables[i - j]] = name_array[i];
     }
     j = i;
     for (i = j; i < cur_cnn.events.Count + j; i++)
     {
         name_array[i] = new NameRef(cur_cnn.events[i - j].name, i);
         pools[cur_cnn.events[i - j]] = name_array[i];
     }
 }
        private void AddNames(NameRef[] names, SymbolTable.Scope Scope)
        {
            for (int i = 0; i < names.Length; i++)
            {
                SymbolInfo si = new SymbolInfo();

                si.symbol_kind = names[i].symbol_kind;
                wrapped_definition_node wdn = new wrapped_definition_node(names[i].offset, this);
                si.sym_info = wdn;
                if (names[i].special_scope == 0)
                {
                    //PCUReturner.AddPCUReader((wrapped_definition_node)si.sym_info, this);
                    //si.access_level = access_level.al_public;
                    SymbolInfo si2 = (cun.scope as WrappedUnitInterfaceScope).FindWithoutCreation(names[i].name);
                    si.Next = si2;
                    Scope.AddSymbol(names[i].name, si);
                }
                else
                {
                    
                    type_node tn = GetSpecialTypeReference(names[i].offset);
                    if (tn is compiled_type_node)
                        (tn as compiled_type_node).scope.AddSymbol(names[i].name, si);
                    else if (tn is generic_instance_type_node)
                        tn.Scope.AddSymbol(names[i].name, si);
                    else if (tn is common_type_node)
                        (tn as common_type_node).scope.AddSymbol(names[i].name, si);
                    else
                        throw new NotSupportedException();
                }
            }
        }
		private void VisitTypeDefinition(common_type_node type)
		{
            int offset = 0;
            if (is_interface == true) offset = SavePositionAndConstPool(type);
			else offset = SavePositionAndImplementationPool(type);
			bw.Write((byte)type.semantic_node_type);
			bw.Write(is_interface);
            bw.Write(type_entity_index++);
			if (is_interface == true)
			 bw.Write(GetNameIndex(type));
			else
			 bw.Write(type.name);
            /*if (type.base_type != null)
             WriteTypeReference(type.base_type);
            else*/

            //Пишем, является ли данный класс интерфейсом
            if (type.IsInterface)
            {
                bw.Write((byte)1);
            }
            else
            {
                bw.Write((byte)0);
            }

            //Пишем, является ли данный класс делегатом
            if (type.IsDelegate)
            {
                bw.Write((byte)1);
            }
            else
            {
                bw.Write((byte)0);
            }
			
            //Является ли тип описанием дженерика
            if (type.is_generic_type_definition)
            {
                bw.Write((byte)1);
                //Число типов-параметров
                bw.Write(type.generic_params.Count);
                //Имена параметров
                foreach (common_type_node par in type.generic_params)
                {
                    bw.Write(par.name);
                }
            }
            else
            {
                bw.Write((byte)0);
            }

            int base_class_off = (int)bw.BaseStream.Position;

            bw.Seek(GetSizeOfReference(type.base_type), SeekOrigin.Current);
			
            //(ssyy) На кой чёрт это надо?
            //WriteTypeReference(SystemLibrary.SystemLibrary.object_type);
            //WriteTypeReference(type.base_type);
            bw.Write(type.internal_is_value);

            //Пишем поддерживаемые интерфейсы
            //eto nepravilno!!! a vdrug bazovye interfejsy eshe ne projdeny.
            //WriteImplementingInterfaces(type);
            int interface_impl_off = (int)bw.BaseStream.Position;
            int seek_off = sizeof(int);
            for (int k=0; k<type.ImplementingInterfaces.Count; k++)
            	seek_off += GetSizeOfReference(type.ImplementingInterfaces[k] as TreeRealization.type_node);
            bw.Seek(seek_off, SeekOrigin.Current);
            bw.Write((byte)type.type_access_level);
            bw.Write((byte)type.type_special_kind);
            bw.Write(type.IsSealed);
            bw.Write(type.IsAbstract);
            bw.Write(type.IsPartial);
            if (type.type_special_kind == SemanticTree.type_special_kind.diap_type)
            {
            	ordinal_type_interface oti = type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
            	VisitExpression(oti.lower_value);
            	VisitExpression(oti.upper_value);
            }

            if (type.is_generic_type_definition)
            {
                //Ограничители параметров
                WriteTypeParamsEliminations(type.generic_params);
            }
            if(CanWriteObject(type.element_type))
                WriteTypeReference(type.element_type);
            
			bw.Write(GetUnitReference(type.comprehensive_namespace));
			SaveOffsetForAttribute(type);
            bw.Write(0);//attributes;
            if (type.default_property != null) 
                bw.Write((byte)1);
            else 
                bw.Write((byte)0);
            int def_prop_off = (int)bw.BaseStream.Position;
            if (type.default_property != null)
                bw.Write(0);//default_property
            WriteDebugInfo(type.loc);
			//заполнение списка имен членов этого класса
            int num = type.const_defs.Count + type.fields.Count + type.properties.Count + type.methods.Count+type.events.Count;
			NameRef[] names = new NameRef[num];
			int pos = (int)bw.BaseStream.Position;
            int int_size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(int));
            int size = int_size;
			int i=0,j=0;
			for (i=j; i<type.const_defs.Count+j; i++)
			{
                names[i] = new NameRef(type.const_defs[i - j].name, i);
                name_pool[type.const_defs[i - j]] = names[i];
                size += names[i].Size;
			}
			j=i;
			for (i=j; i<type.fields.Count+j; i++)
			{
                names[i] = new NameRef(type.fields[i - j].name, i, convert_field_access_level(type.fields[i - j].field_access_level), type.fields[i - j].semantic_node_type);
                name_pool[type.fields[i - j]] = names[i];
                size += names[i].Size;
			}
			j=i;
			for (i=j; i<type.properties.Count+j; i++)
			{
                names[i] = new NameRef(type.properties[i - j].name, i, convert_field_access_level(type.properties[i - j].field_access_level), type.properties[i - j].semantic_node_type);
                name_pool[type.properties[i - j]] = names[i];
                size += names[i].Size;
			}
			j=i;
			for (i=j; i<type.methods.Count+j; i++)
			{
                names[i] = new NameRef(type.methods[i - j].name, i, convert_field_access_level(type.methods[i - j].field_access_level), type.methods[i - j].semantic_node_type);
                name_pool[type.methods[i - j]] = names[i];
                if (type.methods[i - j].is_overload)
                    names[i].symbol_kind = symbol_kind.sk_overload_function;
                names[i].virtual_slot = type.methods[i - j].newslot_awaited || type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_virtual || type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract || type.methods[i - j].is_constructor;
                size += names[i].Size;
			}
			j=i;
			for (i=j; i<type.events.Count+j; i++)
			{
                names[i] = new NameRef(type.events[i - j].name, i, convert_field_access_level(type.events[i - j].field_access_level), type.events[i - j].semantic_node_type);
                name_pool[type.events[i - j]] = names[i];
                size += names[i].Size;
			}
			bw.BaseStream.Seek(size,SeekOrigin.Current);
			/*VisitConstantInTypeDefinitions(type);
			VisitFieldDefinitions(type);
			VisitMethodDefinitions(type);
			VisitPropertyDefinitions(type);
			int tmp = (int)bw.BaseStream.Position;
            if (type.default_property != null)
            {
                bw.Seek(def_prop_off, SeekOrigin.Begin);
                bw.Write(GetMemberOffset(type.default_property));
                bw.Seek(tmp, SeekOrigin.Begin);
            }
            bw.BaseStream.Seek(pos,SeekOrigin.Begin);
            bw.Write(names.Length);
            for (i=0; i<names.Length; i++)
			{
				bw.Write(names[i].name);
				bw.Write(names[i].offset);
			}
			bw.BaseStream.Seek(tmp,SeekOrigin.Begin);*/
            ClassInfo ci = new ClassInfo(pos, def_prop_off, base_class_off, interface_impl_off,names);
            class_info[type] = ci;
		}
		private void ReadInterfaceEntity(NameRef nr)
		{
			SymScope ss = CreateInterfaceMember(nr.offset, nr.name);
			if (ss != null)
			cur_scope.AddName(nr.name,ss);
		}