本文整理汇总了Java中org.mozilla.javascript.ast.Name.length方法的典型用法代码示例。如果您正苦于以下问题:Java Name.length方法的具体用法?Java Name.length怎么用?Java Name.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ast.Name
的用法示例。
在下文中一共展示了Name.length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: methodDefinition
import org.mozilla.javascript.ast.Name; //导入方法依赖的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;
}
示例2: initFunction
import org.mozilla.javascript.ast.Name; //导入方法依赖的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;
}