Base class for Method Descriptors
Inheritance: Member
Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 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);
 }
Example #4
0
        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);
        }
Example #5
0
        //////////////////////////////////////////////////////////////////////////
        // 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);
        }
Example #6
0
 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);
 }
Example #7
0
 /*-------------------- Constructors ---------------------------------*/
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     Constant[] val)
 {
     parent = paren;
     type = constrType;
     argVals = val;
     changed = true;
     sortTable = true;
     tabIx = MDTable.CustomAttribute;
 }
Example #8
0
 /// <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));
 }
Example #9
0
 /// <summary>
 /// Remove the specified method from this class
 /// </summary>
 /// <param name="meth">method descriptor</param>
 public void RemoveMethod(Method meth)
 {
     methods.Remove(meth);
 }
Example #10
0
 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;
 }
Example #11
0
 internal MethSig ReadMethSig(Method thisMeth, uint blobIx)
 {
     blob.GoToIndex(blobIx);
     uint blobSize = blob.ReadCompressedNum();
     return ReadMethSig(thisMeth,false);
 }
Example #12
0
        /// <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;
        }
Example #13
0
 /// <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));
 }
Example #14
0
 private void floatBox()
 {
     PERWAPI.Method m = emitter.findMethod("Fan.Sys.Double", "valueOf",
                                           new string[] { "System.Double" }, "Fan.Sys.Double");
     code.MethInst(MethodOp.call, m);
 }
Example #15
0
 private void intBox()
 {
     PERWAPI.Method m = emitter.findMethod("Fan.Sys.Long", "valueOf",
                                           new string[] { "System.Int64" }, "Fan.Sys.Long");
     code.MethInst(MethodOp.call, m);
 }
Example #16
0
 /// <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));
 }
Example #17
0
 /*-------------------- 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;
 }
Example #18
0
 /*-------------------- Constructors ---------------------------------*/
 public MethInstr(MethodOp inst, Method m)
     : base((uint)inst)
 {
     meth = m;
     size += 4;
 }
Example #19
0
        /// <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;
        }
Example #20
0
 public void SetMethod(Method mth)
 {
     meth = mth;
 }
Example #21
0
 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;
 }
Example #22
0
 /*-------------------- Constructors ---------------------------------*/
 internal MethodImpl(ClassDef par, Method decl, Method bod)
 {
     parent = par;
     header = decl;
     body = bod;
     tabIx = MDTable.MethodImpl;
 }
Example #23
0
 /// <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));
 }
Example #24
0
 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;
 }
Example #25
0
 internal void AddToMethodList(Method m)
 {
     m.SetParent(this);
     methods.Add(m);
 }
Example #26
0
 internal void ResolveMethDetails()
 {
     body = (Method)buffer.GetCodedElement(CIx.MethodDefOrRef,methBodyIx);
     header = (Method)buffer.GetCodedElement(CIx.MethodDefOrRef,methDeclIx);
     resolved = true;
 }
Example #27
0
 /*----------------------------- internal functions ------------------------------*/
 internal void AddMethod(Method meth)
 {
     methods.Add(meth);
     meth.SetParent(this);
 }
Example #28
0
 /*-------------------- Constructors ---------------------------------*/
 public MethodSpec(Method mParent, Type[] instTypes)
     : base(null)
 {
     this.methParent = mParent;
     this.instTypes = instTypes;
     tabIx = MDTable.MethodSpec;
 }
Example #29
0
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     byte[] val)
 {
     parent = paren;
     type = constrType;
     tabIx = MDTable.CustomAttribute;
     byteVal = val;
     sortTable = true;
     changed = true;
 }
Example #30
0
 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;
 }
Example #31
0
 internal void SetMethParam(Method paren,int ix)
 {
     typeIndex = MVAR;
     parent = paren;
     index = (ushort)ix;
 }
Example #32
0
 private void boolBox()
 {
     PERWAPI.Method m = emitter.findMethod("Fan.Sys.Boolean", "valueOf",
                                           new string[] { "System.Boolean" }, "Fan.Sys.Boolean");
     code.MethInst(MethodOp.call, m);
 }