• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IRMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRMethod的典型用法代码示例。如果您正苦于以下问题:C# IRMethod类的具体用法?C# IRMethod怎么用?C# IRMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRMethod类属于命名空间,在下文中一共展示了IRMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Transform

		public override void Transform(IRMethod pMethod)
		{
			KnownLocalType[] locals = new KnownLocalType[pMethod.Locals.Count];
			for (int i = 0; i < pMethod.Instructions.Count; i++)
			{
				var curInstr = pMethod.Instructions[i];
				if (curInstr.Opcode == IROpcode.NewObject && curInstr.Destination.Type == IRLinearizedLocationType.Local)
				{
					locals[curInstr.Destination.Local.LocalIndex].Known = true;
					locals[curInstr.Destination.Local.LocalIndex].Type = ((IRNewObjectInstruction)curInstr).Constructor.ParentType;
				}
			}
			for (int i = 0; i < pMethod.Instructions.Count; i++)
			{
				var curInstr = pMethod.Instructions[i];
				if (curInstr.Opcode == IROpcode.Call)
				{
					var callInstr = (IRCallInstruction)curInstr;
					if (callInstr.Virtual)
					{
						if (!callInstr.Target.IsVirtual || callInstr.Target.IsFinal || callInstr.Target.ParentType.IsSealed || callInstr.Sources[0].GetTypeOfLocation().IsSealed)
						{
							callInstr.Virtual = false;
						}
						else if (callInstr.Sources[0].Type == IRLinearizedLocationType.Local && locals[callInstr.Sources[0].Local.LocalIndex].Known)
						{
							callInstr.Target = locals[callInstr.Sources[0].Local.LocalIndex].Type.VirtualMethodTree[callInstr.Target.VirtualMethodIndex];
							callInstr.Virtual = false;
						}
					}
				}
			}


		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:35,代码来源:CallDevirtualization.cs


示例2: IsSimpleAccessor

		private static bool IsSimpleAccessor(IRMethod m, out int retInstrIdx)
		{
			// TODO: Allow for statics here as well.
			return
				(retInstrIdx = -1) == -1 &&
				m.ReturnType != null &&
				m.Parameters.Count == 1 &&
				m.Parameters[0].Type == m.ParentType &&
				(
					(
						m.Instructions.Count == 1 &&
						m.Instructions[0].Opcode == IROpcode.Return &&
						IsSimpleSource(m.Instructions[0].Sources[0]) &&
						(retInstrIdx = 0) == 0
					) ||
					(
						m.Instructions.Count == 2 &&
						m.Instructions[0].Opcode == IROpcode.Nop &&
						m.Instructions[1].Opcode == IROpcode.Return &&
						IsSimpleSource(m.Instructions[1].Sources[0]) &&
						(retInstrIdx = 1) == 1
					)
				)
			;	
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:25,代码来源:SimplePropertyInlining.cs


示例3: IsEmptyConstructor

		private static bool IsEmptyConstructor(IRMethod m)
		{
			return 
				(
					m.Instructions.Count == 3 &&
					m.Instructions[0].Opcode == IROpcode.Call &&
					IsBaseCallInstruction(m, m.Instructions[0]) &&
					IsEmptyConstructor(((IRCallInstruction)m.Instructions[0]).Target) &&
					m.Instructions[1].Opcode == IROpcode.Nop &&
					m.Instructions[2].Opcode == IROpcode.Return
				) ||
				(
					m.Instructions.Count == 2 &&
					(
						m.Instructions[0].Opcode == IROpcode.Nop ||
						(
							m.Instructions[0].Opcode == IROpcode.Call &&
							IsBaseCallInstruction(m, m.Instructions[0]) &&
							IsEmptyConstructor(((IRCallInstruction)m.Instructions[0]).Target)
						)
					) &&
					m.Instructions[1].Opcode == IROpcode.Return
				) ||
				(
					m.Instructions.Count == 1 &&
					m.Instructions[0].Opcode == IROpcode.Return
				)
			;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:29,代码来源:EmptyBaseConstructorCallElimination.cs


示例4: Transform

		public override void Transform(IRType type)
		{
			if (!type.IsAbstract && (type.IsGeneric || type.NestedInsideOfType != null || type.IsArrayType || type.IsManagedPointerType || type.IsUnmanagedPointerType))
			{
				if (type.VirtualMethodTree[3].ParentType != type)
				{
					// It doesn't already implement ToString() itself.
					IRMethod ts = new IRMethod(type.Assembly);
					ts.ParentType = type;
					ts.ReturnType = type.Assembly.AppDomain.System_String;
					ts.Parameters.Add(new IRParameter(type.Assembly) { ParentMethod = ts, Type = type });
					ts.VirtualMethodIndex = 3;
					var r = new IRReturnInstruction();
					r.ParentMethod = ts;
					r.Linearized = true;
					var loc = new IRLinearizedLocation(r, IRLinearizedLocationType.String);
					loc.String.Value = type.ToString();
					r.Sources.Add(loc);
					ts.Instructions.Add(r);

					ts.ParentTypeMethodIndex = type.Methods.Count;
					type.Methods.Add(ts);
					type.VirtualMethodTree[3] = ts;

					if (!ts.Resolved) // This adds it to the Domain's Methods list.
						throw new Exception();
				}
			}
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:29,代码来源:GenericToStringImplementor.cs


示例5: IRLoadRuntimeHandleInstruction

 public IRLoadRuntimeHandleInstruction(IRType pTargetType, IRMethod pTargetMethod, IRField pTargetField)
     : base(IROpcode.LoadRuntimeHandle)
 {
     TargetType = pTargetType;
     TargetMethod = pTargetMethod;
     TargetField = pTargetField;
 }
开发者ID:Astaelan,项目名称:Fusion,代码行数:7,代码来源:IRLoadRuntimeHandleInstruction.cs


示例6: Transform

		public override void Transform(IRMethod method)
		{
			method.Instructions.ImmediateRetargetModifiedInstructions = false;
			for (int i = 0; i < method.Instructions.Count; i++)
			{
				var curInstr = method.Instructions[i];
				switch (curInstr.Opcode)
				{
					case IROpcode.Unbox:
					{
						var curUBx = (Instructions.IRUnboxInstruction)curInstr;
						if (curUBx.GetValue && !curUBx.Type.IsValueType)
						{
							var c = new Instructions.IRCastInstruction(curUBx.Type, true);
							c.Sources.AddRange(curUBx.Sources);
							c.Sources.ForEach(s => s.SetParentInstruction(c));
							c.Destination = curUBx.Destination;
							c.Destination.SetParentInstruction(c);
							method.Instructions[i] = c;
						}
						break;
					}
					default:
						break;
				}
			}
			method.Instructions.FixModifiedTargetInstructions();
			method.Instructions.ImmediateRetargetModifiedInstructions = false;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:29,代码来源:InstructionSpecialization.cs


示例7: Run

		public override void Run(IRMethod pMethod)
		{
			bool prevWasKeptNop = false;
			pMethod.Instructions.DelayedReIndexOnRemove = true;
			for (int i = 0; i < pMethod.Instructions.Count; i++)
			{
				var curInstr = pMethod.Instructions[i];
				if (curInstr.Opcode == IROpcode.Nop)
				{
					var nop = (IRNopInstruction)curInstr;
					if (!nop.ForceEmit || prevWasKeptNop)
					{
						pMethod.Instructions.Remove(nop);
						i--;
					}
					else
					{
						prevWasKeptNop = true;
					}
				}
				else
				{
					prevWasKeptNop = false;
				}
			}
			pMethod.Instructions.FixRemovedTargetInstructions();
			pMethod.Instructions.DelayedReIndexOnRemove = false;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:28,代码来源:NopKilling.cs


示例8: Transform

		public override void Transform(IRMethod method)
		{
			foreach (var instr in method.Instructions)
			{
				instr.Sources.ForEach(s => TransformLocation(s));
				if (instr.Destination != null)
					TransformLocation(instr.Destination);
			}
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:9,代码来源:SizeOfToConstant.cs


示例9: ResolveSimpleReturn

		private static IRType ResolveSimpleReturn(IRType tp, IRMethod target)
		{
			if (tp.IsTemporaryVar)
				return target.ParentType.GenericParameters[tp.TemporaryVarOrMVarIndex];
			else if (tp.IsTemporaryMVar)
				return target.GenericParameters[tp.TemporaryVarOrMVarIndex];
			else if (tp.IsArrayType)
				return target.Assembly.AppDomain.GetArrayType(ResolveSimpleReturn(tp.ArrayElementType, target));
			else
				return tp;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:11,代码来源:IRCallInstruction.cs


示例10: IsBaseCallInstruction

		private static bool IsBaseCallInstruction(IRMethod pMethod, IRInstruction instr)
		{
			if (((IRCallInstruction)instr).Target.ParentType != pMethod.ParentType.BaseType)
			{
				int i43 = 0;
				i43++;
			}
			return
				instr.Sources.Count == 1 &&
				instr.Sources[0].Type == IRLinearizedLocationType.Parameter &&
				instr.Sources[0].Parameter.ParameterIndex == 0 &&
				((IRCallInstruction)instr).Target.ParentType == pMethod.ParentType.BaseType
			;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:14,代码来源:EmptyBaseConstructorCallElimination.cs


示例11: Run

		public override void Run(IRMethod pMethod)
		{
			pMethod.Instructions.ImmediateRetargetModifiedInstructions = false;
			for (int i = 0; i < pMethod.Instructions.Count; i++)
			{
				var curInstr = pMethod.Instructions[i];
				if (curInstr.Opcode == IROpcode.Call)
				{
					var curCall = (IRCallInstruction)curInstr;
					int retIdx;
					if (!curCall.Virtual && IsSimpleAccessor(curCall.Target, out retIdx))
					{
						if (curCall.Target.IsStatic)
						{
							var newMove = new IRMoveInstruction()
							{
								ParentMethod = pMethod,
							};
							newMove.Destination = curCall.Destination.Clone(newMove);
							var retSrc = curCall.Target.Instructions[retIdx].Sources[0];
							newMove.Sources.Add(retSrc.Clone(newMove));
							pMethod.Instructions[i] = newMove;
						}
						else
						{
							var newMove = new IRMoveInstruction()
							{
								ParentMethod = pMethod,
							};
							newMove.Destination = curCall.Destination.Clone(newMove);
							var curSrc = curCall.Sources[0];
							var retSrc = curCall.Target.Instructions[retIdx].Sources[0];
							var paramSrc = new IRLinearizedLocation(newMove, IRLinearizedLocationType.Parameter)
							{
								Parameter = new IRLinearizedLocation.ParameterLocationData()
								{
									ParameterIndex = 0,
								},
							};
							var nSrc = retSrc.Clone(newMove);
							nSrc.RetargetSource(ref nSrc, paramSrc, curSrc);
							newMove.Sources.Add(nSrc);
							pMethod.Instructions[i] = newMove;
						}
					}
				}
			}
			pMethod.Instructions.FixModifiedTargetInstructions();
			pMethod.Instructions.ImmediateRetargetModifiedInstructions = true;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:50,代码来源:SimplePropertyInlining.cs


示例12: Transform

		public override void Transform(IRMethod method)
		{
			if (method.IsInternalCall)
			{
				IRInstruction added = null;
				switch (method.ToString())
				{
					case "object object::Internal_PointerToReference(void*)":
					case "void* object.Internal_ReferenceToPointer(object)":
						method.Instructions.Add(
							added = new IRReturnInstruction()
							{
								Sources = new List<IRLinearizedLocation>()
								{
									new IRLinearizedLocation(null, IRLinearizedLocationType.Parameter)
									{
										Parameter = new IRLinearizedLocation.ParameterLocationData()
										{
											ParameterIndex = 0
										}
									}
								}
							}
						);
						added.Sources[0].SetParentInstruction(added);
						added.ParentMethod = method;
						break;
					case "(null) object::Internal_FastCopy(void*, void*, int)":
						break;
					case "(null) object::Internal_FastZero(void*, int)":
						break;
					case "(null) string..ctor(string, char[])":
						break;
					case "(null) string..ctor(string, char, int)":
						break;
					default:
						throw new Exception("Unknown internal call '" + method.ToString() + "'!");
				}
			}
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:40,代码来源:InternalCallImplementation.cs


示例13: Run

		public override void Run(IRMethod pMethod)
		{
			if (
				pMethod.Name == ".ctor" && 
				pMethod.Instructions.Count >= 3 &&
				pMethod.ParentType.BaseType != null
			)
			{
				int c = pMethod.Instructions.Count;
				int cIdx = -1;
				pMethod.Instructions.ImmediateRetargetModifiedInstructions = false;
				if (
					(
						pMethod.Instructions[c - 3].Opcode == IROpcode.Call &&
						IsBaseCallInstruction(pMethod, pMethod.Instructions[c - 3]) &&
						(cIdx = c - 3) >= 0
					) ||
					(
						pMethod.Instructions[0].Opcode == IROpcode.Call &&
						IsBaseCallInstruction(pMethod, pMethod.Instructions[0]) &&
						(cIdx = 0) >= 0
					) ||
					(
						pMethod.Instructions[c - 2].Opcode == IROpcode.Call &&
						IsBaseCallInstruction(pMethod, pMethod.Instructions[c - 2]) &&
						(cIdx = c - 2) >= 0
					)
				)
				{
					if (IsEmptyConstructor(((IRCallInstruction)pMethod.Instructions[cIdx]).Target))
					{
						pMethod.Instructions[cIdx] = new IRNopInstruction();
					}
				}
				pMethod.Instructions.FixModifiedTargetInstructions();
				pMethod.Instructions.ImmediateRetargetModifiedInstructions = true;
			}
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:38,代码来源:EmptyBaseConstructorCallElimination.cs


示例14: Run

		public override void Run(IRMethod pMethod)
		{
			pMethod.Instructions.ImmediateRetargetModifiedInstructions = false;
			for (int i = 0; i < pMethod.Instructions.Count - 1; i++)
			{
				var curInstr = pMethod.Instructions[i];
				if (curInstr.Opcode == IROpcode.Branch)
				{
					var curBranchInstr = (IRBranchInstruction)curInstr;
					if (curBranchInstr.BranchCondition == IRBranchCondition.Always)
					{
						if (curBranchInstr.TargetIRInstruction.IRIndex == curBranchInstr.IRIndex + 1)
						{
							pMethod.Instructions[i] = new IRNopInstruction();
						}
						else if (curBranchInstr.TargetIRInstruction.Opcode == IROpcode.Return)
						{
							pMethod.Instructions[i] = curBranchInstr.TargetIRInstruction.Clone(pMethod);
						}
						else if (pMethod.ReturnType != null &&
							curBranchInstr.TargetIRInstruction.Opcode == IROpcode.Move &&
							curBranchInstr.TargetIRInstruction.Sources[0].Type == IRLinearizedLocationType.Local &&
							pMethod.Instructions[curBranchInstr.TargetIRInstruction.IRIndex + 1].Opcode == IROpcode.Return
						)
						{
							var r = pMethod.Instructions[curBranchInstr.TargetIRInstruction.IRIndex + 1].Clone(pMethod);
							r.Sources[0] = curBranchInstr.TargetIRInstruction.Sources[0].Clone(r);
							pMethod.Instructions[i] = r;
						}
					}
				}
			}
			pMethod.Instructions.FixModifiedTargetInstructions();
			pMethod.Instructions.ImmediateRetargetModifiedInstructions = true;
			IRAppDomain.RemoveDeadCode(pMethod);
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:36,代码来源:BranchRemoval.cs


示例15: Clone

 public override IRInstruction Clone(IRMethod pNewMethod)
 {
     IRInstruction[] newTargetIRInstructions = (IRInstruction[])TargetIRInstructions.Clone();
     return CopyTo(new IRSwitchInstruction(TargetILOffsets) { TargetIRInstructions = newTargetIRInstructions }, pNewMethod);
 }
开发者ID:Astaelan,项目名称:Fusion,代码行数:5,代码来源:IRSwitchInstruction.cs


示例16: Clone

 public override IRInstruction Clone(IRMethod pNewMethod)
 {
     return CopyTo(new IRLoadStringInstruction(Value), pNewMethod);
 }
开发者ID:Astaelan,项目名称:Fusion,代码行数:4,代码来源:IRLoadStringInstruction.cs


示例17: Clone

		public override IRInstruction Clone(IRMethod pNewMethod) { return CopyTo(new IRSizeOfInstruction(Type), pNewMethod); }
开发者ID:carriercomm,项目名称:Proton-1,代码行数:1,代码来源:IRSizeOfInstruction.cs


示例18: Clone

 public override IRInstruction Clone(IRMethod pNewMethod)
 {
     return CopyTo(new IRInitializeObjectInstruction(Type), pNewMethod);
 }
开发者ID:Astaelan,项目名称:Fusion,代码行数:4,代码来源:IRInitializeObjectInstruction.cs


示例19: Clone

		public override IRInstruction Clone(IRMethod pNewMethod) { return CopyTo(new IRAddInstruction(OverflowType), pNewMethod); }
开发者ID:carriercomm,项目名称:Proton-1,代码行数:1,代码来源:IRAddInstruction.cs


示例20: Clone

 public override IRInstruction Clone(IRMethod pNewMethod)
 {
     return CopyTo(new IRLoadStaticFieldInstruction(Field), pNewMethod);
 }
开发者ID:Astaelan,项目名称:Fusion,代码行数:4,代码来源:IRLoadStaticFieldInstruction.cs



注:本文中的IRMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IROMatrix类代码示例发布时间:2022-05-24
下一篇:
C# IR类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap