Package com.google.caja.parser.quasiliteral

Examples of com.google.caja.parser.quasiliteral.Scope


   */
  public Block optimize(Block js, MessageQueue mq) {
    finishInference();
    while (true) {
      Result out = new Result();
      Scope s = Scope.fromProgram(js, mq);
      optimize(s, js, false, false, false, false, out);
      Block optimized = ConstLocalOptimization.optimize((Block) out.node);
      if (optimized == js) { return optimized; }
      js = optimized;
    }
View Full Code Here


      attachScopes(AncestorChain.instance(ac, cs.getBody()), scope);
      return false;
    } else if (n instanceof Reference) {
      Reference r = (Reference) n;
      String rName = r.getIdentifierName();
      Scope definingScope = scope.s.thatDefines(rName);
      assert (definingScope != null) || scope.s.isOuter(rName) : rName;
      scope.uses.add(new Use(scope.withScope(definingScope), rName));
      if ("eval".equals(rName)) { infected = true; }
      infected = infected || "eval".equals(rName);
    } else if (n instanceof Declaration) {
View Full Code Here

  private static void renameOne(MutableParseTreeNode n) {
    Identifier id = (Identifier) n.children().get(0);
    String origName = id.getName();
    ScopeInfo u = n.getAttributes().get(SCOPE);
    Scope s = (n instanceof FunctionConstructor)
        ? u.s :  u.s.thatDefines(origName);
    if (s != null) {  // Will be null for undeclared globals.
      String newName = u.withScope(s).mapping.get(origName);
      if (!newName.equals(origName)) {
        n.replaceChild(new Identifier(id.getFilePosition(), newName), id);
View Full Code Here

      attachScopes(AncestorChain.instance(ac, cs.getBody()), scope);
      return false;
    } else if (n instanceof Reference) {
      Reference r = (Reference) n;
      String rName = r.getIdentifierName();
      Scope definingScope = scope.s.thatDefines(rName);
      assert (definingScope != null) || scope.s.isOuter(rName) : rName;
      scope.uses.add(new Use(scope.withScope(definingScope), rName));
      if ("eval".equals(rName)) { infected = true; }
      infected = infected || "eval".equals(rName);
    } else if (n instanceof Declaration) {
View Full Code Here

  private static void renameOne(MutableParseTreeNode n) {
    Identifier id = (Identifier) n.children().get(0);
    String origName = id.getName();
    ScopeInfo u = n.getAttributes().get(SCOPE);
    Scope s = (n instanceof FunctionConstructor)
        ? u.s :  u.s.thatDefines(origName);
    if (s != null) {  // Will be null for undeclared globals.
      String newName = u.withScope(s).mapping.get(origName);
      if (!newName.equals(origName)) {
        n.replaceChild(new Identifier(id.getFilePosition(), newName), id);
View Full Code Here

   */
  public Block optimize(Block js, MessageQueue mq) {
    finishInference();
    while (true) {
      Result out = new Result();
      Scope s = Scope.fromProgram(js, new Rewriter(mq, false, false));
      optimize(s, js, false, false, false, false, out);
      Block optimized = ConstLocalOptimization.optimize((Block) out.node);
      if (optimized == js) { return optimized; }
      js = optimized;
    }
View Full Code Here

TOP

Related Classes of com.google.caja.parser.quasiliteral.Scope

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.