本文整理汇总了Java中org.mozilla.javascript.ast.FunctionNode.getFunctionName方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionNode.getFunctionName方法的具体用法?Java FunctionNode.getFunctionName怎么用?Java FunctionNode.getFunctionName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ast.FunctionNode
的用法示例。
在下文中一共展示了FunctionNode.getFunctionName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createFunctionNodeConstraints
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
/**
* For a function definition (FunctionNode), create constraints equating its
* parameters to param(.) variables, and equate the type of the function name
* to the type of the entire function definition.
*/
private void createFunctionNodeConstraints(FunctionNode node, ITypeTerm funTerm){
// if the function has a name, equate the types of the function node and the function name
Name funName = node.getFunctionName();
if (funName != null){
ITypeTerm nameTerm = findOrCreateNameDeclarationTerm(funName);
addSubTypeConstraint(funTerm, nameTerm, node.getLineno(), null);
}
// for a function f with params v1, v2, ... generate param(|f|,i) = |v_i|
for (int i=0; i < node.getParamCount(); i++){
AstNode param = node.getParams().get(i);
if (param instanceof Name){
Name name = (Name)param;
ITypeTerm nameVar = findOrCreateNameDeclarationTerm(name);
ITypeTerm paramVar = findOrCreateFunctionParamTerm(funTerm, i, node.getParamCount(), node.getLineno());
addTypeEqualityConstraint(paramVar, nameVar, param.getLineno(), null);
} else {
error("createFunctionNodeConstraints: unexpected parameter type", node);
}
}
}
示例4: 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());
}
示例5: 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;
}
示例6: methodDefinition
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
private ObjectProperty methodDefinition(int pos, AstNode propName, int entryKind)
throws IOException
{
FunctionNode fn = function(FunctionNode.FUNCTION_EXPRESSION);
// We've already parsed the function name, so fn should be anonymous.
Name name = fn.getFunctionName();
if (name != null && name.length() != 0) {
reportError("msg.bad.prop");
}
ObjectProperty pn = new ObjectProperty(pos);
switch (entryKind) {
case GET_ENTRY:
pn.setIsGetterMethod();
fn.setFunctionIsGetterMethod();
break;
case SET_ENTRY:
pn.setIsSetterMethod();
fn.setFunctionIsSetterMethod();
break;
case METHOD_ENTRY:
pn.setIsNormalMethod();
fn.setFunctionIsNormalMethod();
break;
}
int end = getNodeEnd(fn);
pn.setLeft(propName);
pn.setRight(fn);
pn.setLength(end - pos);
return pn;
}
示例7: initFunction
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
private Node initFunction(FunctionNode fnNode, int functionIndex,
Node statements, int functionType) {
fnNode.setFunctionType(functionType);
fnNode.addChildToBack(statements);
int functionCount = fnNode.getFunctionCount();
if (functionCount != 0) {
// Functions containing other functions require activation objects
fnNode.setRequiresActivation();
}
if (functionType == FunctionNode.FUNCTION_EXPRESSION) {
Name name = fnNode.getFunctionName();
if (name != null && name.length() != 0
&& fnNode.getSymbol(name.getIdentifier()) == null) {
// A function expression needs to have its name as a
// variable (if it isn't already allocated as a variable).
// See ECMA Ch. 13. We add code to the beginning of the
// function to initialize a local variable of the
// function's name to the function value, but only if the
// function doesn't already define a formal parameter, var,
// or nested function with the same name.
fnNode.putSymbol(new Symbol(Token.FUNCTION, name.getIdentifier()));
Node setFn = new Node(Token.EXPR_VOID,
new Node(Token.SETNAME,
Node.newString(Token.BINDNAME,
name.getIdentifier()),
new Node(Token.THISFN)));
statements.addChildrenToFront(setFn);
}
}
// Add return to end if needed.
Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
statements.addChildToBack(new Node(Token.RETURN));
}
Node result = Node.newString(Token.FUNCTION, fnNode.getName());
result.putIntProp(Node.FUNCTION_PROP, functionIndex);
return result;
}