Examples of JTypeOracle


Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

    minimalRebuildCache.addTypeReference("com.some.app.SomeController",
        "com.some.app.SomeAModel");

    JsTypeLinker jsTypeLinker = new JsTypeLinker(TreeLogger.NULL,
        new JsNoopTransformer(originalJs, srb.build(), smb.build()), classRanges, programRange,
        minimalRebuildCache, new JTypeOracle(null, minimalRebuildCache, true));

    // Run the JS Type Linker.
    jsTypeLinker.exec();

    // Verify that the linker output all the expected classes and sorted them alphabetically.
    assertEquals("<preamble>\n<java.lang.Object />\n<java.lang.Class />\n</preamble>\n"
        + "<com.some.app.EntryPoint>\n" + "<com.some.app.SomeModelA>\n"
        + "<com.some.app.SomeModelB>\n" + "<com.some.app.SomeController>\n"
        + "<epilogue>\n<Some Bootstrap Code>\n</epilogue>\n", jsTypeLinker.getJs());
    assertEquals(Lists.newArrayList("preamble", "java.lang.Object", "java.lang.Class", "/preamble",
        "com.some.app.EntryPoint", "com.some.app.SomeModelA", "com.some.app.SomeModelB",
        "com.some.app.SomeController", "epilogue", "Some Bootstrap Code", "/epilogue"),
        getTypeNames(jsTypeLinker.getSourceInfoMap()));
    assertEquals(11, jsTypeLinker.getSourceInfoMap().getLines());

    // Make SomeModelB the super class of SomeModelA and then verify that B comes out before A.
    superClassesByClass.put("com.some.app.SomeAModel", "com.some.app.SomeBModel");
    jsTypeLinker = new JsTypeLinker(TreeLogger.NULL,
        new JsNoopTransformer(originalJs, srb.build(), smb.build()), classRanges, programRange,
        minimalRebuildCache, new JTypeOracle(null, minimalRebuildCache, true));
    jsTypeLinker.exec();
    assertEquals("<preamble>\n<java.lang.Object />\n<java.lang.Class />\n</preamble>\n"
        + "<com.some.app.EntryPoint>\n" + "<com.some.app.SomeModelB>\n"
        + "<com.some.app.SomeModelA>\n" + "<com.some.app.SomeController>\n"
        + "<epilogue>\n<Some Bootstrap Code>\n</epilogue>\n", jsTypeLinker.getJs());
    assertEquals(Lists.newArrayList("preamble", "java.lang.Object", "java.lang.Class", "/preamble",
        "com.some.app.EntryPoint", "com.some.app.SomeModelB", "com.some.app.SomeModelA",
        "com.some.app.SomeController", "epilogue", "Some Bootstrap Code", "/epilogue"),
        getTypeNames(jsTypeLinker.getSourceInfoMap()));
    assertEquals(11, jsTypeLinker.getSourceInfoMap().getLines());

    // Stop referring to SomeModelA from the Controller and verify that SomeModelA is not in the
    // output.
    minimalRebuildCache.removeReferencesFrom("com.some.app.SomeController");
    minimalRebuildCache.addTypeReference("com.some.app.SomeController",
        "com.some.app.SomeBModel");
    jsTypeLinker = new JsTypeLinker(TreeLogger.NULL,
        new JsNoopTransformer(originalJs, srb.build(), smb.build()), classRanges, programRange,
        minimalRebuildCache, new JTypeOracle(null, minimalRebuildCache, true));
    jsTypeLinker.exec();
    assertEquals("<preamble>\n<java.lang.Object />\n<java.lang.Class />\n</preamble>\n"
        + "<com.some.app.EntryPoint>\n" + "<com.some.app.SomeModelB>\n"
        + "<com.some.app.SomeController>\n" + "<epilogue>\n<Some Bootstrap Code>\n</epilogue>\n",
        jsTypeLinker.getJs());
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

    minimalRebuildCache.setRootTypeNames(Sets.newHashSet("Foo", "Bar", "Baz"));
    minimalRebuildCache.computeReachableTypeNames();

    // Request clearing of cache related to stale types.
    minimalRebuildCache.computeAndClearStaleTypesCache(TreeLogger.NULL,
        new JTypeOracle(null, minimalRebuildCache, true));

    // Has the expected JS been cleared?
    assertNull(minimalRebuildCache.getJs("Foo"));
    assertNull(minimalRebuildCache.getJs("Foo$Inner"));
    assertNull(minimalRebuildCache.getJs("Bar"));
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

      JReferenceType fromType = (JReferenceType) argType;

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
      if (typeOracle.canTriviallyCast(fromType, toType)) {
        triviallyTrue = true;
      } else if (!typeOracle.isInstantiatedType(toType)) {
        triviallyFalse = true;
      } else if (!typeOracle.canTheoreticallyCast(fromType, toType)) {
        triviallyFalse = true;
      }

      if (triviallyTrue) {
        // remove the cast operation
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

      JReferenceType fromType = (JReferenceType) argType;

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
      if (fromType == program.getTypeNull()) {
        // null is never instanceof anything
        triviallyFalse = true;
      } else if (typeOracle.canTriviallyCast(fromType, toType)) {
        triviallyTrue = true;
      } else if (!typeOracle.isInstantiatedType(toType)) {
        triviallyFalse = true;
      } else if (!typeOracle.canTheoreticallyCast(fromType, toType)) {
        triviallyFalse = true;
      }

      if (triviallyTrue) {
        // replace with a simple null test
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

      }

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
      if (typeOracle.canTriviallyCast(fromType, toType)) {
        triviallyTrue = true;
      } else if (!typeOracle.isInstantiatedType(toType)) {
        triviallyFalse = true;
      } else if (!typeOracle.canTheoreticallyCast(fromType, toType)) {
        triviallyFalse = true;
      }

      if (triviallyTrue) {
        // remove the cast operation
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

      }

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
      if (typeOracle.canTriviallyCast(fromType, toType)) {
        triviallyTrue = true;
      } else if (!typeOracle.isInstantiatedType(toType)) {
        triviallyFalse = true;
      } else if (!typeOracle.canTheoreticallyCast(fromType, toType)) {
        triviallyFalse = true;
      }

      if (triviallyTrue) {
        // remove the cast operation
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

      }

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
      if (fromType == program.getTypeNull()) {
        // null is never instanceof anything
        triviallyFalse = true;
      } else if (typeOracle.canTriviallyCast(fromType, toType)) {
        triviallyTrue = true;
      } else if (!typeOracle.isInstantiatedType(toType)) {
        triviallyFalse = true;
      } else if (!typeOracle.canTheoreticallyCast(fromType, toType)) {
        triviallyFalse = true;
      }

      if (triviallyTrue) {
        // replace with a simple null test
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

        /*
         * For every instantiated array type that could -in theory- be the
         * runtime type of the lhs, we must record a cast from the rhs to the
         * prospective element type of the lhs.
         */
        JTypeOracle typeOracle = program.typeOracle;
        JType rhsType = x.getRhs().getType();
        assert (rhsType instanceof JReferenceType);

        JArrayType lhsArrayType = lhsArrayRef.getArrayType();
        for (JArrayType arrayType : instantiatedArrayTypes) {
          if (typeOracle.canTheoreticallyCast(arrayType, lhsArrayType)) {
            JType itElementType = arrayType.getElementType();
            if (itElementType instanceof JReferenceType) {
              recordCast(itElementType, x.getRhs());
            }
          }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

        /*
         * For every instantiated array type that could -in theory- be the
         * runtime type of the lhs, we must record a cast from the rhs to the
         * prospective element type of the lhs.
         */
        JTypeOracle typeOracle = program.typeOracle;
        JType rhsType = x.getRhs().getType();
        assert (rhsType instanceof JReferenceType);

        JArrayType lhsArrayType = lhsArrayRef.getArrayType();
        for (JArrayType arrayType : instantiatedArrayTypes) {
          if (typeOracle.canTheoreticallyCast(arrayType, lhsArrayType)) {
            JType itElementType = arrayType.getElementType();
            if (itElementType instanceof JReferenceType) {
              recordCast(itElementType, x.getRhs());
            }
          }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JTypeOracle

      }

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
      if (typeOracle.canTriviallyCast(fromType, toType)) {
        triviallyTrue = true;
      } else if (!typeOracle.isInstantiatedType(toType)) {
        triviallyFalse = true;
      } else if (!typeOracle.canTheoreticallyCast(fromType, toType)) {
        triviallyFalse = true;
      }

      if (triviallyTrue) {
        // remove the cast operation
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.