use of org.mozilla.javascript.ast.XmlPropRef in project HL4A by HL4A.
the class IRFactory method transformXmlRef.
private Node transformXmlRef(Node pn, XmlRef node, int memberTypeFlags) {
if ((memberTypeFlags & Node.ATTRIBUTE_FLAG) != 0)
decompiler.addToken(Token.XMLATTR);
Name namespace = node.getNamespace();
String ns = namespace != null ? namespace.getIdentifier() : null;
if (ns != null) {
decompiler.addName(ns);
decompiler.addToken(Token.COLONCOLON);
}
if (node instanceof XmlPropRef) {
String name = ((XmlPropRef) node).getPropName().getIdentifier();
decompiler.addName(name);
return createPropertyGet(pn, ns, name, memberTypeFlags);
} else {
decompiler.addToken(Token.LB);
Node expr = transform(((XmlElemRef) node).getExpression());
decompiler.addToken(Token.RB);
return createElementGet(pn, ns, expr, memberTypeFlags);
}
}
use of org.mozilla.javascript.ast.XmlPropRef in project HL4A by HL4A.
the class Parser method propertyName.
/**
* Check if :: follows name in which case it becomes a qualified name.
*
* @param atPos a natural number if we just read an '@' token, else -1
*
* @param s the name or string that was matched (an identifier, "throw" or
* "*").
*
* @param memberTypeFlags flags tracking whether we're a '.' or '..' child
*
* @return an XmlRef node if it's an attribute access, a child of a
* '..' operator, or the name is followed by ::. For a plain name,
* returns a Name node. Returns an ErrorNode for malformed XML
* expressions. (For now - might change to return a partial XmlRef.)
*/
private AstNode propertyName(int atPos, String s, int memberTypeFlags) throws IOException {
int pos = atPos != -1 ? atPos : ts.tokenBeg, lineno = ts.lineno;
int colonPos = -1;
Name name = createNameNode(true, currentToken);
Name ns = null;
if (matchToken(Token.COLONCOLON)) {
ns = name;
colonPos = ts.tokenBeg;
switch(nextToken()) {
// handles name::name
case Token.NAME:
name = createNameNode();
break;
// handles name::*
case Token.MUL:
saveNameTokenData(ts.tokenBeg, "*", ts.lineno);
name = createNameNode(false, -1);
break;
// handles name::[expr] or *::[expr]
case Token.LB:
return xmlElemRef(atPos, ns, colonPos);
default:
reportError("msg.no.name.after.coloncolon");
return makeErrorNode();
}
}
if (ns == null && memberTypeFlags == 0 && atPos == -1) {
return name;
}
XmlPropRef ref = new XmlPropRef(pos, getNodeEnd(name) - pos);
ref.setAtPos(atPos);
ref.setNamespace(ns);
ref.setColonPos(colonPos);
ref.setPropName(name);
ref.setLineno(lineno);
return ref;
}
Aggregations