Example #1
0
  private ResolvedType resolveGep(Type baseType, EList<? extends EObject> indices) {
    ResolvedType result = resolve(baseType);
    if (result.isVector()) {
      return result;
    }

    if (result.isPointer() == false) {
      // That's not legal
      return TYPE_UNKNOWN;
    }

    BigInteger addrSpace = result.asPointer().getAddrSpace();

    for (EObject index : indices) {
      Integer indexValue = 0;
      if (result.isStruct()) {
        indexValue = constResolver.getInteger(index);
        if (indexValue == null) {
          // We could not resolve the index constant, so we cannot tell what the type is.
          return TYPE_ANY;
        }
      }
      result = result.getContainedType(indexValue);
      if (result == null) return null;
    }

    return new ResolvedPointerType(result, addrSpace);
  }
Example #2
0
  @Override
  public ResolvedType caseInstruction_extractvalue(Instruction_extractvalue object) {
    ResolvedType result = resolve(object.getAggregate().getType());

    for (Constant index : object.getIndices()) {
      Integer indexValue = constResolver.getInteger(index);
      if (indexValue == null) {
        // We could not resolve the index constant, so we cannot tell what the type is.
        return TYPE_ANY;
      }
      result = result.getContainedType(indexValue);
      if (result == null) return null;
    }

    return result;
  }