Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.TypeReference


          }
          String entryName = entry.getName();
          if (entryName.endsWith(".class")) {
            label.setText("Extracting: " + name);
            String internalName = StringUtilities.removeRight(entryName, ".class");
            TypeReference type = metadataSystem.lookupType(internalName);
            extractClassToTextPane(type, name, path);
          } else {
            label.setText("Opening: " + name);
            try (InputStream in = state.jarFile.getInputStream(entry);) {
              extractSimpleFileEntryToTextPane(in, name, path);
            }
          }
        }
      } else {
        name = file.getName();
        path = file.getPath().replaceAll("\\\\", "/");
        if (file.length() > MAX_UNPACKED_FILE_SIZE_BYTES) {
          throw new TooLargeFileException(file.length());
        }
        if (name.endsWith(".class")) {
          label.setText("Extracting: " + name);
          TypeReference type = metadataSystem.lookupType(path);
          extractClassToTextPane(type, name, path);
        } else {
          label.setText("Opening: " + name);
          try (InputStream in = new FileInputStream(file);) {
            extractSimpleFileEntryToTextPane(in, name, path);
View Full Code Here


    new Thread() {
      public void run() {
        try {
          Thread.sleep(500);
          String internalName = FindBox.class.getName();
          TypeReference type = metadataSystem.lookupType(internalName);
          TypeDefinition resolvedType = null;
          if ((type == null) || ((resolvedType = type.resolve()) == null)) {
            return;
          }
          StringWriter stringwriter = new StringWriter();
          settings.getLanguage().decompileType(resolvedType,
              new PlainTextOutput(stringwriter), decompilationOptions);
View Full Code Here

          //Duplicate
          if(history.add(etn)){
            out.putNextEntry(etn);
            try {
              String internalName = StringUtilities.removeRight(entry.getName(), ".class");
              TypeReference type = metadataSystem.lookupType(internalName);
              TypeDefinition resolvedType = null;
              if ((type == null) || ((resolvedType = type.resolve()) == null)) {
                throw new Exception("Unable to resolve type.");
              }
              Writer writer = new OutputStreamWriter(out);
              settings.getLanguage().decompileType(resolvedType,
                  new PlainTextOutput(writer), decompilationOptions);
View Full Code Here

  private void doSaveClassDecompiled(File inFile, File outFile) throws Exception {
    DecompilerSettings settings = cloneSettings();
    LuytenTypeLoader typeLoader = new LuytenTypeLoader();
    MetadataSystem metadataSystem = new MetadataSystem(typeLoader);
    TypeReference type = metadataSystem.lookupType(inFile.getCanonicalPath());

    DecompilationOptions decompilationOptions = new DecompilationOptions();
    decompilationOptions.setSettings(settings);
    decompilationOptions.setFullDecompilation(true);

    TypeDefinition resolvedType = null;
    if (type == null || ((resolvedType = type.resolve()) == null)) {
      throw new Exception("Unable to resolve type.");
    }
    StringWriter stringwriter = new StringWriter();
    settings.getLanguage().decompileType(resolvedType,
        new PlainTextOutput(stringwriter), decompilationOptions);
View Full Code Here

public final class AnnotationReader {
    public static CustomAnnotation read(final IMetadataScope scope, final Buffer input) {
        final int typeToken = input.readUnsignedShort();
        final int parameterCount = input.readUnsignedShort();
       
        final TypeReference annotationType = scope.lookupType(typeToken);
        final AnnotationParameter[] parameters = new AnnotationParameter[parameterCount];
       
        readParameters(parameters, scope, input, true);

        return new CustomAnnotation(annotationType, ArrayUtilities.asUnmodifiableList(parameters));
View Full Code Here

                return new ConstantAnnotationElement(constantValue);
            }

            case Enum: {
                final TypeReference enumType = scope.lookupType(input.readUnsignedShort());
                final String constantName = scope.lookupConstant(input.readUnsignedShort());
                return new EnumAnnotationElement(enumType, constantName);
            }

            case Array: {
                final AnnotationElement[] elements = new AnnotationElement[input.readUnsignedShort()];

                for (int i = 0; i < elements.length; i++) {
                    elements[i] = readElement(scope, input);
                }

                return new ArrayAnnotationElement(elements);
            }

            case Class: {
                final TypeReference type = scope.lookupType(input.readUnsignedShort());
                return new ClassAnnotationElement(type);
            }

            case Annotation: {
                final CustomAnnotation annotation = read(scope, input);
View Full Code Here

        }

        final Object parameter = t.getParameter();

        if (parameter instanceof Instruction) {
            final TypeReference initializedType = initializations.get(parameter);

            if (initializedType != null) {
                t = FrameValue.makeReference(initializedType);
            }
        }
View Full Code Here

        // Now, either sc is the last element of the list, or
        // it has type arguments (or both)
        assert (!(iter.hasNext()) || (sc.getTypeArguments().length > 0));
        // Create the raw type
        TypeReference c = getFactory().makeNamedType(n.toString());
        // if there are no type arguments
        if (sc.getTypeArguments().length == 0) {
            //we have surely reached the end of the path
            assert (!iter.hasNext());
            resultType = c; // the result is the raw type
        }
        else {
            assert (sc.getTypeArguments().length > 0);
            // otherwise, we have type arguments, so we create a parameterized
            // type, whose declaration is the raw type c, and whose owner is
            // the declaring class of c (if any). This latter fact is indicated
            // by passing null as the owner.
            // First, we reify the type arguments
            TypeReference[] pts = reifyTypeArguments(sc.getTypeArguments());

            TypeReference owner = getFactory().makeParameterizedType(c, null, pts);
            // phase 2: iterate over remaining simple class types
            while (iter.hasNext()) {
                sc = iter.next();
                dollar = sc.useDollar();
                n.append(dollar ? "$" : ".").append(sc.getName()); // build up raw class name
View Full Code Here

    }

    public void visitArrayTypeSignature(final ArrayTypeSignature a) {
        // extract and reify component type
        a.getComponentType().accept(this);
        final TypeReference ct = resultType;
        assert ct != null;
        resultType = getFactory().makeArrayType(ct);
    }
View Full Code Here

            if (!allVariables.isEmpty()) {
                for (final Variable variable : allVariables) {
                    output.writeDefinition(variable.getName(), variable);

                    final TypeReference type = variable.getType();

                    if (type != null) {
                        output.write(" : ");
                        DecompilerHelpers.writeType(output, type, NameSyntax.SHORT_TYPE_NAME);
                    }
View Full Code Here

TOP

Related Classes of com.strobel.assembler.metadata.TypeReference

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.