Beispiel #1
0
 /** Produces a {@link JsNameRef}. */
 private JsNameRef mapAsPropertyNameRef(Node nameRefNode) throws JsParserException {
   JsNode unknown = map(nameRefNode);
   // This is weird, but for "a.b", the rhino AST calls "b" a string literal.
   // However, since we know it's for a PROPGET, we can unstringliteralize it.
   //
   if (unknown instanceof JsStringLiteral) {
     JsStringLiteral lit = (JsStringLiteral) unknown;
     return scopeContext.referenceFor(lit.getValue());
   } else {
     throw createParserException("Expecting a name reference", nameRefNode);
   }
 }
Beispiel #2
0
  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 = scopeContext.referenceFor((String) obj);
    }
    toNameRef.setQualifier(toQualifier);

    return toNameRef;
  }