private int GetTokenForNetEntity(ConstructorInfo val)
 {
     int off = 0;
     //if (tokens.TryGetValue(val, out off)) return off;
     object o = tokens[val];
     if (o != null) return (int)o;
     DotNetNameRef dnnr = new DotNetNameRef();
     dnnr.kind = DotNetKind.Constructor;
     dnnr.name = ".ctor";
     //if (val.GetParameters() != null)
     //{
         ParameterInfo[] prms = val.GetParameters();
         if (prms != null)
         {
             dnnr.addit = new DotAdditInfo[prms.Length];
             for (int i = 0; i < prms.Length; i++)
             {
                 dnnr.addit[i] = new DotAdditInfo();
                 dnnr.addit[i].offset = GetTokenForNetEntity(prms[i].ParameterType);
             }
         }
         else dnnr.addit = new DotAdditInfo[0];
     //}
     off = dot_net_name_list.Count;
     tokens.Add(val, dot_net_name_list.Count);
     dot_net_name_list.Add(dnnr);
     return off;
 }
 private int GetTokenForNetEntity(Type val)
 {
     int off = 0;
     //if (tokens.TryGetValue(val, out off)) return off;
     object o = tokens[val];
     if (o != null) return (int)o;
     DotNetNameRef dnnr = new DotNetNameRef();
     dnnr.kind = DotNetKind.Type;
     if (val.FullName != null)
     {
         //(ssyy) для инстанций generic-ов пишем имя оригинала
         if (val.IsGenericType && !val.IsGenericTypeDefinition)
             dnnr.name = val.GetGenericTypeDefinition().FullName;
         else
             dnnr.name = val.FullName;
     }
     else if (val.IsGenericType && !val.IsGenericTypeDefinition)
         dnnr.name = val.GetGenericTypeDefinition().FullName;
     else
         dnnr.name = val.Name;
    // if (val.IsGenericType)
     //{
         Type[] tt = (val.IsGenericTypeDefinition)?
             new Type[0]
             :
             val.GetGenericArguments();
         dnnr.addit = new DotAdditInfo[tt.Length];
         for (int i = 0; i < tt.Length; i++)
         {
             dnnr.addit[i] = new DotAdditInfo();
             dnnr.addit[i].offset = GetTokenForNetEntity(tt[i]);
         }
     //}
     off = dot_net_name_list.Count;
     tokens.Add(val, dot_net_name_list.Count);
     dot_net_name_list.Add(dnnr);
     return off;
 }
 private int GetTokenForNetEntity(FieldInfo val)
 {
     int off=0;
     object o = tokens[val];
     if (o != null) return (int)o;
     DotNetNameRef dnnr = new DotNetNameRef();
     dnnr.kind = DotNetKind.Field;
     dnnr.name = val.Name;
     dnnr.addit = new DotAdditInfo[0];
     off = dot_net_name_list.Count;
     tokens.Add(val, dot_net_name_list.Count);
     dot_net_name_list.Add(dnnr);
     return off;
 }
        //чтение заголовка PCU
		private void ReadPCUHeader()
		{
            if (!ReadPCUHead(pcu_file, br) || PCUFile.SupportedVersion != pcu_file.Version)
                InvalidUnitDetected();
            
            if(pcu_file.IncludeDebugInfo)
                pcu_file.SourceFileName = br.ReadString();
            else
                pcu_file.SourceFileName = Path.GetFileNameWithoutExtension(FileName);
			int num_names = br.ReadInt32();
			pcu_file.names = new NameRef[num_names];
			for (int i=0; i<num_names; i++)
			{
				pcu_file.names[i] = new NameRef(br.ReadString(),i);
				pcu_file.names[i].offset = br.ReadInt32();
                pcu_file.names[i].symbol_kind = (symbol_kind)br.ReadByte();
                pcu_file.names[i].special_scope = br.ReadByte();
            }
            //ssyy
            num_names = br.ReadInt32();
            pcu_file.implementation_names = new NameRef[num_names];
            for (int i = 0; i < num_names; i++)
            {
                pcu_file.implementation_names[i] = new NameRef(br.ReadString(), i);
                pcu_file.implementation_names[i].offset = br.ReadInt32();
                pcu_file.implementation_names[i].symbol_kind = (symbol_kind)br.ReadByte();
                pcu_file.implementation_names[i].special_scope = br.ReadByte();
            }
            //\ssyy
			int num_incl = br.ReadInt32();
			pcu_file.incl_modules = new string[num_incl];
			for (int i=0; i<num_incl; i++)
			{
				pcu_file.incl_modules[i] = br.ReadString();
			}
			int num_used_ns = br.ReadInt32();
			pcu_file.used_namespaces = new string[num_used_ns];
			for (int i=0; i<num_used_ns; i++)
			{
				pcu_file.used_namespaces[i] = br.ReadString();
			}
            //ssyy
            pcu_file.interface_uses_count = br.ReadInt32();
            //\ssyy
			int num_ref_ass = br.ReadInt32();
			pcu_file.ref_assemblies = new string[num_ref_ass];
			for (int i=0; i<num_ref_ass; i++)
			{
				pcu_file.ref_assemblies[i] = br.ReadString();
				
			}
			ReadAllAssemblies();
            int num_directives = br.ReadInt32();
            pcu_file.compiler_directives = new List<compiler_directive>();
            for (int i = 0; i < num_directives; i++)
            {
                pcu_file.compiler_directives.Add(new compiler_directive(br.ReadString(),br.ReadString(),ReadDebugInfo()));    
            }

			int num_imp_entity = br.ReadInt32();
			ext_pos = (int)br.BaseStream.Position;
			pcu_file.imp_entitles = new ImportedEntity[num_imp_entity];
			br.BaseStream.Seek(num_imp_entity*ImportedEntity.GetClassSize(),SeekOrigin.Current);

            //ssyy
            /*int num_int_syn = br.ReadInt32();
            pcu_file.interface_type_synonyms = new List<type_synonym>(num_int_syn);
            for (int i = 0; i < num_int_syn; i++)
            {
                pcu_file.interface_type_synonyms.Add(CreateTypeSynonym());
            }
            int num_impl_syn = br.ReadInt32();
            pcu_file.implementation_type_synonyms = new List<type_synonym>(num_impl_syn);
            for (int i = 0; i < num_impl_syn; i++)
            {
                pcu_file.implementation_type_synonyms.Add(CreateTypeSynonym());
            }*/
            //\ssyy

            pcu_file.interface_synonyms_offset = br.ReadInt32();
            pcu_file.implementation_synonyms_offset = br.ReadInt32();

            InitializationMethodOffset = br.ReadInt32();
            FinalizationMethodOffset = br.ReadInt32();
            //ivan
            int num_net_entities = br.ReadInt32();
            pcu_file.dotnet_names = new DotNetNameRef[num_net_entities];
            for (int i = 0; i < num_net_entities; i++)
            {
                DotNetNameRef dnnr = new DotNetNameRef();
                dnnr.kind = (DotNetKind)br.ReadByte();
                dnnr.name = br.ReadString();
                dnnr.addit = new DotAdditInfo[br.ReadInt32()];
                for (int j = 0; j < dnnr.addit.Length; j++)
                {
                    dnnr.addit[j] = new DotAdditInfo();
                    dnnr.addit[j].offset = br.ReadInt32();
                }
                pcu_file.dotnet_names[i] = dnnr;
            }
			start_pos = (int)br.BaseStream.Position;
		}