private void floatUnbox(bool cast) { PERWAPI.Method m = emitter.findMethod("Fan.Sys.Double", "doubleValue", new string[0], "System.Double"); m.AddCallConv(CallConv.Instance); code.MethInst(MethodOp.call, m); }
private void intUnbox(bool cast) { PERWAPI.Method m = emitter.findMethod("Fan.Sys.Long", "longValue", new string[0], "System.Int64"); m.AddCallConv(CallConv.Instance); code.MethInst(MethodOp.call, m); }
private void boolUnbox(bool cast) { PERWAPI.Method m = emitter.findMethod("Fan.Sys.Boolean", "booleanValue", new string[0], "System.Boolean"); m.AddCallConv(CallConv.Instance); code.MethInst(MethodOp.call, m); }
private void doCompare(string suffix, FTypeRef lhs, FTypeRef rhs) { // get lhs and rhs types string[] args = new string[] { lhs.isRef() ? "System.Object" : lhs.nname(), rhs.isRef() ? "System.Object" : rhs.nname() }; string ret = (suffix == "") ? "System.Int64" : "System.Boolean"; PERWAPI.Method m = emitter.findMethod("Fanx.Util.OpUtil", "compare" + suffix, args, ret); code.MethInst(MethodOp.call, m); }
////////////////////////////////////////////////////////////////////////// // Compare ////////////////////////////////////////////////////////////////////////// private void compareEQ() { FTypeRef lhs = pod.typeRef(u2()); FTypeRef rhs = pod.typeRef(u2()); // if this is a.equals(b) and we know a is non-null, then just call equals if (lhs.isRef() && !lhs.isNullable() && rhs.isRef()) { PERWAPI.Method m = emitter.findMethod("System.Object", "Equals", new string[] { "System.Object" }, "System.Boolean"); m.AddCallConv(CallConv.Instance); code.MethInst(MethodOp.callvirt, m); return; } doCompare("EQ", lhs, rhs); }
internal override void Resolve(PEReader buff) { parent = buff.GetCodedElement(CIx.HasCustomAttr,parentIx); if (parent == null) return; parent.AddCustomAttribute(this); type = (Method)buff.GetCodedElement(CIx.CustomAttributeType,typeIx); byteVal = buff.GetBlob(valIx); }
/*-------------------- Constructors ---------------------------------*/ internal CustomAttribute(MetaDataElement paren, Method constrType, Constant[] val) { parent = paren; type = constrType; argVals = val; changed = true; sortTable = true; tabIx = MDTable.CustomAttribute; }
/// <summary> /// Use a method as the implementation for another method (.override) /// </summary> /// <param name="decl">the method to be overridden</param> /// <param name="body">the implementation to be used</param> public void AddMethodOverride(Method decl, Method body) { methodImpls.Add(new MethodImpl(this,decl,body)); }
/// <summary> /// Remove the specified method from this class /// </summary> /// <param name="meth">method descriptor</param> public void RemoveMethod(Method meth) { methods.Remove(meth); }
private MethSig ReadMethSig(Method currMeth, bool firstByteRead) { //Class currClass = null; //if (currMeth != null) currClass = (Class)currMeth.GetParent(); MethSig meth = new MethSig(null); if (!firstByteRead) { byte firstByte = blob.ReadByte(); if (firstByte == Field.FieldTag) return null; meth.callConv =(CallConv)firstByte; } if ((meth.callConv & CallConv.Generic) != 0){ meth.numGenPars = blob.ReadCompressedNum(); if (currMeth is MethodRef) { ((MethodRef)currMeth).MakeGenericPars(meth.numGenPars); } //else if (currMeth is MethodDef) { //GetGenericParams((MethodDef)currMeth); //} } uint parCount = blob.ReadCompressedNum(); if (Diag.DiagOn) Console.WriteLine("Method sig has " + parCount + " parameters"); meth.retType = GetBlobType();//currClass,currMeth); if (meth.retType == null) System.Diagnostics.Debug.Assert(meth.retType != null); int optParStart = -1; ArrayList pTypes = new ArrayList(); for (int i=0; i < parCount; i++) { Type pType = GetBlobType();//currClass,currMeth); if (pType == sentinel) { optParStart = i; pType = GetBlobType();//currClass,currMeth); } if (Diag.DiagOn) if (pType == null) Console.WriteLine("Param type is null"); pTypes.Add(pType); } if (optParStart > -1) { meth.numPars = (uint)optParStart; meth.numOptPars = parCount - meth.numPars; meth.optParTypes = new Type[meth.numOptPars]; for (int i=0; i < meth.numOptPars; i++) { meth.optParTypes[i] = (Type)pTypes[i+optParStart]; } } else meth.numPars = parCount; meth.parTypes = new Type[meth.numPars]; for (int i=0; i < meth.numPars; i++) { meth.parTypes[i] = (Type)pTypes[i]; } return meth; }
internal MethSig ReadMethSig(Method thisMeth, uint blobIx) { blob.GoToIndex(blobIx); uint blobSize = blob.ReadCompressedNum(); return ReadMethSig(thisMeth,false); }
/// <summary> /// Close the current method. /// </summary> public void CloseMethod() { // Make sure a method is open if (currentMethod == null) throw new Exception("No methods currently open."); // Check to make sure all scopes have been closed. if (currentScope != null) throw new Exception("Can not close method until all scopes are closed. Method Token: " + currentMethod.Token.ToString()); // Change the current method to null currentMethod = null; }
/// <summary> /// Add a custom attribute to this item /// </summary> /// <param name="ctorMeth">the constructor method for this attribute</param> /// <param name="val">the byte value of the parameters</param> public void AddCustomAttribute(Method ctorMeth, byte[] val) { if (customAttributes == null) { customAttributes = new ArrayList(); } customAttributes.Add(new CustomAttribute(this,ctorMeth,val)); }
private void floatBox() { PERWAPI.Method m = emitter.findMethod("Fan.Sys.Double", "valueOf", new string[] { "System.Double" }, "Fan.Sys.Double"); code.MethInst(MethodOp.call, m); }
private void intBox() { PERWAPI.Method m = emitter.findMethod("Fan.Sys.Long", "valueOf", new string[] { "System.Int64" }, "Fan.Sys.Long"); code.MethInst(MethodOp.call, m); }
/// <summary> /// Add a custom attribute to this item /// </summary> /// <param name="ctorMeth">the constructor method for this attribute</param> /// <param name="cVals">the constant values of the parameters</param> public void AddCustomAttribute(Method ctorMeth, Constant[] cVals) { if (customAttributes == null) { customAttributes = new ArrayList(); } customAttributes.Add(new CustomAttribute(this,ctorMeth,cVals)); }
/*-------------------- Constructors ---------------------------------*/ /// <summary> /// Create a new function pointer type /// </summary> /// <param name="meth">the function to be referenced</param> public MethPtrType(Method meth) : base((byte)ElementType.FnPtr) { this.meth = meth; }
/*-------------------- Constructors ---------------------------------*/ public MethInstr(MethodOp inst, Method m) : base((uint)inst) { meth = m; size += 4; }
/// <summary> /// Open a method. Scopes and sequence points will be added to this method. /// </summary> /// <param name="token">The token for this method.</param> public void OpenMethod(int token) { // Add this new method to the list of methods Method meth = new Method(); meth.Token = new SymbolToken(token); methods.Add(meth); // Set the current method currentMethod = meth; }
public void SetMethod(Method mth) { meth = mth; }
internal MethSig ReadMethSig(Method thisMeth, string name, uint blobIx) { blob.GoToIndex(blobIx); uint blobSize = blob.ReadCompressedNum(); MethSig mSig = ReadMethSig(thisMeth,false); mSig.name = name; return mSig; }
/*-------------------- Constructors ---------------------------------*/ internal MethodImpl(ClassDef par, Method decl, Method bod) { parent = par; header = decl; body = bod; tabIx = MDTable.MethodImpl; }
/// <summary> /// Add an instruction with a method parameter /// </summary> /// <param name="inst">the CIL instruction</param> /// <param name="m">the method parameter</param> public void MethInst(MethodOp inst, Method m) { Debug.Assert(m != null); if (m is MethodDef) if (((MethodDef)m).GetScope() != thisMeth.GetScope()) throw new DescriptorException(); AddToBuffer(new MethInstr(inst,m)); }
internal override void Resolve(PEReader buff) { body = (Method)buff.GetCodedElement(CIx.MethodDefOrRef,methBodyIx); header = (Method)buff.GetCodedElement(CIx.MethodDefOrRef,methDeclIx); parent = (ClassDef)buff.GetElement(MDTable.TypeDef,classIx); parent.AddMethodImpl(this); resolved = true; }
internal void AddToMethodList(Method m) { m.SetParent(this); methods.Add(m); }
internal void ResolveMethDetails() { body = (Method)buffer.GetCodedElement(CIx.MethodDefOrRef,methBodyIx); header = (Method)buffer.GetCodedElement(CIx.MethodDefOrRef,methDeclIx); resolved = true; }
/*----------------------------- internal functions ------------------------------*/ internal void AddMethod(Method meth) { methods.Add(meth); meth.SetParent(this); }
/*-------------------- Constructors ---------------------------------*/ public MethodSpec(Method mParent, Type[] instTypes) : base(null) { this.methParent = mParent; this.instTypes = instTypes; tabIx = MDTable.MethodSpec; }
internal CustomAttribute(MetaDataElement paren, Method constrType, byte[] val) { parent = paren; type = constrType; tabIx = MDTable.CustomAttribute; byteVal = val; sortTable = true; changed = true; }
internal override void Resolve(PEReader buff) { methParent = (Method)buff.GetCodedElement(CIx.MethodDefOrRef,parentIx); buff.currentMethodScope = methParent; // set scopes - Fix by CK buff.currentClassScope = (Class)methParent.GetParent(); instTypes = buff.ReadMethSpecSig(instIx); this.unresolved = false; buff.currentMethodScope = null; buff.currentClassScope = null; }
internal void SetMethParam(Method paren,int ix) { typeIndex = MVAR; parent = paren; index = (ushort)ix; }
private void boolBox() { PERWAPI.Method m = emitter.findMethod("Fan.Sys.Boolean", "valueOf", new string[] { "System.Boolean" }, "Fan.Sys.Boolean"); code.MethInst(MethodOp.call, m); }