private int GetPropertyReference(common_property_node prop, ref byte is_def) { int off = 0; if (members.TryGetValue(prop, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(prop, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetExtTypeReference(prop.common_comprehensive_type); ie.offset = GetExternalOffset(prop); int offset = imp_entitles.Count * ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[prop] = ie; return offset; }
private int GetEventReference(event_node ev, ref byte is_def) { if (ev.semantic_node_type == semantic_node_type.compiled_event) { is_def = 2; compiled_event cev = (compiled_event)ev; ImportedEntity ie = null; if (ext_members.TryGetValue(cev, out ie)) { return ie.index * ie.GetSize(); } //заполняем структуру в списке импортируемых сущностей ie = new ImportedEntity(); ie.index = imp_entitles.Count; ie.flag = ImportKind.DotNet; ie.num_unit = GetAssemblyToken(cev.event_info.DeclaringType.Assembly); //ie.offset = (int)ctn.compiled_type.MetadataToken;//токен для типа (уникален в сборке) ie.offset = GetTokenForNetEntity(cev.event_info.DeclaringType); int offset = imp_entitles.Count * ie.GetSize(); imp_entitles.Add(ie);//добавляем структуру ext_members[cev] = ie; return offset;//возвращаем смещение относительно начала списка импорт. сущ-тей } else if (ev.semantic_node_type == semantic_node_type.common_namespace_event) { int off = 0; if (members.TryGetValue(ev, out off)) //если этот тип описан в этом модуле { is_def = 4; return off;//возвращаем его смещение } is_def = 3; ImportedEntity ie = null; if (ext_members.TryGetValue(ev, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetUnitReference((ev as common_namespace_event).namespace_node); ie.offset = GetExternalOffset(ev); int offset = imp_entitles.Count * ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[ev] = ie; return offset; } else { int off = 0; if (members.TryGetValue(ev, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(ev, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetExtTypeReference((ev as common_event).cont_type); ie.offset = GetExternalOffset(ev); int offset = imp_entitles.Count * ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[ev] = ie; return offset; } }
private int GetFieldReference(class_field field, ref byte is_def) { int off = 0; if (members.TryGetValue(field, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(field, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetExtTypeReference(field.cont_type); ie.offset = GetExternalOffset(field); int offset = imp_entitles.Count*ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[field] = ie; return offset; }
private int GetConstantReference(namespace_constant_definition nv, ref byte is_def) { int off = 0; if (members.TryGetValue(nv, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } if (!used_units.ContainsKey(nv.comprehensive_namespace)) { is_def = 1; return -1; } is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(nv, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetUnitToken(nv.comprehensive_namespace); ie.offset = GetExternalOffset(nv); int offset = imp_entitles.Count*ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[nv] = ie; return offset; }
private int GetCompiledVariable(compiled_variable_definition cvd) { ImportedEntity ie = null; if (ext_members.TryGetValue(cvd, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.DotNet; ie.num_unit = GetCompiledTypeReference(cvd.cont_type); //ie.offset = (int)cvd.compiled_field.MetadataToken; ie.offset = GetTokenForNetEntity(cvd.compiled_field); ie.index = imp_entitles.Count; int offset = imp_entitles.Count*ie.GetSize(); imp_entitles.Add(ie); ext_members[cvd] = ie; return offset; }
//получение ссылки на откомпилированный метод private int GetCompiledMethod(compiled_function_node cfn) { ImportedEntity ie = null; if (ext_members.TryGetValue(cfn, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.DotNet; ie.num_unit = GetCompiledTypeReference(cfn.cont_type); //ie.offset = (int)cfn.method_info.MetadataToken; ie.offset = GetTokenForNetEntity(cfn.method_info); int offset = imp_entitles.Count*ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[cfn] = ie; return offset; }
//получение ссылки на откомпилированное свойство private int GetCompiledProperty(compiled_property_node cpn) { ImportedEntity ie = null; if (ext_members.TryGetValue(cpn, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.DotNet; ie.num_unit = GetCompiledTypeReference(cpn.compiled_comprehensive_type); //ie.offset = (int)ccn.constructor_info.MetadataToken; ie.offset = GetTokenForNetEntity(cpn.property_info); int offset = imp_entitles.Count * ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[cpn] = ie; return offset; }
//получение ссылки на функцию private int GetFunctionReference(common_namespace_function_node fn, ref byte is_def) { int off = 0; if (members.TryGetValue(fn, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(fn, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetUnitToken(fn.namespace_node); ie.offset = GetExternalOffset(fn); int offset = imp_entitles.Count*ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[fn] = ie; return offset; }
//получение ссылки на тип, описанный в другом модуле private int GetExtTypeReference(common_type_node ctn) { ImportedEntity ie = null; if (ext_members.TryGetValue(ctn, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetUnitToken(ctn.comprehensive_namespace); ie.offset = GetExternalOffset(ctn); int offset = imp_entitles.Count*ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[ctn] = ie; return offset; }
//\ssyy //получения ссылки на откомпилированный тип private int GetCompiledTypeReference(compiled_type_node ctn) { ImportedEntity ie = null; if (ext_members.TryGetValue(ctn, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.index = imp_entitles.Count; ie.flag = ImportKind.DotNet; ie.num_unit = GetAssemblyToken(ctn.compiled_type.Assembly); //ie.offset = (int)ctn.compiled_type.MetadataToken; ie.offset = GetTokenForNetEntity(ctn.compiled_type); int offset = imp_entitles.Count*ie.GetSize(); imp_entitles.Add(ie); ext_members[ctn] = ie; return offset; }
//ssyy private int GetTemplateTypeReference(template_class tc, ref byte is_def) { int off = 0; if (members.TryGetValue(tc, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } //иначе он описан в другом модуле is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(tc, out ie)) { return ie.index * ie.GetSize(); } ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetUnitToken(tc.cnn);//получаем модуль ie.offset = GetExternalOffset(tc);//получаем смещение в другом модуле int offset = imp_entitles.Count * ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[tc] = ie; return offset; }
//получения ссылки на тип private int GetTypeReference(type_node tn, ref byte is_def) { //если это откомпилир. тип if (tn.semantic_node_type == semantic_node_type.compiled_type_node) { is_def = 0; compiled_type_node ctn = (compiled_type_node)tn; ImportedEntity ie = null; if (ext_members.TryGetValue(ctn,out ie)) { return ie.index*ie.GetSize(); } //заполняем структуру в списке импортируемых сущностей ie = new ImportedEntity(); ie.index = imp_entitles.Count; ie.flag = ImportKind.DotNet; ie.num_unit = GetAssemblyToken(ctn.compiled_type.Assembly); //ie.offset = (int)ctn.compiled_type.MetadataToken;//токен для типа (уникален в сборке) ie.offset = GetTokenForNetEntity(ctn.compiled_type); int offset = imp_entitles.Count*ie.GetSize(); imp_entitles.Add(ie);//добавляем структуру ext_members[ctn] = ie; return offset;//возвращаем смещение относительно начала списка импорт. сущ-тей } else { int off = 0; if (members.TryGetValue(tn, out off)) //если этот тип описан в этом модуле { is_def = 1; return off;//возвращаем его смещение } //иначе он описан в другом модуле is_def = 0; ImportedEntity ie = null; if (ext_members.TryGetValue(tn, out ie)) { return ie.index * ie.GetSize(); } common_type_node ctn = (common_type_node)tn; ie = new ImportedEntity(); ie.flag = ImportKind.Common; ie.num_unit = GetUnitToken(ctn.comprehensive_namespace);//получаем модуль ie.offset = GetExternalOffset(ctn);//получаем смещение в другом модуле int offset = imp_entitles.Count*ie.GetSize(); ie.index = imp_entitles.Count; imp_entitles.Add(ie); ext_members[ctn] = ie; return offset; } }