本文整理汇总了Java中org.mozilla.javascript.ast.FunctionNode.ARROW_FUNCTION属性的典型用法代码示例。如果您正苦于以下问题:Java FunctionNode.ARROW_FUNCTION属性的具体用法?Java FunctionNode.ARROW_FUNCTION怎么用?Java FunctionNode.ARROW_FUNCTION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mozilla.javascript.ast.FunctionNode
的用法示例。
在下文中一共展示了FunctionNode.ARROW_FUNCTION属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkActivationName
protected void checkActivationName(String name, int token) {
if (!insideFunction()) {
return;
}
boolean activation = false;
if ("arguments".equals(name) &&
// An arrow function not generate arguments. So it not need activation.
((FunctionNode)currentScriptOrFn).getFunctionType() != FunctionNode.ARROW_FUNCTION) {
activation = true;
} else if (compilerEnv.getActivationNames() != null
&& compilerEnv.getActivationNames().contains(name)) {
activation = true;
} else if ("length".equals(name)) {
if (token == Token.GETPROP
&& compilerEnv.getLanguageVersion() == Context.VERSION_1_2)
{
// Use of "length" in 1.2 requires an activation object.
activation = true;
}
}
if (activation) {
setRequiresActivation();
}
}
示例2: decompileFunctionHeader
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;
}
示例3: markFunctionStart
int markFunctionStart(int functionType)
{
int savedOffset = getCurrentOffset();
if (functionType != FunctionNode.ARROW_FUNCTION) {
addToken(Token.FUNCTION);
append((char)functionType);
}
return savedOffset;
}
示例4: visitFunction
private void visitFunction(OptFunctionNode ofn, int functionType)
{
int fnIndex = codegen.getIndex(ofn.fnode);
cfw.add(ByteCode.NEW, codegen.mainClassName);
// Call function constructor
cfw.add(ByteCode.DUP);
cfw.addALoad(variableObjectLocal);
cfw.addALoad(contextLocal); // load 'cx'
cfw.addPush(fnIndex);
cfw.addInvoke(ByteCode.INVOKESPECIAL, codegen.mainClassName,
"<init>", Codegen.FUNCTION_CONSTRUCTOR_SIGNATURE);
if (functionType == FunctionNode.ARROW_FUNCTION) {
cfw.addALoad(contextLocal); // load 'cx'
cfw.addALoad(variableObjectLocal);
cfw.addALoad(thisObjLocal);
addOptRuntimeInvoke("bindThis",
"(Lorg/mozilla/javascript/NativeFunction;"
+"Lorg/mozilla/javascript/Context;"
+"Lorg/mozilla/javascript/Scriptable;"
+"Lorg/mozilla/javascript/Scriptable;"
+")Lorg/mozilla/javascript/Function;");
}
if (functionType == FunctionNode.FUNCTION_EXPRESSION ||
functionType == FunctionNode.ARROW_FUNCTION) {
// Leave closure object on stack and do not pass it to
// initFunction which suppose to connect statements to scope
return;
}
cfw.addPush(functionType);
cfw.addALoad(variableObjectLocal);
cfw.addALoad(contextLocal); // load 'cx'
addOptRuntimeInvoke("initFunction",
"(Lorg/mozilla/javascript/NativeFunction;"
+"I"
+"Lorg/mozilla/javascript/Scriptable;"
+"Lorg/mozilla/javascript/Context;"
+")V");
}