Package ch.epfl.lamp.compiler.msil

Examples of ch.epfl.lamp.compiler.msil.Type$AuxAttr


    throw e;
      }
  }

  public Type decodeType0() {
      Type type = null;
      int desc = readByte();
      switch (desc) {
      case ELEMENT_TYPE_BOOLEAN:type = Type.GetType("System.Boolean"); break;
      case ELEMENT_TYPE_CHAR:   type = Type.GetType("System.Char"); break;
      case ELEMENT_TYPE_I1:     type = Type.GetType("System.SByte"); break;
      case ELEMENT_TYPE_U1:     type = Type.GetType("System.Byte"); break;
      case ELEMENT_TYPE_I2:     type = Type.GetType("System.Int16"); break;
      case ELEMENT_TYPE_U2:     type = Type.GetType("System.UInt16"); break;
      case ELEMENT_TYPE_I4:     type = Type.GetType("System.Int32"); break;
      case ELEMENT_TYPE_U4:     type = Type.GetType("System.UInt32"); break;
      case ELEMENT_TYPE_I8:     type = Type.GetType("System.Int64"); break;
      case ELEMENT_TYPE_U8:     type = Type.GetType("System.UInt64"); break;
      case ELEMENT_TYPE_R4:     type = Type.GetType("System.Single"); break;
      case ELEMENT_TYPE_R8:     type = Type.GetType("System.Double"); break;
      case ELEMENT_TYPE_OBJECT: type = Type.GetType("System.Object"); break;
      case ELEMENT_TYPE_STRING: type = Type.GetType("System.String"); break;
      case ELEMENT_TYPE_I:      type = Type.GetType("System.IntPtr"); break;
      case ELEMENT_TYPE_U:      type = Type.GetType("System.UIntPtr"); break;
      case ELEMENT_TYPE_PTR:        // Followed by <type> token.
    if (getByte() == ELEMENT_TYPE_VOID) {
        readByte();
        type = Type.mkPtr(Type.GetType("System.Void"));
    } else type = Type.mkPtr(decodeType());
    break;
        case ELEMENT_TYPE_BYREF:      /* although BYREF is not listed in 23.2.12. as possible alternative, this method is also called when parsing the signatures of a method param and a method return, which do allow for BYREF */
            type = Type.mkByRef(decodeType());
            break;
        case ELEMENT_TYPE_VALUETYPE:  // Followed by TypeDefOrRefEncoded
            assert true;
      case ELEMENT_TYPE_CLASS:
    // Followed by <type> token
    type = pemodule.getTypeDefOrRef(decodeInt());
    if (type == null) throw new RuntimeException();
    break;

      case ELEMENT_TYPE_SZARRAY:    // Single-dim array with 0 lower bound.
    skipCustomMods();
    type = Type.mkArray(decodeType(), 1);
    break;
      case ELEMENT_TYPE_ARRAY:
    // <type> <rank> <boundsCount> <bound1> ... <loCount> <lo1> ...
                    // ArrayShape defined in 23.2.13 ArrayShape
    Type elem = decodeType();
    int rank = decodeInt();
    int numSizes = decodeInt();
    for (int i = 0; i < numSizes; i++)
            decodeInt(); // TODO don't ignore
    int numLoBounds = decodeInt();
    for (int i = 0; i < numLoBounds; i++)
            decodeInt(); // TODO don't ignore
    type = Type.mkArray(elem, rank);
    break;

        // a grammar production from 23.2.12 Type
        // GENERICINST (CLASS | VALUETYPE) TypeDefOrRefEncoded GenArgCount Type*
        case ELEMENT_TYPE_GENERICINST:
            int b = readByte();
            /*- TODO don't ignore b as done above. Should .NET valuetypes be represented as Scala case classes? */
            Type instantiatedType = pemodule.getTypeDefOrRef(decodeInt());
            int numberOfTypeArgs = decodeInt();
            Type[] typeArgs = new Type[numberOfTypeArgs];
            for (int iarg = 0; iarg < numberOfTypeArgs; iarg++) {
                typeArgs[iarg] = decodeType();
            }
View Full Code Here


    } // decodeType0()

  public PECustomMod decodeFieldType() {
      skipByte(FIELD); // 0x06
      CustomModifier[] cmods = getCustomMods();
        Type fieldType = decodeType();
      return new PECustomMod(fieldType, cmods);
  }
View Full Code Here

    {
            boolean isREQD = (getByte() == ELEMENT_TYPE_CMOD_REQD); // 0x1f
                    // skip the tag 23.2.7
                    readByte();
                    // skip the TypeDefOrRefEncoded (23.2.8)
            Type ignored = pemodule.getTypeDefOrRef(decodeInt());
            if(isREQD) {
                // System.err.println("ELEMENT_TYPE_CMOD_REQD: " + ignored);
                // throw new RuntimeException("Reqired CMOD: " + ignored);
    }
  }
View Full Code Here

  public CustomModifier[] getCustomMods() {
      java.util.List/*<CustomModifier>*/ cmods = new java.util.LinkedList();
      while (getByte() == ELEMENT_TYPE_CMOD_OPT || getByte() == ELEMENT_TYPE_CMOD_REQD) {
        boolean isReqd = (getByte() == ELEMENT_TYPE_CMOD_REQD);
        readByte(); // tag 23.2.7
        Type t = pemodule.getTypeDefOrRef(decodeInt()); // TypeDefOrRefEncoded (23.2.8)
        cmods.add(new CustomModifier(isReqd, t));
      }
      CustomModifier[] res = (CustomModifier[])cmods.toArray(new CustomModifier[0]);
      return res;
  }
View Full Code Here

TOP

Related Classes of ch.epfl.lamp.compiler.msil.Type$AuxAttr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.