Java Code Examples for jdk.nashorn.internal.ir.LiteralNode#ArrayLiteralNode
The following examples show how to use
jdk.nashorn.internal.ir.LiteralNode#ArrayLiteralNode .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSONWriter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }
Example 2
Source File: JSONWriter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }
Example 3
Source File: JSONWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }
Example 4
Source File: JSONWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }
Example 5
Source File: JSONWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }
Example 6
Source File: JSONWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }
Example 7
Source File: JSONWriter.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { type("ArrayExpression"); comma(); array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions()); } else { type("Literal"); comma(); property("value"); final Object value = literalNode.getValue(); if (value instanceof RegexToken) { // encode RegExp literals as Strings of the form /.../<flags> final RegexToken regex = (RegexToken)value; final StringBuilder regexBuf = new StringBuilder(); regexBuf.append('/'); regexBuf.append(regex.getExpression()); regexBuf.append('/'); regexBuf.append(regex.getOptions()); buf.append(quote(regexBuf.toString())); } else { final String str = literalNode.getString(); // encode every String literal with prefix '$' so that script // can differentiate b/w RegExps as Strings and Strings. buf.append(literalNode.isString()? quote("$" + str) : str); } } return leave(); }