本文整理汇总了C#中ITypeNode类的典型用法代码示例。如果您正苦于以下问题:C# ITypeNode类的具体用法?C# ITypeNode怎么用?C# ITypeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITypeNode类属于命名空间,在下文中一共展示了ITypeNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:10,代码来源:HtmlUtils.cs
示例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);
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:7,代码来源:NETGenerator.cs
示例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;
//.........这里部分代码省略.........
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:101,代码来源:Helpers.cs
示例4: AddEnum
public TypeInfo AddEnum(ITypeNode type, EnumBuilder emb)
{
TypeInfo ti = new TypeInfo(emb);
defs[type] = ti;
return ti;
}
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:6,代码来源:Helpers.cs
示例5: GetPascalTypeReference
public Type GetPascalTypeReference(ITypeNode tn)
{
return pas_defs[tn] as Type;
}
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:4,代码来源:Helpers.cs
示例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();
}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:6,代码来源:TypeDefCommands.cs
示例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));
}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:9,代码来源:TypeDefCommands.cs
示例8: DeleteTypeDefCommand
DeleteTypeDefCommand(ITypeNode[] asmNodes) {
nodes = new DeletableNodes<ITypeNode>(asmNodes);
}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:3,代码来源:TypeDefCommands.cs
示例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);
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:22,代码来源:NETGenerator.cs
示例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);
//.........这里部分代码省略.........
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:101,代码来源:NETGenerator.cs
示例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);
}
//.........这里部分代码省略.........
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:101,代码来源:NETGenerator.cs
示例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;
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:37,代码来源:NETGenerator.cs
示例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);
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:28,代码来源:NETGenerator.cs
示例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);
}
}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:15,代码来源:TypeDefCommands.cs
示例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;
}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:16,代码来源:TypeDefCommands.cs
示例16: GenerateNDimArrayInitCode
private void GenerateNDimArrayInitCode(ILGenerator il, LocalBuilder lb, IArrayInitializer InitalValue, ITypeNode ArrayType, int rank)
{
IExpressionNode[] ElementValues = InitalValue.ElementValues;
Type elem_type = helper.GetTypeReference(ArrayType.element_type).tp;
MethodInfo set_meth = null;
if (ArrayType is ICompiledTypeNode)
set_meth = lb.LocalType.GetMethod("Set");
else
{
List<Type> lst = new List<Type>();
for (int i = 0; i < rank; i++)
lst.Add(TypeFactory.Int32Type);
lst.Add(elem_type);
set_meth = mb.GetArrayMethod(lb.LocalType, "Set", CallingConventions.HasThis, TypeFactory.VoidType, lst.ToArray());
}
List<int> indices = new List<int>();
for (int i = 0; i < ElementValues.Length; i++)
{
if (i == 0)
indices.Add(i);
else
indices[indices.Count - rank] = i;
EmitArrayIndex(il, set_meth, lb, ElementValues[i] as IArrayInitializer, rank - 1, rank, indices);
}
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:25,代码来源:NETGenerator.cs
示例17: GenerateArrayInitCode
private void GenerateArrayInitCode(ILGenerator il, LocalBuilder lb, IArrayInitializer InitalValue, ITypeNode ArrayType)
{
IExpressionNode[] ElementValues = InitalValue.ElementValues;
if (ElementValues[0] is IArrayInitializer)
{
bool is_unsized_array;
Type FieldType, ArrType;
int rank = get_rank(ElementValues[0].type);
TypeInfo ti = helper.GetTypeReference(ElementValues[0].type);
if (NETGeneratorTools.IsBoundedArray(ti))
{
is_unsized_array = false;
ArrType = ti.tp;
FieldType = ti.arr_fld.FieldType;
}
else
{
is_unsized_array = true;
ArrType = helper.GetTypeReference(ElementValues[0].type).tp;
FieldType = ArrType;
}
LocalBuilder llb = il.DeclareLocal(FieldType);
for (int i = 0; i < ElementValues.Length; i++)
{
il.Emit(OpCodes.Ldloc, lb);
PushIntConst(il, i);
if (!is_unsized_array)
{
il.Emit(OpCodes.Ldelem, ArrType);
il.Emit(OpCodes.Ldfld, ti.arr_fld);
}
else
{
//il.Emit(OpCodes.Ldelema, ArrType);
if (rank > 1)
CreateNDimUnsizedArray(il, (ElementValues[i] as IArrayInitializer).type, helper.GetTypeReference((ElementValues[i] as IArrayInitializer).type.element_type), rank, get_sizes(ElementValues[0] as IArrayInitializer, rank), lb.LocalType.GetElementType());
else
CreateUnsizedArray(il, helper.GetTypeReference((ElementValues[i] as IArrayInitializer).type.element_type), (ElementValues[0] as IArrayInitializer).ElementValues.Length, lb.LocalType.GetElementType());
il.Emit(OpCodes.Stelem, ArrType);
il.Emit(OpCodes.Ldloc, lb);
PushIntConst(il, i);
il.Emit(OpCodes.Ldelem, ArrType);
//il.Emit(OpCodes.Ldelem_Ref);
}
il.Emit(OpCodes.Stloc, llb);
if (rank > 1)
GenerateNDimArrayInitCode(il, llb, ElementValues[i] as IArrayInitializer, ElementValues[i].type, rank);
else
GenerateArrayInitCode(il, llb, ElementValues[i] as IArrayInitializer, ArrayType);
}
}
else
if (ElementValues[0] is IRecordConstantNode || ElementValues[0] is IRecordInitializer)
{
TypeInfo ti = helper.GetTypeReference(ElementValues[0].type);
LocalBuilder llb = il.DeclareLocal(ti.tp.MakePointerType());
for (int i = 0; i < ElementValues.Length; i++)
{
il.Emit(OpCodes.Ldloc, lb);
PushIntConst(il, i);
il.Emit(OpCodes.Ldelema, ti.tp);
il.Emit(OpCodes.Stloc, llb);
if (ElementValues[0] is IRecordConstantNode)
GenerateRecordInitCode(il, llb, ElementValues[i] as IRecordConstantNode);
else GenerateRecordInitCode(il, llb, ElementValues[i] as IRecordInitializer, true);
}
}
else
for (int i = 0; i < ElementValues.Length; i++)
{
il.Emit(OpCodes.Ldloc, lb);
PushIntConst(il, i);
ILGenerator ilb = this.il;
TypeInfo ti = helper.GetTypeReference(ElementValues[i].type);
if (ti != null && ti.is_set)
{
this.il = il;
IConstantNode cn1 = null;
IConstantNode cn2 = null;
if (ArrayType != null && ArrayType.element_type.element_type is ICommonTypeNode)
{
cn1 = (ArrayType.element_type.element_type as ICommonTypeNode).lower_value;
cn2 = (ArrayType.element_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);
il.Emit(OpCodes.Ldnull);
}
il.Emit(OpCodes.Newobj, ti.def_cnstr);
il.Emit(OpCodes.Stelem_Ref);
il.Emit(OpCodes.Ldloc, lb);
//.........这里部分代码省略.........
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:101,代码来源:NETGenerator.cs
示例18: TypeDefSettingsCommand
TypeDefSettingsCommand(ModuleDef module, ITypeNode typeNode, TypeDefOptions options) {
this.module = module;
this.typeNode = typeNode;
this.newOptions = options;
this.origOptions = new TypeDefOptions(typeNode.TypeDef);
this.origParentNode = (IFileTreeNodeData)typeNode.TreeNode.Parent.Data;
this.origParentChildIndex = this.origParentNode.TreeNode.Children.IndexOf(typeNode.TreeNode);
Debug.Assert(this.origParentChildIndex >= 0);
if (this.origParentChildIndex < 0)
throw new InvalidOperationException();
this.nameChanged = origOptions.Name != newOptions.Name;
if (this.origParentNode is INamespaceNode) {
var modNode = (IModuleFileNode)this.origParentNode.TreeNode.Parent.Data;
if (newOptions.Namespace != origOptions.Namespace)
this.nsNodeCreator = new NamespaceNodeCreator(newOptions.Namespace, modNode);
}
if (this.nameChanged || origOptions.Namespace != newOptions.Namespace)
this.typeRefInfos = RefFinder.FindTypeRefsToThisModule(module).Where(a => RefFinder.TypeEqualityComparerInstance.Equals(a, typeNode.TypeDef)).Select(a => new TypeRefInfo(a)).ToArray();
}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:22,代码来源:TypeDefCommands.cs
示例19: get_type_reference_for_pascal_attributes
private Type get_type_reference_for_pascal_attributes(ITypeNode tn)
{
if (tn.type_special_kind == type_special_kind.short_string)
{
return CreateShortStringType(tn);
}
else if (tn.type_special_kind == type_special_kind.typed_file)
{
return CreateTypedFileType(tn as ICommonTypeNode);
}
else if (tn.type_special_kind == type_special_kind.set_type)
{
return CreateTypedSetType(tn as ICommonTypeNode);
}
else
return helper.GetTypeReference(tn).tp;
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:17,代码来源:NETGenerator.cs
示例20: AddPascalTypeReference
public void AddPascalTypeReference(ITypeNode tn, Type t)
{
pas_defs[tn] = t;
}
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:4,代码来源:Helpers.cs
注:本文中的ITypeNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论