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(); } } }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(this, IRLinearizedLocationType.StaticField); Destination.StaticField.Field = Field; }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.StaticField); Destination.StaticField.Field = Field; }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); Destination.Local.LocalIndex = LocalIndex; }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.Parameter); Destination.Parameter.ParameterIndex = ParameterIndex; }
public override void Linearize(Stack <IRStackObject> pStack) { for (int count = 0; count < Target.Parameters.Count; ++count) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); } if (Target.ReturnType != null) { IRStackObject returned = new IRStackObject(); IRType retType = Target.ReturnType; if (retType.IsTemporaryVar) { retType = Target.ParentType.GenericParameters[retType.TemporaryVarOrMVarIndex]; } else if (retType.IsTemporaryMVar) { retType = Target.GenericParameters[retType.TemporaryVarOrMVarIndex]; } returned.Type = retType; returned.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); returned.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, retType); Destination = new IRLinearizedLocation(returned.LinearizedTarget); pStack.Push(returned); } }
private static bool IsDefaultValue(IRLinearizedLocation loc) { switch (loc.Type) { case IRLinearizedLocationType.ConstantI4: if (loc.ConstantI4.Value == 0) return true; return false; case IRLinearizedLocationType.ConstantI8: if (loc.ConstantI8.Value == 0L) return true; return false; case IRLinearizedLocationType.ConstantR4: if (loc.ConstantR4.Value == 0f) return true; return false; case IRLinearizedLocationType.ConstantR8: if (loc.ConstantR8.Value == 0d) return true; return false; case IRLinearizedLocationType.Null: return true; default: return false; } }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.Parameter); Destination.Parameter.ParameterIndex = ParameterIndex; }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.Indirect); Destination.Indirect.Type = Type; Destination.Indirect.AddressLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.Indirect); Destination.Indirect.Type = Type; Destination.Indirect.AddressLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); }
public override void Linearize(Stack<IRStackObject> pStack) { IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_RuntimeArgumentHandle; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_RuntimeArgumentHandle); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
private static void ProcessLocation(IRLinearizedLocation s, AssignedLocal[] locals) { switch (s.Type) { case IRLinearizedLocationType.Null: break; case IRLinearizedLocationType.ConstantI4: break; case IRLinearizedLocationType.ConstantI8: break; case IRLinearizedLocationType.ConstantR4: break; case IRLinearizedLocationType.ConstantR8: break; case IRLinearizedLocationType.SizeOf: break; case IRLinearizedLocationType.String: break; case IRLinearizedLocationType.Parameter: break; case IRLinearizedLocationType.ParameterAddress: break; case IRLinearizedLocationType.StaticField: break; case IRLinearizedLocationType.StaticFieldAddress: break; case IRLinearizedLocationType.RuntimeHandle: break; case IRLinearizedLocationType.Local: locals[s.Local.LocalIndex].UseCount++; break; case IRLinearizedLocationType.LocalAddress: locals[s.LocalAddress.LocalIndex].UseCount++; locals[s.LocalAddress.LocalIndex].AddressLoaded = true; break; case IRLinearizedLocationType.Field: ProcessLocation(s.Field.FieldLocation, locals); break; case IRLinearizedLocationType.FieldAddress: ProcessLocation(s.FieldAddress.FieldLocation, locals); break; case IRLinearizedLocationType.Indirect: ProcessLocation(s.Indirect.AddressLocation, locals); break; case IRLinearizedLocationType.ArrayElement: ProcessLocation(s.ArrayElement.ArrayLocation, locals); ProcessLocation(s.ArrayElement.IndexLocation, locals); break; case IRLinearizedLocationType.ArrayElementAddress: ProcessLocation(s.ArrayElementAddress.ArrayLocation, locals); ProcessLocation(s.ArrayElementAddress.IndexLocation, locals); break; case IRLinearizedLocationType.ArrayLength: ProcessLocation(s.ArrayLength.ArrayLocation, locals); break; case IRLinearizedLocationType.FunctionAddress: if (s.FunctionAddress.Virtual) ProcessLocation(s.FunctionAddress.InstanceLocation, locals); break; case IRLinearizedLocationType.Phi: s.Phi.SourceLocations.ForEach(source => ProcessLocation(source, locals)); break; default: throw new Exception("Unknown IRLinearizedLocation type!"); } }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = TargetType; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, TargetType); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_TypedReference; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_TypedReference); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); IRType arrayType = ParentMethod.Assembly.AppDomain.GetArrayType(ElementType); IRStackObject result = new IRStackObject(); result.Type = arrayType; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, arrayType); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_TypedReference; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_TypedReference); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { // Skip first parameter source, it is the 'this' reference that is put on the stack by newobj before constructor call for (int count = 1; count < Constructor.Parameters.Count; ++count) Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = Constructor.ParentType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Constructor.ParentType); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRStackObject value = pStack.Pop(); Sources.Add(new IRLinearizedLocation(value.LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = value.Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, value.Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
private static void TransformLocation(IRLinearizedLocation loc) { switch (loc.Type) { case IRLinearizedLocationType.Null: break; case IRLinearizedLocationType.ConstantI4: break; case IRLinearizedLocationType.ConstantI8: break; case IRLinearizedLocationType.ConstantR4: break; case IRLinearizedLocationType.ConstantR8: break; case IRLinearizedLocationType.String: break; case IRLinearizedLocationType.Parameter: break; case IRLinearizedLocationType.ParameterAddress: break; case IRLinearizedLocationType.StaticField: break; case IRLinearizedLocationType.StaticFieldAddress: break; case IRLinearizedLocationType.RuntimeHandle: break; case IRLinearizedLocationType.Local: break; case IRLinearizedLocationType.LocalAddress: break; case IRLinearizedLocationType.SizeOf: loc.Type = IRLinearizedLocationType.ConstantI4; loc.ConstantI4.Value = loc.SizeOf.Type.StackSize; loc.SizeOf.Type = null; break; case IRLinearizedLocationType.Field: TransformLocation(loc.Field.FieldLocation); break; case IRLinearizedLocationType.FieldAddress: TransformLocation(loc.FieldAddress.FieldLocation); break; case IRLinearizedLocationType.Indirect: TransformLocation(loc.Indirect.AddressLocation); break; case IRLinearizedLocationType.ArrayElement: TransformLocation(loc.ArrayElement.ArrayLocation); TransformLocation(loc.ArrayElement.IndexLocation); break; case IRLinearizedLocationType.ArrayElementAddress: TransformLocation(loc.ArrayElementAddress.ArrayLocation); TransformLocation(loc.ArrayElementAddress.IndexLocation); break; case IRLinearizedLocationType.ArrayLength: TransformLocation(loc.ArrayLength.ArrayLocation); break; case IRLinearizedLocationType.FunctionAddress: if (loc.FunctionAddress.Virtual) TransformLocation(loc.FunctionAddress.InstanceLocation); break; case IRLinearizedLocationType.Phi: throw new Exception("Phi's shouldn't exist yet!"); default: throw new Exception("Unknown IRLinearizedLocation type!"); } }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(this, IRLinearizedLocationType.ArrayLength); source.ArrayLength.ArrayLocation = new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget); Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_Int32; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_Int32); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); IRType resultType = Type; if (!GetValue) resultType = ParentMethod.Assembly.AppDomain.GetUnmanagedPointerType(Type); IRStackObject result = new IRStackObject(); result.Type = resultType; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, resultType); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.LocalAddress); source.LocalAddress.LocalIndex = LocalIndex; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_IntPtr; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_IntPtr); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.StaticField); source.StaticField.Field = Field; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = Field.Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Field.Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation value = new IRLinearizedLocation(IRLinearizedLocationType.String); value.String.Value = Value; Sources.Add(value); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_String; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_String); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); source.Local.LocalIndex = LocalIndex; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Locals[(int)LocalIndex].Type; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Locals[(int)LocalIndex].Type); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.Indirect); source.Indirect.Type = Type; source.Indirect.AddressLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.ArrayElement); Destination.ArrayElement.IndexLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); var arraySource = pStack.Pop(); Destination.ArrayElement.ArrayLocation = new IRLinearizedLocation(arraySource.LinearizedTarget); if (Type == null) { Type = arraySource.Type.ArrayType; } Destination.ArrayElement.ElementType = Type; }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation value = new IRLinearizedLocation(IRLinearizedLocationType.FunctionAddress); value.FunctionAddress.Method = Target; value.FunctionAddress.Virtual = Virtual; Sources.Add(value); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_IntPtr; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_IntPtr); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.ParameterAddress); source.ParameterAddress.ParameterIndex = ParameterIndex; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_IntPtr; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_IntPtr); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation value = new IRLinearizedLocation(IRLinearizedLocationType.SizeOf); value.SizeOf.Type = Type; Sources.Add(value); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_UInt32; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_UInt32); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(IRLinearizedLocationType.ArrayElement); Destination.ArrayElement.IndexLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); var arraySource = pStack.Pop(); Destination.ArrayElement.ArrayLocation = new IRLinearizedLocation(arraySource.LinearizedTarget); if (Type == null) { Type = arraySource.Type.ArrayType; } Destination.ArrayElement.ElementType = Type; }
public override void Linearize(Stack <IRStackObject> pStack) { IRStackObject value = pStack.Peek(); Sources.Add(new IRLinearizedLocation(value.LinearizedTarget)); IRStackObject result = new IRStackObject(); result.Type = value.Type; result.BoxedType = value.BoxedType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, value.Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.Parameter); source.Parameter.ParameterIndex = ParameterIndex; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Parameters[(int)ParameterIndex].Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Parameters[(int)ParameterIndex].Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.StaticField); source.StaticField.Field = Field; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = Field.Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Field.Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.ArrayLength); source.ArrayLength.ArrayLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_Int32; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_Int32); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRStackObject value2 = pStack.Pop(); IRStackObject value1 = pStack.Pop(); Sources.Add(new IRLinearizedLocation(this, value1.LinearizedTarget)); Sources.Add(new IRLinearizedLocation(this, value2.LinearizedTarget)); IRType resultType = ParentMethod.Assembly.AppDomain.BinaryNumericResult(value1.Type, value2.Type); IRStackObject result = new IRStackObject(); result.Type = resultType; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, resultType); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { // Skip first parameter source, it is the 'this' reference that is put on the stack by newobj before constructor call for (int count = 1; count < Constructor.Parameters.Count; ++count) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); } IRStackObject result = new IRStackObject(); result.Type = Constructor.ParentType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Constructor.ParentType); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRStackObject shiftAmount = pStack.Pop(); IRStackObject value = pStack.Pop(); Sources.Add(new IRLinearizedLocation(value.LinearizedTarget)); Sources.Add(new IRLinearizedLocation(shiftAmount.LinearizedTarget)); IRType resultType = ParentMethod.Assembly.AppDomain.ShiftNumericResult(value.Type, shiftAmount.Type); IRStackObject result = new IRStackObject(); result.Type = resultType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, resultType); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { for (int count = 0; count < Target.Parameters.Count; ++count) Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); if (Target.ReturnType != null) { IRStackObject returned = new IRStackObject(); IRType retType = ResolveSimpleReturn(Target.ReturnType, Target); returned.Type = retType; returned.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); returned.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, retType); Destination = new IRLinearizedLocation(this, returned.LinearizedTarget); pStack.Push(returned); } }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation value = new IRLinearizedLocation(IRLinearizedLocationType.FunctionAddress); value.FunctionAddress.Method = Target; value.FunctionAddress.Virtual = Virtual; Sources.Add(value); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_IntPtr; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_IntPtr); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget)); Destination = new IRLinearizedLocation(this, IRLinearizedLocationType.Indirect); var addressLocation = pStack.Pop(); Destination.Indirect.AddressLocation = new IRLinearizedLocation(this, addressLocation.LinearizedTarget); if (Type == null) { if (addressLocation.Type.IsManagedPointerType) Type = addressLocation.Type.ManagedPointerType; else Type = addressLocation.Type.UnmanagedPointerType; } if (Type == null) throw new Exception(); Destination.Indirect.Type = Type; }
public override void Linearize(Stack <IRStackObject> pStack) { IRStackObject value2 = pStack.Pop(); IRStackObject value1 = pStack.Pop(); Sources.Add(new IRLinearizedLocation(value1.LinearizedTarget)); Sources.Add(new IRLinearizedLocation(value2.LinearizedTarget)); IRType resultType = ParentMethod.Assembly.AppDomain.BinaryNumericResult(value1.Type, value2.Type); IRStackObject result = new IRStackObject(); result.Type = resultType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, resultType); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); IRType resultType = Type; if (!Value) { resultType = ParentMethod.Assembly.AppDomain.GetPointerType(Type); } IRStackObject result = new IRStackObject(); result.Type = resultType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, resultType); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.ArrayElement); source.ArrayElement.IndexLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); var arraySource = pStack.Pop(); source.ArrayElement.ArrayLocation = new IRLinearizedLocation(arraySource.LinearizedTarget); if (Type == null) { Type = arraySource.Type.ArrayType; } source.ArrayElement.ElementType = Type; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack<IRStackObject> pStack) { for (int count = 0; count < Target.Parameters.Count; ++count) Sources.Add(new IRLinearizedLocation(pStack.Pop().LinearizedTarget)); if (Target.ReturnType != null) { IRStackObject returned = new IRStackObject(); IRType retType = Target.ReturnType; if (retType.IsTemporaryVar) retType = Target.ParentType.GenericParameters[retType.TemporaryVarOrMVarIndex]; else if (retType.IsTemporaryMVar) retType = Target.GenericParameters[retType.TemporaryVarOrMVarIndex]; returned.Type = retType; returned.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); returned.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, retType); Destination = new IRLinearizedLocation(returned.LinearizedTarget); pStack.Push(returned); } }
public override void Linearize(Stack<IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(this, IRLinearizedLocationType.ArrayElementAddress); source.ArrayElementAddress.IndexLocation = new IRLinearizedLocation(this, pStack.Pop().LinearizedTarget); var arraySource = pStack.Pop(); source.ArrayElementAddress.ArrayLocation = new IRLinearizedLocation(this, arraySource.LinearizedTarget); if (Type == null) { Type = arraySource.Type.ArrayElementType; } if (Type == null) throw new Exception(); source.ArrayElementAddress.ElementType = Type; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = ParentMethod.Assembly.AppDomain.System_IntPtr; result.LinearizedTarget = new IRLinearizedLocation(this, IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, ParentMethod.Assembly.AppDomain.System_IntPtr); Destination = new IRLinearizedLocation(this, result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRLinearizedLocation source = new IRLinearizedLocation(IRLinearizedLocationType.ArrayElement); source.ArrayElement.IndexLocation = new IRLinearizedLocation(pStack.Pop().LinearizedTarget); var arraySource = pStack.Pop(); source.ArrayElement.ArrayLocation = new IRLinearizedLocation(arraySource.LinearizedTarget); if (Type == null) { Type = arraySource.Type.ArrayType; } source.ArrayElement.ElementType = Type; Sources.Add(source); IRStackObject result = new IRStackObject(); result.Type = Type; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, Type); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }
public override void Linearize(Stack <IRStackObject> pStack) { IRType handleType = null; if (TargetType != null) { handleType = ParentMethod.Assembly.AppDomain.System_RuntimeTypeHandle; } else if (TargetMethod != null) { handleType = ParentMethod.Assembly.AppDomain.System_RuntimeMethodHandle; } else if (TargetField != null) { handleType = ParentMethod.Assembly.AppDomain.System_RuntimeFieldHandle; } else { throw new NullReferenceException(); } IRLinearizedLocation value = new IRLinearizedLocation(IRLinearizedLocationType.RuntimeHandle); value.RuntimeHandle.HandleType = handleType; value.RuntimeHandle.TargetType = TargetType; value.RuntimeHandle.TargetMethod = TargetMethod; value.RuntimeHandle.TargetField = TargetField; Sources.Add(value); IRStackObject result = new IRStackObject(); result.Type = handleType; result.LinearizedTarget = new IRLinearizedLocation(IRLinearizedLocationType.Local); result.LinearizedTarget.Local.LocalIndex = AddLinearizedLocal(pStack, handleType); Destination = new IRLinearizedLocation(result.LinearizedTarget); pStack.Push(result); }