private String getJavaMethod(AstNode node) { if (!(node instanceof StringLiteral)) { return null; } String str = ((StringLiteral) node).getValue(); if (!str.startsWith("$$JSO$$_")) { return null; } return str.substring("$$JSO$$_".length()); }
public ASTStringLiteral(StringLiteral stringLiteral) { super(stringLiteral); super.setImage(stringLiteral.getValue()); }
private void print(StringLiteral node) throws IOException { writer.append(node.getQuoteCharacter()); writer.append(ScriptRuntime.escapeString(node.getValue(), node.getQuoteCharacter())); writer.append(node.getQuoteCharacter()); }
private String getJavaMethod(AstNode node) { if (!(node instanceof StringLiteral)) { return null; } String str = ((StringLiteral) node).getValue(); if (!str.startsWith("$$JSO$$_")) { return null; } return str.substring("$$JSO$$_".length()); }
/** * Return string literal value. */ private String stringLiteral(final AstNode node) { checkState(node instanceof StringLiteral, node, "Expected string literal only"); //noinspection ConstantConditions StringLiteral string = (StringLiteral) node; return string.getValue(); }
private String getDirective(AstNode n) { if (n instanceof ExpressionStatement) { AstNode e = ((ExpressionStatement) n).getExpression(); if (e instanceof StringLiteral) { return ((StringLiteral) e).getValue(); } } return null; }
private String getDirective(AstNode n) { if (n instanceof ExpressionStatement) { AstNode e = ((ExpressionStatement) n).getExpression(); if (e instanceof StringLiteral) { return ((StringLiteral) e).getValue(); } } return null; }
private String getDirective(AstNode n) { if (n instanceof ExpressionStatement) { AstNode e = ((ExpressionStatement) n).getExpression(); if (e instanceof StringLiteral) { return ((StringLiteral) e).getValue(); } } return null; }
private String getDirective(AstNode n) { if (n instanceof ExpressionStatement) { AstNode e = ((ExpressionStatement) n).getExpression(); if (e instanceof StringLiteral) { return ((StringLiteral) e).getValue(); } } return null; }
@Override public CAstNode visitStringLiteral(StringLiteral node, WalkContext arg) { return Ast.makeConstant(node.getValue()); }
/** * Property keys in object literals can be identifiers or string literals. * This method takes an AST node that was the key of an * <code>ObjectProperty</code> and returns its value, no matter what the * concrete AST node's type. * * @param propKeyNode The AST node for the property key. * @return The property key's value. */ public static String getPropertyName(AstNode propKeyNode) { // TODO: Does Rhino use any other node type for this? return (propKeyNode instanceof Name) ? ((Name)propKeyNode).getIdentifier() : ((StringLiteral)propKeyNode).getValue(); }
/** * Find the textual name of the given node. */ @Nullable private String nameOf(final AstNode node) { if (node instanceof Name) { return ((Name) node).getIdentifier(); } else if (node instanceof PropertyGet) { PropertyGet prop = (PropertyGet) node; return String.format("%s.%s", nameOf(prop.getTarget()), nameOf(prop.getProperty())); } else if (node instanceof StringLiteral) { return ((StringLiteral) node).getValue(); } return null; }
private boolean extractMethodName(AstNode node, StringBuilder sb) { if (node.getType() == Token.ADD) { InfixExpression infix = (InfixExpression) node; return extractMethodName(infix.getLeft(), sb) && extractMethodName(infix.getRight(), sb); } else if (node.getType() == Token.STRING) { sb.append(((StringLiteral) node).getValue()); return true; } else { return false; } }
private void print(StringLiteral node) throws IOException { writer.append(node.getQuoteCharacter()); writer.append(ScriptRuntime.escapeString(node.getValue(), node.getQuoteCharacter())); writer.append(node.getQuoteCharacter()); }
private Object getPropKey(Node id) { Object key; if (id instanceof Name) { String s = ((Name)id).getIdentifier(); decompiler.addName(s); key = ScriptRuntime.getIndexObject(s); } else if (id instanceof StringLiteral) { String s = ((StringLiteral)id).getValue(); decompiler.addString(s); key = ScriptRuntime.getIndexObject(s); } else if (id instanceof NumberLiteral) { double n = ((NumberLiteral)id).getNumber(); decompiler.addNumber(n); key = ScriptRuntime.getIndexObject(n); } else { throw Kit.codeBug(); } return key; }
private Object getPropKey(Node id) { Object key; if (id instanceof Name) { String s = ((Name)id).getIdentifier(); decompiler.addName(s); key = ScriptRuntime.getIndexObject(s); } else if (id instanceof StringLiteral) { String s = ((StringLiteral)id).getValue(); decompiler.addString(s); key = ScriptRuntime.getIndexObject(s); } else if (id instanceof NumberLiteral) { double n = ((NumberLiteral)id).getNumber(); decompiler.addNumber(n); key = ScriptRuntime.getIndexObject(n); } else { throw Kit.codeBug(); } return key; }