public boolean hasResult() { return node.getReturnValue() != null; } }
private void print(ReturnStatement node) throws IOException { writer.append("return"); if (node.getReturnValue() != null) { writer.append(' '); print(node.getReturnValue()); } writer.append(';'); }
private void print(FunctionNode node) throws IOException { if (!node.isMethod()) { writer.append("function"); } if (node.getFunctionName() != null) { writer.append(' '); print(node.getFunctionName()); } writer.append('('); printList(node.getParams()); writer.append(')').ws(); if (node.isExpressionClosure()) { if (node.getBody().getLastChild() instanceof ReturnStatement) { print(((ReturnStatement) node.getBody().getLastChild()).getReturnValue()); if (node.getFunctionType() == FunctionNode.FUNCTION_STATEMENT) { writer.append(";"); } } } else { print(node.getBody()); } }
private void print(ReturnStatement node) throws IOException { writer.append("return"); if (node.getReturnValue() != null) { writer.append(' '); print(node.getReturnValue()); } writer.append(';'); }
@Override public CAstNode visitReturnStatement(ReturnStatement node, WalkContext arg) { AstNode val = node.getReturnValue(); if (val != null) { return Ast.makeNode(CAstNode.RETURN, visit(val, arg)); } else { return Ast.makeNode(CAstNode.RETURN); } }
private static AstNode getExpression(MethodReference method, AstNode statement) { if (method.getReturnType() == ValueType.VOID) { if (statement instanceof ExpressionStatement) { return ((ExpressionStatement) statement).getExpression(); } else if (statement instanceof ThrowStatement) { return ((ThrowStatement) statement).getExpression(); } } else { if (statement instanceof ReturnStatement) { return ((ReturnStatement) statement).getReturnValue(); } } return null; }
if (body.getLastChild() instanceof ReturnStatement) { body = ((ReturnStatement) body.getLastChild()).getReturnValue(); sb.append(body.toSource(0)); if (functionType == FUNCTION_STATEMENT) {
if (body.getLastChild() instanceof ReturnStatement) { body = ((ReturnStatement) body.getLastChild()).getReturnValue(); sb.append(body.toSource(0)); if (functionType == FUNCTION_STATEMENT) {
if (body.getLastChild() instanceof ReturnStatement) { body = ((ReturnStatement) body.getLastChild()).getReturnValue(); sb.append(body.toSource(0)); if (functionType == FUNCTION_STATEMENT) {
if (body.getLastChild() instanceof ReturnStatement) { body = ((ReturnStatement) body.getLastChild()).getReturnValue(); sb.append(body.toSource(0)); if (functionType == FUNCTION_STATEMENT) {
private Node transformReturn(ReturnStatement node) { boolean expClosure = Boolean.TRUE.equals(node.getProp(Node.EXPRESSION_CLOSURE_PROP)); if (expClosure) { decompiler.addName(" "); } else { decompiler.addToken(Token.RETURN); } AstNode rv = node.getReturnValue(); Node value = rv == null ? null : transform(rv); if (!expClosure) decompiler.addEOL(Token.SEMI); return rv == null ? new Node(Token.RETURN, node.getLineno()) : new Node(Token.RETURN, value, node.getLineno()); }
private Node transformReturn(ReturnStatement node) { boolean expClosure = Boolean.TRUE.equals(node.getProp(Node.EXPRESSION_CLOSURE_PROP)); if (expClosure) { decompiler.addName(" "); } else { decompiler.addToken(Token.RETURN); } AstNode rv = node.getReturnValue(); Node value = rv == null ? null : transform(rv); if (!expClosure) decompiler.addEOL(Token.SEMI); return rv == null ? new Node(Token.RETURN, node.getLineno()) : new Node(Token.RETURN, value, node.getLineno()); }
private Node transformReturn(ReturnStatement node) { boolean expClosure = Boolean.TRUE.equals(node.getProp(Node.EXPRESSION_CLOSURE_PROP)); if (expClosure) { decompiler.addName(" "); } else { decompiler.addToken(Token.RETURN); } AstNode rv = node.getReturnValue(); Node value = rv == null ? null : transform(rv); if (!expClosure) decompiler.addEOL(Token.SEMI); return rv == null ? new Node(Token.RETURN, node.getLineno()) : new Node(Token.RETURN, value, node.getLineno()); }
private Node transformReturn(ReturnStatement node) { boolean expClosure = Boolean.TRUE.equals(node.getProp(Node.EXPRESSION_CLOSURE_PROP)); if (expClosure) { decompiler.addName(" "); } else { decompiler.addToken(Token.RETURN); } AstNode rv = node.getReturnValue(); Node value = rv == null ? null : transform(rv); if (!expClosure) decompiler.addEOL(Token.SEMI); return rv == null ? new Node(Token.RETURN, node.getLineno()) : new Node(Token.RETURN, value, node.getLineno()); }
/** * Iterate through all the return types and check they are all the same, * otherwise return no type * * @return */ public TypeDeclaration getCommonReturnType() { TypeDeclaration commonType = null; for (ReturnStatement rs : returnStatements) { AstNode returnValue = rs.getReturnValue(); // resolve the node TypeDeclaration type = provider.getJavaScriptEngine() .getJavaScriptResolver(provider).resolveNode( returnValue); if (commonType == null) { commonType = type; } else { if (!commonType.equals(type)) { commonType = provider.getTypesFactory() .getDefaultTypeDeclaration(); break; // not matching } } } return commonType; }
private void print(FunctionNode node) throws IOException { if (!node.isMethod()) { writer.append("function"); } if (node.getFunctionName() != null) { writer.append(' '); print(node.getFunctionName()); } writer.append('('); printList(node.getParams()); writer.append(')').ws(); if (node.isExpressionClosure()) { if (node.getBody().getLastChild() instanceof ReturnStatement) { print(((ReturnStatement) node.getBody().getLastChild()).getReturnValue()); if (node.getFunctionType() == FunctionNode.FUNCTION_STATEMENT) { writer.append(";"); } } } else { print(node.getBody()); } }