Examples of Sig


Examples of ch.epfl.lamp.compiler.msil.PEFile.Sig

                byte[] compressedUInt = compressUInt(blobArrWithLengthStripped.length);
                byte[] byteArr = new byte[blobArrWithLengthStripped.length + compressedUInt.length];
                System.arraycopy(compressedUInt, 0, byteArr, 0, compressedUInt.length);
                System.arraycopy(blobArrWithLengthStripped, 0, byteArr, compressedUInt.length, blobArrWithLengthStripped.length);
                ByteBuffer buf = ByteBuffer.wrap(byteArr);
                Sig sig = pefile.new Sig(buf);
                int desc = sig.readByte();

                switch (desc) {

                    // GENERICINST (CLASS | VALUETYPE) TypeDefOrRefEncodred GenArgCount Type*
                    case Signature.ELEMENT_TYPE_GENERICINST:      // i.e. 0x15
                        int b = sig.readByte(); // i.e. (0x12 | 0x11)
                        /* TODO don't ignore b as done above */
                        Type instantiatedType = getTypeDefOrRef(sig.decodeInt())// TypeDefOrRefEncoded
                        int numberOfTypeArgs = sig.decodeInt();    // GenArgCount
                        Type[] typeArgs = new Type[numberOfTypeArgs];
                        for (int iarg = 0; iarg < numberOfTypeArgs; iarg++) {
                            typeArgs[iarg] = sig.decodeType();       // Type*
                        }
                        type = new ConstructedType(instantiatedType, typeArgs);
                        break;

                    /* Miguel says: Actually the following grammar rule production is not among those for a TypeSpecBlob
                       but I've found it in assemblies compiled from C# 3.0.
                       See also duplicate code in PEFile.java */
                    case Signature.ELEMENT_TYPE_VAR:
                        int typeArgAsZeroBased = sig.decodeInt();
                        type = new Type.TMVarUsage(typeArgAsZeroBased, true);
                        break;

                    /* Miguel says: Actually the following grammar rule production is not among those for a TypeSpecBlob
                       but I've found it in assemblies compiled from C# 3.0.
                       See also duplicate code in PEFile.java */
                    case Signature.ELEMENT_TYPE_MVAR:
                        typeArgAsZeroBased = sig.decodeInt();
                        type = new Type.TMVarUsage(typeArgAsZeroBased, false);
                        break;

                    case Signature.ELEMENT_TYPE_SZARRAY:    // Single-dim array with 0 lower bound.
                        sig.skipCustomMods();
                        type = Type.mkArray(sig.decodeType(), 1);
                        break;

                    case Signature.ELEMENT_TYPE_ARRAY:
                        // <type> <rank> <boundsCount> <bound1> ... <loCount> <lo1> ...
                        // ArrayShape defined in 23.2.13 ArrayShape
                        Type elem = sig.decodeType();
                        int rank = sig.decodeInt();
                        int numSizes = sig.decodeInt();
                        for (int i = 0; i < numSizes; i++)
                            sig.decodeInt(); // TODO don't ignore
                        int numLoBounds = sig.decodeInt();
                        for (int i = 0; i < numLoBounds; i++)
                            sig.decodeInt(); // TODO don't ignore
                        type = Type.mkArray(elem, rank);
                        break;

                    default:
                        // TODO remaining grammar productions in 23.2.14 are for PTR and FNPTR only
View Full Code Here

Examples of ch.epfl.lamp.compiler.msil.PEFile.Sig

  switch (mtbl) {
  case TypeRef.ID:
      Type type = getTypeRef(mind, inAssembly);
            if (type == null)
                return null;
            Sig sig = mref.getSignature();
            int callconv = sig.readByte(); // should be 0x20
            int paramCount = sig.decodeInt();
      //sig.skipByte(Signature.ELEMENT_TYPE_BYREF); //from MethodDef
      Type retType = sig.decodeRetType();
      Type[] paramType = new Type[paramCount];
      for (int i = 0; i < paramCount; i++)
    paramType[i] = sig.decodeParamType();

            String memberName = mref.getName();
            if (memberName.equals(ConstructorInfo.CTOR) ||
                memberName.equals(ConstructorInfo.CCTOR))
            {
View Full Code Here

Examples of ch.epfl.lamp.compiler.msil.PEFile.Sig

      int frow = file.FieldTrans.rows == 0
    ? row : file.FieldTrans(row).Field;
      int attrs = file.FieldDef(frow).Flags;
      String name = file.FieldDef.getName();
      //System.out.println("\t-->Loading field: " + name);
      Sig sig = file.FieldDef.getSignature();
      PECustomMod pecmod = sig.decodeFieldType();
      Object val = null;
      Table.Constant consts = file.Constant;
      for (int i = 1; i <= consts.rows; i++) {
    consts.readRow(i);
    int tableId = Table.getTableId(Table._HasConstant,consts.Parent);
View Full Code Here

Examples of ch.epfl.lamp.compiler.msil.PEFile.Sig

  for (int row = methodListBeg; row < methodListEnd; row++) {
      int mrow = file.MethodTrans.rows == 0
    ? row : file.MethodTrans(row).Method;
      int attrs = file.MethodDef(mrow).Flags;
      String name = file.MethodDef.getName();
      Sig sig = file.MethodDef.getSignature();
            /* we're about to parse a MethodDefSig, defined in Sec. 23.2.1 of Partition II ()  */

      int callConv = sig.readByte();
            // TODO decode HASTHIS from high byte of calling convention
            // TODO decode EXPLICITTHIS from high byte of calling convention
            // TODO handle VARARG calling convention (not CLS but may show up )
            if((callConv & 0x1F) == Signature.GENERIC) {
                int genParamCount = sig.decodeInt();
                /* genParamCount is ignored because the method's type params will be obtained below
                (see: file.GenericParam.getMVarIdxes(row) ) */
            }
      int paramCount = sig.decodeInt();
      Type retType = sig.decodeRetType();
      Type[] paramType = new Type[paramCount];
      for (int i = 0; i < paramCount; i++)
    paramType[i] = sig.decodeParamType();

      ParameterInfo[] params = new ParameterInfo[paramCount];
      int paramListBeg = file.MethodDef.ParamList;
            int paramListEnd = paramListBeg + paramCount;
            if (paramListEnd > file.ParamDef.rows) {
View Full Code Here

Examples of ch.epfl.lamp.compiler.msil.PEFile.Sig

  }

  final ArrayList properties = new ArrayList();
        for (int i = propListBeg; i < propListEnd; i++) {
            pdef.readRow(i);
            Sig sig = pdef.getSignature();
            int b = sig.readByte();
            b &= ~HASTHIS;
            int paramCount = sig.readByte();
            assert b == PROPERTY;
            Type propType = sig.decodeType();
            int index = Table.encodeIndex(i, Table._HasSemantics,
                                          Table.PropertyDef.ID);
            MethodSemantics msem = file.MethodSemantics;
            MethodInfo getter = null, setter = null;
            for (int j = 1; j <= msem.rows; j++) {
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

  }

  private List<String> getClasses() {
    List<String> result = new ArrayList<String>();

    Sig sig = getSig("Class");
    List<String> classInstances = extractInstances(ans.eval(sig).toString());
    result.addAll(classInstances);

    return result;
  }
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

  }

  private TypeDeclaration getClass(String classId) {
    TypeDeclaration result = ast.newTypeDeclaration();

    Sig classSig = getSig("Class");
    SafeList<Field> classFields = classSig.getFields();
    Field classIdRelations = getField("id", classFields);
    Map<String, List<String>> classIdRel = getRelations(classIdRelations);

    Field classExtendRel = getField("extend", classFields);
    Map<String, List<String>> extendRel = getRelations(classExtendRel);
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

    Map<String, List<String>> methodsMap = getRelations(methodsRel);

    List<String> methods = methodsMap.get(classId);

    if (methods != null) {
      Sig methodSig = getSig("Method");
      SafeList<Field> mFields = methodSig.getFields();
      Field mIdRelations = getField("id", mFields);
      Map<String, List<String>> idRel = getRelations(mIdRelations);
      Field mArgRelations = getField("param", mFields);
      Map<String, List<String>> argRel = getRelations(mArgRelations);
      Field mVisRelations = getField("acc", mFields);
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

  private Expression getMethodBody(String bodyId, String classId) {

    // String instanceName = bodyId.replaceAll("_[0-9]", "");

    Sig s = null;
    SafeList<Field> sFields = null;

    // pega o nome da classe que contem o metodo para usar no qualified this
    Sig classSig = getSig("Class");
    SafeList<Field> classFields = classSig.getFields();
    Field classIdRelations = getField("id", classFields);
    Map<String, List<String>> classIdRel = getRelations(classIdRelations);

    //debug
//    System.out.println("Body id: " + bodyId);
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

    }

  }

  private boolean isInstanceOfType(String instance, String type) {
    Sig s = getSig(type);
   
    //debug
//    System.out.println("type: " + s);
   
    if (s == null)
      return false;

    SafeList<Field> sFields = s.getFields();
    Field idRelations = getField("id", sFields);
   
    //debug
//    System.out.println("sFieds: " + sFields);
//    System.out.println("idRelations: "  + idRelations);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.