本文整理汇总了Java中org.mozilla.javascript.ast.FunctionNode.getFunctionType方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionNode.getFunctionType方法的具体用法?Java FunctionNode.getFunctionType怎么用?Java FunctionNode.getFunctionType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ast.FunctionNode
的用法示例。
在下文中一共展示了FunctionNode.getFunctionType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFunctionICode
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
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);
}
if (theFunction.isInStrictMode()) {
itsData.isStrict = true;
}
generateICodeFromTree(theFunction.getLastChild());
}
示例2: generateFunctionICode
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
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.getIgnoreDynamicScope()) {
if (compilerEnv.isUseDynamicScope()) {
itsData.useDynamicScope = true;
}
}
if (theFunction.isGenerator()) {
addIcode(Icode_GENERATOR);
addUint16(theFunction.getBaseLineno() & 0xFFFF);
}
generateICodeFromTree(theFunction.getLastChild());
}
示例3: generateFunctionICode
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
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());
}
示例4: decompileFunctionHeader
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
Node decompileFunctionHeader(FunctionNode fn) {
Node mexpr = null;
if (fn.getFunctionName() != null) {
decompiler.addName(fn.getName());
} else if (fn.getMemberExprNode() != null) {
mexpr = transform(fn.getMemberExprNode());
}
boolean isArrow = fn.getFunctionType() == FunctionNode.ARROW_FUNCTION;
boolean noParen = isArrow && fn.getLp() == -1;
if (!noParen) {
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);
}
}
if (!noParen) {
decompiler.addToken(Token.RP);
}
if (isArrow) {
decompiler.addToken(Token.ARROW);
}
if (!fn.isExpressionClosure()) {
decompiler.addEOL(Token.LC);
}
return mexpr;
}
示例5: transformFunction
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
private Node transformFunction(FunctionNode fn) {
int functionType = fn.getFunctionType();
int start = decompiler.markFunctionStart(functionType);
Node mexpr = decompileFunctionHeader(fn);
int index = currentScriptOrFn.addFunction(fn);
PerFunctionVariables savedVars = new PerFunctionVariables(fn);
try {
// If we start needing to record much more codegen metadata during
// function parsing, we should lump it all into a helper class.
Node destructuring = (Node)fn.getProp(Node.DESTRUCTURING_PARAMS);
fn.removeProp(Node.DESTRUCTURING_PARAMS);
int lineno = fn.getBody().getLineno();
++nestingOfFunction; // only for body, not params
Node body = transform(fn.getBody());
if (!fn.isExpressionClosure()) {
decompiler.addToken(Token.RC);
}
fn.setEncodedSourceBounds(start, decompiler.markFunctionEnd(start));
if (functionType != FunctionNode.FUNCTION_EXPRESSION && !fn.isExpressionClosure()) {
// Add EOL only if function is not part of expression
// since it gets SEMI + EOL from Statement in that case
decompiler.addToken(Token.EOL);
}
if (destructuring != null) {
body.addChildToFront(new Node(Token.EXPR_VOID,
destructuring, lineno));
}
int syntheticType = fn.getFunctionType();
Node pn = initFunction(fn, index, body, syntheticType);
if (mexpr != null) {
pn = createAssignment(Token.ASSIGN, mexpr, pn);
if (syntheticType != FunctionNode.FUNCTION_EXPRESSION) {
pn = createExprStatementNoReturn(pn, fn.getLineno());
}
}
return pn;
} finally {
--nestingOfFunction;
savedVars.restore();
}
}
示例6: transformGenExpr
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
private Node transformGenExpr(GeneratorExpression node) {
Node pn;
FunctionNode fn = new FunctionNode();
fn.setSourceName(currentScriptOrFn.getNextTempName());
fn.setIsGenerator();
fn.setFunctionType(FunctionNode.FUNCTION_EXPRESSION);
fn.setRequiresActivation();
int functionType = fn.getFunctionType();
int start = decompiler.markFunctionStart(functionType);
Node mexpr = decompileFunctionHeader(fn);
int index = currentScriptOrFn.addFunction(fn);
PerFunctionVariables savedVars = new PerFunctionVariables(fn);
try {
// If we start needing to record much more codegen metadata during
// function parsing, we should lump it all into a helper class.
Node destructuring = (Node)fn.getProp(Node.DESTRUCTURING_PARAMS);
fn.removeProp(Node.DESTRUCTURING_PARAMS);
int lineno = node.lineno;
++nestingOfFunction; // only for body, not params
Node body = genExprTransformHelper(node);
if (!fn.isExpressionClosure()) {
decompiler.addToken(Token.RC);
}
fn.setEncodedSourceBounds(start, decompiler.markFunctionEnd(start));
if (functionType != FunctionNode.FUNCTION_EXPRESSION && !fn.isExpressionClosure()) {
// Add EOL only if function is not part of expression
// since it gets SEMI + EOL from Statement in that case
decompiler.addToken(Token.EOL);
}
if (destructuring != null) {
body.addChildToFront(new Node(Token.EXPR_VOID,
destructuring, lineno));
}
int syntheticType = fn.getFunctionType();
pn = initFunction(fn, index, body, syntheticType);
if (mexpr != null) {
pn = createAssignment(Token.ASSIGN, mexpr, pn);
if (syntheticType != FunctionNode.FUNCTION_EXPRESSION) {
pn = createExprStatementNoReturn(pn, fn.getLineno());
}
}
} finally {
--nestingOfFunction;
savedVars.restore();
}
Node call = createCallOrNew(Token.CALL, pn);
call.setLineno(node.getLineno());
decompiler.addToken(Token.LP);
decompiler.addToken(Token.RP);
return call;
}