public ASTFunctionNode(FunctionNode functionNode) { super(functionNode); super.setImage(functionNode.getName()); }
private FunctionCall getFunctionCall() { FunctionCall functionCall = new FunctionCall(); Name name = new Name(); name.setIdentifier("initialize"); functionCall.setTarget(name); StringLiteral arg = new StringLiteral(); arg.setValue("value"); arg.setQuoteCharacter('"'); functionCall.addArgument(arg); return functionCall; } class FunctionVisitor implements NodeVisitor { @Override public boolean visit(AstNode node) { if (node.getClass() == FunctionNode.class) { FunctionNode fun = (FunctionNode) node; if(fun.getName().equals("initialize")) //prevents infinit loop { return true; } fun.getBody().addChildrenToFront(new EmptyStatement()); // adds ';', I don't know if required fun.getBody().addChildrenToFront(getFunctionCall());//no fun.addChildrenToFront } return true; } }
private JavaScriptFunctionDeclaration createJavaScriptFunction(String lookupName, int offset, CodeBlock block, TypeDeclaration returnType, FunctionNode fn) { Name name = fn.getFunctionName(); JavaScriptFunctionDeclaration function = new JavaScriptFunctionDeclaration(lookupName, offset, block, returnType); if(name != null) { int start = name.getAbsolutePosition(); int end = start + name.getLength(); function.setStartOffset(start); function.setEndOffset(end); function.setFunctionName(fn.getName()); } return function; }
Node decompileFunctionHeader(FunctionNode fn) { Node mexpr = null; if (fn.getFunctionName() != null) { decompiler.addName(fn.getName()); } else if (fn.getMemberExprNode() != null) { mexpr = transform(fn.getMemberExprNode()); } decompiler.addToken(Token.LP); List<AstNode> params = fn.getParams(); for (int i = 0; i < params.size(); i++) { decompile(params.get(i)); if (i < params.size() - 1) { decompiler.addToken(Token.COMMA); } } decompiler.addToken(Token.RP); if (!fn.isExpressionClosure()) { decompiler.addEOL(Token.LC); } return mexpr; }
Node decompileFunctionHeader(FunctionNode fn) { Node mexpr = null; if (fn.getFunctionName() != null) { decompiler.addName(fn.getName()); } else if (fn.getMemberExprNode() != null) { mexpr = transform(fn.getMemberExprNode()); } decompiler.addToken(Token.LP); List<AstNode> params = fn.getParams(); for (int i = 0; i < params.size(); i++) { decompile(params.get(i)); if (i < params.size() - 1) { decompiler.addToken(Token.COMMA); } } decompiler.addToken(Token.RP); if (!fn.isExpressionClosure()) { decompiler.addEOL(Token.LC); } return mexpr; }
Node decompileFunctionHeader(FunctionNode fn) { Node mexpr = null; if (fn.getFunctionName() != null) { decompiler.addName(fn.getName()); } else if (fn.getMemberExprNode() != null) { mexpr = transform(fn.getMemberExprNode()); } decompiler.addToken(Token.LP); List<AstNode> params = fn.getParams(); for (int i = 0; i < params.size(); i++) { decompile(params.get(i)); if (i < params.size() - 1) { decompiler.addToken(Token.COMMA); } } decompiler.addToken(Token.RP); if (!fn.isExpressionClosure()) { decompiler.addEOL(Token.LC); } return mexpr; }
Node decompileFunctionHeader(FunctionNode fn) { Node mexpr = null; if (fn.getFunctionName() != null) { decompiler.addName(fn.getName()); } else if (fn.getMemberExprNode() != null) { mexpr = transform(fn.getMemberExprNode()); } decompiler.addToken(Token.LP); List<AstNode> params = fn.getParams(); for (int i = 0; i < params.size(); i++) { decompile(params.get(i)); if (i < params.size() - 1) { decompiler.addToken(Token.COMMA); } } decompiler.addToken(Token.RP); if (!fn.isExpressionClosure()) { decompiler.addEOL(Token.LC); } return mexpr; }
== FunctionNode.FUNCTION_STATEMENT) String name = ofn.fnode.getName(); if (name.length() != 0) { if (possibleDirectCalls == null) {
== FunctionNode.FUNCTION_STATEMENT) String name = ofn.fnode.getName(); if (name.length() != 0) { if (possibleDirectCalls == null) {
== FunctionNode.FUNCTION_STATEMENT) String name = ofn.fnode.getName(); if (name.length() != 0) { if (possibleDirectCalls == null) {
== FunctionNode.FUNCTION_STATEMENT) String name = ofn.fnode.getName(); if (name.length() != 0) { if (possibleDirectCalls == null) {
private void generateFunctionICode() { itsInFunctionFlag = true; FunctionNode theFunction = (FunctionNode)scriptOrFn; itsData.itsFunctionType = theFunction.getFunctionType(); itsData.itsNeedsActivation = theFunction.requiresActivation(); if (theFunction.getFunctionName() != null) { itsData.itsName = theFunction.getName(); } if (theFunction.isGenerator()) { addIcode(Icode_GENERATOR); addUint16(theFunction.getBaseLineno() & 0xFFFF); } generateICodeFromTree(theFunction.getLastChild()); }
private void generateFunctionICode() { itsInFunctionFlag = true; FunctionNode theFunction = (FunctionNode)scriptOrFn; itsData.itsFunctionType = theFunction.getFunctionType(); itsData.itsNeedsActivation = theFunction.requiresActivation(); if (theFunction.getFunctionName() != null) { itsData.itsName = theFunction.getName(); } if (theFunction.isGenerator()) { addIcode(Icode_GENERATOR); addUint16(theFunction.getBaseLineno() & 0xFFFF); } generateICodeFromTree(theFunction.getLastChild()); }
private void generateFunctionICode() { itsInFunctionFlag = true; FunctionNode theFunction = (FunctionNode)scriptOrFn; itsData.itsFunctionType = theFunction.getFunctionType(); itsData.itsNeedsActivation = theFunction.requiresActivation(); if (theFunction.getFunctionName() != null) { itsData.itsName = theFunction.getName(); } if (theFunction.isGenerator()) { addIcode(Icode_GENERATOR); addUint16(theFunction.getBaseLineno() & 0xFFFF); } generateICodeFromTree(theFunction.getLastChild()); }
private void generateFunctionICode() { itsInFunctionFlag = true; FunctionNode theFunction = (FunctionNode)scriptOrFn; itsData.itsFunctionType = theFunction.getFunctionType(); itsData.itsNeedsActivation = theFunction.requiresActivation(); if (theFunction.getFunctionName() != null) { itsData.itsName = theFunction.getName(); } if (theFunction.isGenerator()) { addIcode(Icode_GENERATOR); addUint16(theFunction.getBaseLineno() & 0xFFFF); } generateICodeFromTree(theFunction.getLastChild()); }
/** * Visits a function AST node. This will create a tree node for the * function, and also visit the AST nodes in the function's body, to * identify local variables, nested functions, etc. * * @param fn The function node. * @return <code>false</code> always, as this method manually visits * the function AST node's child nodes. */ private boolean visitFunction(FunctionNode fn) { Name funcName = fn.getFunctionName(); // Happens with certain syntax errors, such as // "function function foo() {". if (funcName!=null) { String text = fn.getName() + RhinoUtil.getFunctionArgsString(fn); JavaScriptTreeNode tn = createTreeNode(funcName); tn.setText(text); tn.setIcon(IconFactory.getIcon(IconFactory.DEFAULT_FUNCTION_ICON)); tn.setSortPriority(JavaScriptOutlineTree.PRIORITY_FUNCTION); curScopeTreeNode.add(tn); curScopeTreeNode = tn; fn.getBody().visit(this); curScopeTreeNode = (JavaScriptTreeNode)curScopeTreeNode.getParent(); } // Never visit children; we do this manually so we know when scope ends return false; }
Node result = Node.newString(Token.FUNCTION, fnNode.getName()); result.putIntProp(Node.FUNCTION_PROP, functionIndex); return result;
Node result = Node.newString(Token.FUNCTION, fnNode.getName()); result.putIntProp(Node.FUNCTION_PROP, functionIndex); return result;
Node result = Node.newString(Token.FUNCTION, fnNode.getName()); result.putIntProp(Node.FUNCTION_PROP, functionIndex); return result;
Node result = Node.newString(Token.FUNCTION, fnNode.getName()); result.putIntProp(Node.FUNCTION_PROP, functionIndex); return result;