private JsExpression mapNumber(Node numberNode) {
return program.getNumberLiteral(numberNode.getDouble());
}
private JsExpression mapObjectLit(Node objLitNode) throws JsParserException {
JsObjectLiteral toLit = new JsObjectLiteral(makeSourceInfo(objLitNode));
Node fromPropInit = objLitNode.getFirstChild();
while (fromPropInit != null) {
Node fromLabelExpr = fromPropInit;
JsExpression toLabelExpr = mapExpression(fromLabelExpr);
// Advance to the initializer expression.
//
fromPropInit = fromPropInit.getNext();
Node fromValueExpr = fromPropInit;
if (fromValueExpr == null) {
throw createParserException("Expected an init expression for: "
+ toLabelExpr, objLitNode);
}
JsExpression toValueExpr = mapExpression(fromValueExpr);
JsPropertyInitializer toPropInit = new JsPropertyInitializer(
makeSourceInfo(fromLabelExpr), toLabelExpr, toValueExpr);
toLit.getPropertyInitializers().add(toPropInit);
// Begin the next property initializer, if there is one.
//
fromPropInit = fromPropInit.getNext();
}