Examples of JsScope


Examples of com.google.gwt.dev.js.ast.JsScope

      List<JsExpression> list, JsFunction context) {
    /*
     * If the caller contains no nested functions, none of its locals can
     * possibly be affected by side effects.
     */
    JsScope safeScope = null;
    if (context != null && !containsNestedFunctions(context)) {
      safeScope = context.getScope();
    }
    AffectedBySideEffectsVisitor v = new AffectedBySideEffectsVisitor(program,
        safeScope);
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

         * the same function has been inlined in multiple places within the
         * function so we'll use a counter for disambiguation.
         */
        String ident;
        int count = 0;
        JsScope scope = functionStack.peek().getScope();
        do {
          ident = f.getName() + "_" + name.getIdent() + "_" + count++;
        } while (scope.findExistingName(ident) != null);

        JsName newName = scope.declareName(ident, name.getShortIdent());
        v.setReplacementName(name, newName);
        nameIterator.set(newName);
      }
      op = v.accept(op);

View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

  public String optimizeJavaScript(TreeLogger logger, String program)
      throws UnableToCompleteException {
    logger = logger.branch(TreeLogger.DEBUG, "Attempting to optimize JS", null);
    Reader r = new StringReader(program);
    JsProgram jsProgram = new JsProgram();
    JsScope topScope = jsProgram.getScope();
    JsName funcName = topScope.declareName(getModuleFunctionName());
    funcName.setObfuscatable(false);

    try {
      SourceInfo sourceInfo = jsProgram.createSourceInfo(1,
          "StandardLinkerContext.optimizeJavaScript");
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

  public void testPackageInfo() throws Exception {
    // Synthesize a function definition with an illegal name, "package-info" like can result from
    // JDT compilation of package-info.java files.
    JsProgram jsProgram = new JsProgram();
    JsScope scope = jsProgram.getScope();

    // Function declaration statement.
    JsName name = scope.declareName("package-info", "package-info");
    List<JsStatement> statements = jsProgram.getFragment(0).getGlobalBlock().getStatements();
    final SourceOrigin sourceInfo = SourceOrigin.UNKNOWN;
    JsFunction function = new JsFunction(sourceInfo, scope, name);
    function.setBody(new JsBlock(sourceInfo));
    statements.add(new JsExprStmt(sourceInfo, function));
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

      gwtOnLoadName.setObfuscatable(false);
      JsFunction gwtOnLoad = new JsFunction(topScope, gwtOnLoadName, true);
      globalStmts.add(gwtOnLoad.makeStmt());
      JsBlock body = new JsBlock();
      gwtOnLoad.setBody(body);
      JsScope fnScope = gwtOnLoad.getScope();
      List<JsParameter> params = gwtOnLoad.getParameters();
      JsName errFn = fnScope.declareName("errFn");
      JsName modName = fnScope.declareName("modName");
      JsName modBase = fnScope.declareName("modBase");
      params.add(new JsParameter(errFn));
      params.add(new JsParameter(modName));
      params.add(new JsParameter(modBase));
      JsExpression asg = createAssignment(
          topScope.findExistingUnobfuscatableName("$moduleName").makeRef(),
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

    this.program = program;
    typeOracle = program.typeOracle;
    this.jsProgram = jsProgram;
    topScope = jsProgram.getScope();
    objectScope = jsProgram.getObjectScope();
    interfaceScope = new JsScope(objectScope, "Interfaces");
    this.output = output;

    /*
     * Because we modify String's prototype, all fields and polymorphic methods
     * on String's super types need special handling.
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

    }

    @Override
    public void endVisit(JLocal x, Context ctx) {
      // locals can conflict, that's okay just reuse the same variable
      JsScope scope = peek();
      JsName jsName = scope.declareName(x.getName());
      names.put(x, jsName);
    }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

    }

    @Override
    public boolean visit(JClassType x, Context ctx) {
      // have I already been visited as a super type?
      JsScope myScope = classScopes.get(x);
      if (myScope != null) {
        push(myScope);
        return false;
      }

      // My seed function name
      names.put(x, topScope.declareName(getNameString(x), x.getShortName()));

      // My class scope
      if (x.extnds == null) {
        myScope = objectScope;
      } else {
        JsScope parentScope = classScopes.get(x.extnds);
        // Run my superclass first!
        if (parentScope == null) {
          accept(x.extnds);
        }
        parentScope = classScopes.get(x.extnds);
        assert (parentScope != null);
        /*
         * WEIRD: we wedge the global interface scope in between object and all
         * of its subclasses; this ensures that interface method names trump all
         * (except Object method names)
         */
        if (parentScope == objectScope) {
          parentScope = interfaceScope;
        }
        myScope = new JsScope(parentScope, "class " + x.getShortName());
      }
      classScopes.put(x, myScope);

      push(myScope);
      return true;
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

      throws UnableToCompleteException {
    logger = logger.branch(TreeLogger.DEBUG, "Attempting to optimize JS", null);
    JsParser parser = new JsParser();
    Reader r = new StringReader(program);
    JsProgram jsProgram = new JsProgram();
    JsScope topScope = jsProgram.getScope();
    JsName funcName = topScope.declareName(getModuleFunctionName());
    funcName.setObfuscatable(false);

    try {
      parser.parseInto(topScope, jsProgram.getGlobalBlock(), r, 1);
    } catch (IOException e) {
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsScope

      List<JsExpression> list, JsFunction context) {
    /*
     * If the caller contains no nested functions, none of its locals can
     * possibly be affected by side effects.
     */
    JsScope safeScope = null;
    if (context != null && !containsNestedFunctions(context)) {
      safeScope = context.getScope();
    }
    AffectedBySideEffectsVisitor v = new AffectedBySideEffectsVisitor(program,
        safeScope);
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.