Base class for Method Descriptors
상속: Member
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
        }
예제 #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);
        }
예제 #6
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 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);
 }
예제 #7
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /*-------------------- Constructors ---------------------------------*/
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     Constant[] val)
 {
     parent = paren;
     type = constrType;
     argVals = val;
     changed = true;
     sortTable = true;
     tabIx = MDTable.CustomAttribute;
 }
예제 #8
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /// <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));
 }
예제 #9
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /// <summary>
 /// Remove the specified method from this class
 /// </summary>
 /// <param name="meth">method descriptor</param>
 public void RemoveMethod(Method meth)
 {
     methods.Remove(meth);
 }
예제 #10
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 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;
 }
예제 #11
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 internal MethSig ReadMethSig(Method thisMeth, uint blobIx)
 {
     blob.GoToIndex(blobIx);
     uint blobSize = blob.ReadCompressedNum();
     return ReadMethSig(thisMeth,false);
 }
예제 #12
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
        /// <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;
        }
예제 #13
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /// <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));
 }
예제 #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);
 }
예제 #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);
 }
예제 #16
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /// <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));
 }
예제 #17
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /*-------------------- 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;
 }
예제 #18
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /*-------------------- Constructors ---------------------------------*/
 public MethInstr(MethodOp inst, Method m)
     : base((uint)inst)
 {
     meth = m;
     size += 4;
 }
예제 #19
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
        /// <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;
        }
예제 #20
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 public void SetMethod(Method mth)
 {
     meth = mth;
 }
예제 #21
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 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;
 }
예제 #22
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /*-------------------- Constructors ---------------------------------*/
 internal MethodImpl(ClassDef par, Method decl, Method bod)
 {
     parent = par;
     header = decl;
     body = bod;
     tabIx = MDTable.MethodImpl;
 }
예제 #23
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /// <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));
 }
예제 #24
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 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;
 }
예제 #25
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 internal void AddToMethodList(Method m)
 {
     m.SetParent(this);
     methods.Add(m);
 }
예제 #26
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 internal void ResolveMethDetails()
 {
     body = (Method)buffer.GetCodedElement(CIx.MethodDefOrRef,methBodyIx);
     header = (Method)buffer.GetCodedElement(CIx.MethodDefOrRef,methDeclIx);
     resolved = true;
 }
예제 #27
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /*----------------------------- internal functions ------------------------------*/
 internal void AddMethod(Method meth)
 {
     methods.Add(meth);
     meth.SetParent(this);
 }
예제 #28
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 /*-------------------- Constructors ---------------------------------*/
 public MethodSpec(Method mParent, Type[] instTypes)
     : base(null)
 {
     this.methParent = mParent;
     this.instTypes = instTypes;
     tabIx = MDTable.MethodSpec;
 }
예제 #29
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     byte[] val)
 {
     parent = paren;
     type = constrType;
     tabIx = MDTable.CustomAttribute;
     byteVal = val;
     sortTable = true;
     changed = true;
 }
예제 #30
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 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;
 }
예제 #31
0
파일: PERWAPI.cs 프로젝트: nomit007/f4
 internal void SetMethParam(Method paren,int ix)
 {
     typeIndex = MVAR;
     parent = paren;
     index = (ushort)ix;
 }
예제 #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);
 }