当前位置: 首页>>代码示例>>Java>>正文


Java FunctionNode.getFunctionName方法代码示例

本文整理汇总了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());
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:22,代码来源:CodeGenerator.java

示例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());
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:24,代码来源:CodeGenerator.java

示例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);
		}
	}

}
 
开发者ID:Samsung,项目名称:SJS,代码行数:28,代码来源:ConstraintVisitor.java

示例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());
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:19,代码来源:CodeGenerator.java

示例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;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:31,代码来源:IRFactory.java

示例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;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:31,代码来源:Parser.java

示例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;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:43,代码来源:IRFactory.java


注:本文中的org.mozilla.javascript.ast.FunctionNode.getFunctionName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。