本文整理汇总了C#中ITypeNode类的典型用法代码示例。如果您正苦于以下问题:C# ITypeNode类的具体用法?C# ITypeNode怎么用?C# ITypeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITypeNode类属于命名空间,在下文中一共展示了ITypeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: get_type_name
public static string get_type_name(ITypeNode t)
{
if (t is ICommonTypeNode)
{
return (t as ICommonTypeNode).comprehensive_namespace.namespace_name + "." + t.name;
}
else if (t is ICompiledTypeNode)
return (t as ICompiledTypeNode).name;
return t.name;
}
示例2: InitializeNDimUnsizedArray
private void InitializeNDimUnsizedArray(ILGenerator il, TypeInfo ti, ITypeNode _arr_type, IExpressionNode[] exprs, int rank)
{
Type arr_type = helper.GetTypeReference(_arr_type).tp.MakeArrayType(rank);
LocalBuilder tmp = il.DeclareLocal(arr_type);
CreateArrayLocalVariable(il, tmp, helper.GetTypeReference((exprs[2 + rank] as IArrayInitializer).type), exprs[2 + rank] as IArrayInitializer, (exprs[2 + rank] as IArrayInitializer).type);
il.Emit(OpCodes.Ldloc, tmp);
}
示例3: GetTypeReference
//получение типа
public TypeInfo GetTypeReference(ITypeNode type)
{
TypeInfo ti = defs[type] as TypeInfo;
if (ti != null)
{
if (type.type_special_kind == type_special_kind.text_file)
ti.is_text_file = true;
if (!ti.is_set && !ti.is_typed_file && !ti.is_text_file) return ti;
if (ti.clone_meth == null && !ti.is_typed_file && !ti.is_text_file)
{
if (type is ICommonTypeNode)
ti.clone_meth = this.GetMethodBuilder(find_method(type as ICommonTypeNode, "CloneSet"));//ti.tp.GetMethod("Clone");
else
ti.clone_meth = ti.tp.GetMethod("CloneSet");
}
if (ti.def_cnstr == null)
{
//if (type.type_special_kind == type_special_kind.text_file) ti.is_text_file = true;
if (ti.is_set)
{
if (type is ICommonTypeNode)
ti.def_cnstr = this.GetConstructorBuilder(find_constructor_with_params(type as ICommonTypeNode));
else
ti.def_cnstr = find_constructor_with_params(ti.tp);
}
else if (ti.is_typed_file)
{
if (type is ICommonTypeNode)
ti.def_cnstr = this.GetConstructorBuilder(find_constructor_with_one_param(type as ICommonTypeNode));
else
ti.def_cnstr = find_constructor_with_one_param(ti.tp);
}
else
{
if (type is ICommonTypeNode)
ti.def_cnstr = this.GetConstructorBuilder(find_constructor(type as ICommonTypeNode));
else
ti.def_cnstr = find_constructor(ti.tp);
}
}
if (ti.assign_meth == null && !ti.is_typed_file && !ti.is_text_file)
{
if (type is ICommonTypeNode)
ti.assign_meth = this.GetMethodBuilder(find_method(type as ICommonTypeNode, "AssignSetFrom"));
else
ti.assign_meth = ti.tp.GetMethod("AssignSetFrom");
}
return ti;
}
if (type is ICompiledTypeNode) {
ti = new TypeInfo(((ICompiledTypeNode)type).compiled_type);
defs[type] = ti;
return ti;
}
//(ssyy) Ускорил, вставив switch
switch (type.type_special_kind)
{
case type_special_kind.typed_file:
ti = GetTypeReference(type.base_type);
if (ti == null) return null;
ti.is_typed_file = true;
if (ti.def_cnstr == null)
{
if (type.base_type is ICommonTypeNode)
ti.def_cnstr = this.GetConstructorBuilder(find_constructor_with_one_param(type.base_type as ICommonTypeNode));
else
ti.def_cnstr = find_constructor_with_one_param(ti.tp);
}
return ti;
case type_special_kind.set_type:
ti = GetTypeReference(type.base_type);
if (ti == null) return null;
ti.is_set = true;
if (ti.clone_meth == null)
{
if (type.base_type is ICommonTypeNode)
ti.clone_meth = this.GetMethodBuilder(find_method(type.base_type as ICommonTypeNode, "CloneSet"));//ti.tp.GetMethod("Clone");
else
ti.clone_meth = ti.tp.GetMethod("CloneSet");
}
if (ti.assign_meth == null)
{
if (type.base_type is ICommonTypeNode)
ti.assign_meth = this.GetMethodBuilder(find_method(type.base_type as ICommonTypeNode, "AssignSetFrom"));
else
ti.assign_meth = ti.tp.GetMethod("AssignSetFrom");
}
if (ti.def_cnstr == null)
{
if (type.base_type is ICommonTypeNode)
ti.def_cnstr = this.GetConstructorBuilder(find_constructor_with_params(type.base_type as ICommonTypeNode));
else
ti.def_cnstr = find_constructor_with_params(ti.tp);
}
return ti;
case type_special_kind.diap_type:
return GetTypeReference(type.base_type);
case type_special_kind.short_string:
return TypeFactory.string_type;
//.........这里部分代码省略.........
示例4: AddEnum
public TypeInfo AddEnum(ITypeNode type, EnumBuilder emb)
{
TypeInfo ti = new TypeInfo(emb);
defs[type] = ti;
return ti;
}
示例5: GetPascalTypeReference
public Type GetPascalTypeReference(ITypeNode tn)
{
return pas_defs[tn] as Type;
}
示例6: InvalidateBaseTypeFolderNode
void InvalidateBaseTypeFolderNode(ITypeNode typeNode) {
var btNode = (IBaseTypeFolderNode)typeNode.TreeNode.DataChildren.FirstOrDefault(a => a is IBaseTypeFolderNode);
Debug.Assert(btNode != null || typeNode.TreeNode.Children.Count == 0);
if (btNode != null)
btNode.InvalidateChildren();
}
示例7: CreateNestedTypeDefCommand
CreateNestedTypeDefCommand(ITypeNode ownerType, TypeDefOptions options) {
this.ownerType = ownerType;
var modNode = ownerType.GetModuleNode();
Debug.Assert(modNode != null);
if (modNode == null)
throw new InvalidOperationException();
this.nestedType = ownerType.Create(options.CreateTypeDef(modNode.DnSpyFile.ModuleDef));
}
示例8: DeleteTypeDefCommand
DeleteTypeDefCommand(ITypeNode[] asmNodes) {
nodes = new DeletableNodes<ITypeNode>(asmNodes);
}
示例9: CreateNDimUnsizedArray
private void CreateNDimUnsizedArray(ILGenerator il, TypeInfo ti, ITypeNode tn, int rank, IExpressionNode[] sizes)
{
Type arr_type = ti.tp.MakeArrayType(rank);
List<Type> types = new List<Type>();
for (int i = 2; i < rank + 2; i++)
types.Add(TypeFactory.Int32Type);
ConstructorInfo ci = null;
MethodInfo mi = null;
if (tn is ICompiledTypeNode)
ci = arr_type.GetConstructor(types.ToArray());
else
mi = mb.GetArrayMethod(arr_type, ".ctor", CallingConventions.HasThis, null, types.ToArray());
ILGenerator tmp_il = this.il;
this.il = il;
for (int i = 2; i < rank + 2; i++)
sizes[i].visit(this);
this.il = tmp_il;
if (ci != null)
il.Emit(OpCodes.Newobj, ci);
else
il.Emit(OpCodes.Newobj, mi);
}
示例10: CreateInitCodeForUnsizedArray
private void CreateInitCodeForUnsizedArray(ILGenerator il, ITypeNode itn, IExpressionNode arr, LocalBuilder len)
{
ILGenerator tmp_il = this.il;
TypeInfo ti = helper.GetTypeReference(itn);
ICommonTypeNode ictn = itn as ICommonTypeNode;
bool generic_param = (ictn != null && ictn.runtime_initialization_marker != null);
FieldInfo finfo = null;
MethodInfo rif = null;
Label lab = default(Label);
this.il = il;
if (generic_param)
{
finfo = helper.GetField(ictn.runtime_initialization_marker).fi;
lab = il.DefineLabel();
il.Emit(OpCodes.Ldsfld, finfo);
il.Emit(OpCodes.Brfalse, lab);
if (SystemLibrary.SystemLibInitializer.RuntimeInitializeFunction.sym_info is ICompiledMethodNode)
rif = (SystemLibrary.SystemLibInitializer.RuntimeInitializeFunction.sym_info as ICompiledMethodNode).method_info;
else
rif = helper.GetMethod(SystemLibrary.SystemLibInitializer.RuntimeInitializeFunction.sym_info as IFunctionNode).mi;
}
if (ti.tp.IsValueType && ti.init_meth != null || ti.is_arr || ti.is_set || ti.is_typed_file || ti.is_text_file || ti.tp == TypeFactory.StringType ||
(generic_param))
{
LocalBuilder clb = il.DeclareLocal(TypeFactory.Int32Type);
il.Emit(OpCodes.Ldc_I4_0);
il.Emit(OpCodes.Stloc, clb);
Label tlabel = il.DefineLabel();
Label flabel = il.DefineLabel();
il.MarkLabel(tlabel);
il.Emit(OpCodes.Ldloc, clb);
il.Emit(OpCodes.Ldloc, len);
il.Emit(OpCodes.Bge, flabel);
if (generic_param)
{
arr.visit(this);
il.Emit(OpCodes.Ldloc, clb);
il.Emit(OpCodes.Ldsfld, finfo);
}
arr.visit(this);
il.Emit(OpCodes.Ldloc, clb);
if (!ti.is_arr && !ti.is_set && !ti.is_typed_file && !ti.is_text_file)
{
if (generic_param)
{
il.Emit(OpCodes.Ldelem, ti.tp);
il.Emit(OpCodes.Box, ti.tp);
il.EmitCall(OpCodes.Call, rif, null);
il.Emit(OpCodes.Unbox_Any, ti.tp);
il.Emit(OpCodes.Stelem, ti.tp);
}
else if (ti.tp != TypeFactory.StringType)
{
il.Emit(OpCodes.Ldelema, ti.tp);
il.Emit(OpCodes.Call, ti.init_meth);
}
else
{
Label lb1 = il.DefineLabel();
Label lb2 = il.DefineLabel();
il.Emit(OpCodes.Ldelem_Ref);
il.Emit(OpCodes.Ldnull);
il.Emit(OpCodes.Beq, lb2);
arr.visit(this);
il.Emit(OpCodes.Ldloc, clb);
il.Emit(OpCodes.Ldelem_Ref);
il.Emit(OpCodes.Ldstr, "");
il.Emit(OpCodes.Ceq);
il.Emit(OpCodes.Brfalse, lb1);
il.MarkLabel(lb2);
arr.visit(this);
il.Emit(OpCodes.Ldloc, clb);
il.Emit(OpCodes.Ldstr, "");
il.Emit(OpCodes.Stelem_Ref);
il.MarkLabel(lb1);
}
}
else
{
Label label1 = il.DefineLabel();
il.Emit(OpCodes.Ldelem_Ref);
il.Emit(OpCodes.Ldnull);
il.Emit(OpCodes.Ceq);
il.Emit(OpCodes.Brfalse, label1);
arr.visit(this);
il.Emit(OpCodes.Ldloc, clb);
if (ti.is_set)
{
IConstantNode cn1 = (arr.type.element_type as ICommonTypeNode).lower_value;
IConstantNode cn2 = (arr.type.element_type as ICommonTypeNode).upper_value;
if (cn1 != null && cn2 != null)
{
cn1.visit(this);
il.Emit(OpCodes.Box, helper.GetTypeReference(cn1.type).tp);
cn2.visit(this);
il.Emit(OpCodes.Box, helper.GetTypeReference(cn2.type).tp);
}
else
{
il.Emit(OpCodes.Ldnull);
//.........这里部分代码省略.........
示例11: CreateInitCodeForNDimUnsizedArray
private void CreateInitCodeForNDimUnsizedArray(ILGenerator il, TypeInfo ti, ITypeNode _arr_type, int rank, IExpressionNode[] exprs)
{
Type arr_type = helper.GetTypeReference(_arr_type).tp.MakeArrayType(rank);
ILGenerator tmp_il = this.il;
this.il = il;
MethodInfo set_meth = null;
MethodInfo addr_meth = null;
MethodInfo get_meth = null;
List<Type> lst2 = new List<Type>();
for (int i = 0; i < exprs.Length; i++)
lst2.Add(TypeFactory.Int32Type);
get_meth = mb.GetArrayMethod(arr_type, "Get", CallingConventions.HasThis, ti.tp, lst2.ToArray());
addr_meth = mb.GetArrayMethod(arr_type, "Address", CallingConventions.HasThis, ti.tp.MakeByRefType(), lst2.ToArray());
lst2.Add(ti.tp);
set_meth = mb.GetArrayMethod(arr_type, "Set", CallingConventions.HasThis, TypeFactory.VoidType, lst2.ToArray());
if (ti.tp.IsValueType && ti.init_meth != null || ti.is_arr || ti.is_set || ti.is_typed_file || ti.is_text_file || ti.tp == TypeFactory.StringType)
{
LocalBuilder tmp = il.DeclareLocal(arr_type);
il.Emit(OpCodes.Stloc, tmp);
List<TmpForNDimArr> lst = new List<TmpForNDimArr>();
for (int i = 0; i < exprs.Length; i++)
{
LocalBuilder clb = il.DeclareLocal(TypeFactory.Int32Type);
il.Emit(OpCodes.Ldc_I4_0);
il.Emit(OpCodes.Stloc, clb);
Label tlabel = il.DefineLabel();
Label flabel = il.DefineLabel();
il.MarkLabel(tlabel);
il.Emit(OpCodes.Ldloc, clb);
TmpForNDimArr tmp_arr_str = new TmpForNDimArr(clb, tlabel, flabel);
lst.Add(tmp_arr_str);
exprs[i].visit(this);
il.Emit(OpCodes.Bge, flabel);
}
il.Emit(OpCodes.Ldloc, tmp);
for (int i = 0; i < exprs.Length; i++)
{
il.Emit(OpCodes.Ldloc, lst[i].clb);
}
if (!ti.is_arr && !ti.is_set && !ti.is_typed_file && !ti.is_text_file)
{
if (ti.tp != TypeFactory.StringType)
{
il.Emit(OpCodes.Call, addr_meth);
il.Emit(OpCodes.Call, ti.init_meth);
}
else
{
il.Emit(OpCodes.Ldstr, "");
il.Emit(OpCodes.Call, set_meth);
}
}
else
{
Label label1 = il.DefineLabel();
il.Emit(OpCodes.Call, get_meth);
il.Emit(OpCodes.Ldnull);
il.Emit(OpCodes.Ceq);
il.Emit(OpCodes.Brfalse, label1);
il.Emit(OpCodes.Ldloc, tmp);
for (int i = 0; i < exprs.Length; i++)
{
il.Emit(OpCodes.Ldloc, lst[i].clb);
}
if (ti.is_set)
{
IConstantNode cn1 = (_arr_type as ICommonTypeNode).lower_value;
IConstantNode cn2 = (_arr_type as ICommonTypeNode).upper_value;
if (cn1 != null && cn2 != null)
{
cn1.visit(this);
il.Emit(OpCodes.Box, helper.GetTypeReference(cn1.type).tp);
cn2.visit(this);
il.Emit(OpCodes.Box, helper.GetTypeReference(cn2.type).tp);
}
else
{
il.Emit(OpCodes.Ldnull);
il.Emit(OpCodes.Ldnull);
}
}
else if (ti.is_typed_file)
{
NETGeneratorTools.PushTypeOf(il, helper.GetTypeReference((_arr_type as ICommonTypeNode).element_type).tp);
}
il.Emit(OpCodes.Newobj, ti.def_cnstr);
il.Emit(OpCodes.Call, set_meth);
il.MarkLabel(label1);
}
for (int i = exprs.Length - 1; i >= 0; i--)
{
il.Emit(OpCodes.Ldloc, lst[i].clb);
il.Emit(OpCodes.Ldc_I4_1);
il.Emit(OpCodes.Add);
il.Emit(OpCodes.Stloc, lst[i].clb);
il.Emit(OpCodes.Br, lst[i].tlabel);
il.MarkLabel(lst[i].flabel);
}
il.Emit(OpCodes.Ldloc, tmp);
}
//.........这里部分代码省略.........
示例12: GetGenericFunctionContainer
private ICommonFunctionNode GetGenericFunctionContainer(ITypeNode tn)
{
if (tn.common_generic_function_container != null)
{
return tn.common_generic_function_container;
}
if (tn.type_special_kind == type_special_kind.typed_file)
{
return GetGenericFunctionContainer(tn.element_type);
}
if (tn.type_special_kind == type_special_kind.set_type)
{
return GetGenericFunctionContainer(tn.element_type);
}
if (tn.type_special_kind == type_special_kind.array_kind)
{
return GetGenericFunctionContainer(tn.element_type);
}
IRefTypeNode ir = tn as IRefTypeNode;
if (ir != null)
{
return GetGenericFunctionContainer(ir.pointed_type);
}
IGenericTypeInstance igti = tn as IGenericTypeInstance;
if (igti != null)
{
foreach (ITypeNode par in igti.generic_parameters)
{
ICommonFunctionNode rez = GetGenericFunctionContainer(par);
if (rez != null)
{
return rez;
}
}
}
return null;
}
示例13: InitializeUnsizedArray
private void InitializeUnsizedArray(ILGenerator il, TypeInfo ti, ITypeNode _arr_type, IExpressionNode[] exprs, int rank)
{
Type arr_type = helper.GetTypeReference(_arr_type).tp.MakeArrayType();
LocalBuilder tmp = il.DeclareLocal(arr_type);
il.Emit(OpCodes.Stloc, tmp);
for (int i = 2 + rank; i < exprs.Length; i++)
{
il.Emit(OpCodes.Ldloc, tmp);
PushIntConst(il, i - 2 - rank);
ILGenerator ilb = this.il;
if (ti != null && ti.tp.IsValueType && !TypeFactory.IsStandType(ti.tp) && !ti.tp.IsEnum)
il.Emit(OpCodes.Ldelema, ti.tp);
this.il = il;
exprs[i].visit(this);
bool box = EmitBox(exprs[i], arr_type.GetElementType());
this.il = ilb;
TypeInfo ti2 = helper.GetTypeReference(exprs[i].type);
if (ti2 != null && !box)
NETGeneratorTools.PushStelem(il, ti2.tp);
else
il.Emit(OpCodes.Stelem_Ref);
}
il.Emit(OpCodes.Ldloc, tmp);
}
示例14: Delete
public void Delete(ITypeNode[] nodes) {
Debug.Assert(infos == null);
if (infos != null)
throw new InvalidOperationException();
infos = new ModelInfo[nodes.Length];
for (int i = 0; i < infos.Length; i++) {
var node = nodes[i];
var info = new ModelInfo(node.TypeDef);
infos[i] = info;
info.OwnerList.RemoveAt(info.Index);
}
}
示例15: Restore
public void Restore(ITypeNode[] nodes) {
Debug.Assert(infos != null);
if (infos == null)
throw new InvalidOperationException();
Debug.Assert(infos.Length == nodes.Length);
if (infos.Length != nodes.Length)
throw new InvalidOperationException();
for (int i = infos.Length - 1; i >= 0; i--) {
var node = nodes[i];
var info = infos[i];
info.OwnerList.Insert(info.Index, node.TypeDef);
}
infos = null;
}