private Node transform(JsObjectLiteral x) { Node n = IR.objectlit(); for (Object element : x.getPropertyInitializers()) { JsPropertyInitializer propInit = (JsPropertyInitializer) element; Node key; if (propInit.getLabelExpr().getKind() == NodeKind.NUMBER) { key = transformNumberAsString((JsNumberLiteral) propInit.getLabelExpr()); key.putBooleanProp(Node.QUOTED_PROP, true); } else if (propInit.getLabelExpr().getKind() == NodeKind.NAME_REF) { key = transformNameAsString( ((JsNameRef) propInit.getLabelExpr()).getShortIdent(), propInit.getLabelExpr()); } else { key = transform(propInit.getLabelExpr()); } Preconditions.checkState(key.isString(), key); key.setType(Token.STRING_KEY); // Set as quoted as the rhino version we use does not distinguish one from the other. // Closure assumes unquoted property names are obfuscatable, but since there is no way to // distinguish between them at this point they have to be assumed quoted, hence not // obfuscatable. // TODO(rluble): Make sure this is handled correctly once rhino is upgraded. key.putBooleanProp(Node.QUOTED_PROP, true); n.addChildToBack(IR.propdef(key, transform(propInit.getValueExpr()))); } return applySourceInfo(n, x); }
private Node transform(JsCatch x) { Node n = IR.catchNode(transformName(x.getParameter().getName()), transform(x.getBody())); Preconditions.checkState(x.getCondition() == null); return applySourceInfo(n, x); }