Package com.google.gwt.dev.js.ast

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


  @Override
  public boolean visit(JsBreak x, JsContext<JsStatement> ctx) {
    _break();

    JsNameRef label = x.getLabel();
    if (label != null) {
      _space();
      _nameRef(label);
    }
View Full Code Here


  @Override
  public boolean visit(JsContinue x, JsContext<JsStatement> ctx) {
    _continue();

    JsNameRef label = x.getLabel();
    if (label != null) {
      _space();
      _nameRef(label);
    }
View Full Code Here

     * throughout the AST, you can't just go and change their qualifiers when
     * re-writing an invocation.
     */
    @Override
    public void endVisit(JsNameRef x, JsContext<JsExpression> ctx) {
      JsNameRef toReturn = new JsNameRef(x.getName());

      if (x.getQualifier() != null) {
        toReturn.setQualifier(stack.pop());
      }
      stack.push(toReturn);
    }
View Full Code Here

    // However, since we know it's for a PROPGET, we can unstringliteralize it.
    //
    if (unknown instanceof JsStringLiteral) {
      JsStringLiteral lit = (JsStringLiteral) unknown;
      String litName = lit.getValue();
      return new JsNameRef(makeSourceInfo(nameRefNode), litName);
    } else {
      throw createParserException("Expecting a name reference", nameRefNode);
    }
  }
View Full Code Here

  private JsNameRef mapGetProp(Node getPropNode) throws JsParserException {
    Node from1 = getPropNode.getFirstChild();
    Node from2 = from1.getNext();

    JsExpression toQualifier = mapExpression(from1);
    JsNameRef toNameRef;
    if (from2 != null) {
      toNameRef = mapAsPropertyNameRef(from2);
    } else {
      // Special properties don't have a second expression.
      //
      Object obj = getPropNode.getProp(Node.SPECIAL_PROP_PROP);
      assert (obj instanceof String);
      toNameRef = new JsNameRef(makeSourceInfo(getPropNode), (String) obj);
    }
    toNameRef.setQualifier(toQualifier);

    return toNameRef;
  }
View Full Code Here

   * Creates a reference to a name that may or may not be obfuscatable, based on
   * whether it matches a known name in the scope.
   */
  private JsNameRef mapName(Node node) {
    String ident = node.getString();
    return new JsNameRef(makeSourceInfo(node), ident);
  }
View Full Code Here

  }

  private JsExpression mapSetProp(Node getPropNode) throws JsParserException {
    // Reuse the get prop code.
    //
    JsNameRef lhs = mapGetProp(getPropNode);

    // Map the RHS.
    //
    Node fromRhs = getPropNode.getFirstChild().getNext().getNext();
    JsExpression toRhs = mapExpression(fromRhs);
View Full Code Here

        // Use a clone instead of modifying the original JSNI
        // __gwt_makeTearOff(obj, dispId, paramCount)
        SourceInfo newSourceInfo = x.getSourceInfo().makeChild(getClass(),
            "Replace JSNI ref for hosted mode");
        JsInvocation rewritten = new JsInvocation(newSourceInfo);
        rewritten.setQualifier(new JsNameRef(newSourceInfo, "__gwt_makeTearOff"));

        List<JsExpression> arguments = rewritten.getArguments();
        if (q == null) {
          q = program.getNullLiteral();
        }
View Full Code Here

     * correctly on some browsers.
     */
    @Override
    public boolean visit(JsInvocation x, JsContext<JsExpression> ctx) {
      if (x.getQualifier() instanceof JsNameRef) {
        JsNameRef ref = (JsNameRef) x.getQualifier();
        String ident = ref.getIdent();
        if (ident.startsWith("@")) {
          int dispId = dispatchInfo.getDispId(ident);

          Member member;
          if (dispId < 0) {
            member = null;
          } else {
            member = dispatchInfo.getClassInfoByDispId(dispId).getMember(dispId);
          }

          /*
           * Make sure the ident is a reference to a method or constructor and
           * not a reference to a field whose contents (e.g. a Function) we
           * intend to immediately invoke.
           *
           * p.C::method()(); versus p.C::field();
           *
           * Also, if the reference was to a non-existent field, we'll go ahead
           * and rewrite the call site as though -1 is a valid dispid.
           */
          if (member == null || member instanceof Method
              || member instanceof Constructor) {

            // Use a clone instead of modifying the original JSNI
            // __gwt_makeJavaInvoke(paramCount)(obj, dispId, args)
            int paramCount = 0;
            if (member instanceof Method) {
              paramCount = ((Method) member).getParameterTypes().length;
            } else if (member instanceof Constructor) {
              paramCount = ((Constructor<?>) member).getParameterTypes().length;
            }

            SourceInfo newSourceInfo = x.getSourceInfo().makeChild(getClass(),
                "Replace JSNI ref for hosted mode");
            JsInvocation inner = new JsInvocation(newSourceInfo);
            inner.setQualifier(new JsNameRef(newSourceInfo,
                "__gwt_makeJavaInvoke"));
            inner.getArguments().add(program.getNumberLiteral(paramCount));

            JsInvocation outer = new JsInvocation(newSourceInfo);
            outer.setQualifier(inner);
            JsExpression q = ref.getQualifier();
            if (q == null) {
              q = program.getNullLiteral();
            }
            List<JsExpression> arguments = outer.getArguments();
            arguments.add(q);
View Full Code Here

      JsExpression expr = ((JsExprStmt) stat).getExpression();
      if (expr instanceof JsInvocation) {
        JsInvocation inv = (JsInvocation) expr;
        if (inv.getArguments().isEmpty()
            && (inv.getQualifier() instanceof JsNameRef)) {
          JsNameRef calleeRef = (JsNameRef) inv.getQualifier();
          if (calleeRef.getQualifier() == null) {
            return entryMethodNames.contains(calleeRef.getName());
          }
        }
      }
    }
    return false;
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.js.ast.JsNameRef

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.