本文整理了Java中org.mozilla.javascript.Node
类的一些代码示例,展示了Node
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node
类的具体详情如下:
包路径:org.mozilla.javascript.Node
类名称:Node
[英]This class implements the root of the intermediate representation.
[中]此类实现了中间表示的根。
代码示例来源:origin: konsoletyper/teavm
private void handle(AstNode block) {
Node child = block.getFirstChild();
while (child != null) {
Node next = child.getNext();
if (child instanceof ExpressionStatement) {
ExpressionStatement statement = (ExpressionStatement) child;
if (statement.getExpression() instanceof StringLiteral) {
block.removeChild(child);
}
}
child = next;
}
}
}
代码示例来源:origin: rhino/js
private static Node addBeforeCurrent(Node parent, Node previous,
Node current, Node toAdd)
{
if (previous == null) {
if (!(current == parent.getFirstChild())) Kit.codeBug();
parent.addChildToFront(toAdd);
} else {
if (!(current == previous.getNext())) Kit.codeBug();
parent.addChildAfter(toAdd, previous);
}
return toAdd;
}
代码示例来源:origin: rhino/js
Node createUseLocal(Node localBlock)
{
if (Token.LOCAL_BLOCK != localBlock.getType()) throw Kit.codeBug();
Node result = new Node(Token.LOCAL_LOAD);
result.putProp(Node.LOCAL_BLOCK_PROP, localBlock);
return result;
}
代码示例来源:origin: rhino/js
private int getLocalBlockRef(Node node)
{
Node localBlock = (Node)node.getProp(Node.LOCAL_BLOCK_PROP);
return localBlock.getExistingIntProp(Node.LOCAL_PROP);
}
代码示例来源:origin: geogebra/geogebra
private Node createWith(Node obj, Node body, int lineno) {
setRequiresActivation();
Node result = new Node(Token.BLOCK, lineno);
result.addChildToBack(new Node(Token.ENTERWITH, obj));
Node bodyNode = new Node(Token.WITH, body, lineno);
result.addChildrenToBack(bodyNode);
result.addChildToBack(new Node(Token.LEAVEWITH));
return result;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private Node transformScript(ScriptNode node) {
decompiler.addToken(Token.SCRIPT);
if (currentScope != null) Kit.codeBug();
currentScope = node;
Node body = new Node(Token.BLOCK);
for (Node kid : node) {
body.addChildToBack(transform((AstNode)kid));
}
node.removeChildren();
Node children = body.getFirstChild();
if (children != null) {
node.addChildrenToBack(children);
}
return node;
}
代码示例来源:origin: rhino/js
private static void buildStatementList_r(Node node, ObjArray statements)
{
int type = node.getType();
if (type == Token.BLOCK
|| type == Token.LOCAL_BLOCK
|| type == Token.LOOP
|| type == Token.FUNCTION)
{
Node child = node.getFirstChild();
while (child != null) {
buildStatementList_r(child, statements);
child = child.getNext();
}
} else {
statements.add(node);
}
}
代码示例来源:origin: rhino/js
private Node createName(int type, String name, Node child)
{
Node result = createName(name);
result.setType(type);
if (child != null)
result.addChildToBack(child);
return result;
}
代码示例来源:origin: rhino/js
private boolean getterSetterProperty(ObjArray elems, Object property,
boolean isGetter) throws IOException {
Node f = function(FunctionNode.FUNCTION_EXPRESSION);
if (f.getType() != Token.FUNCTION) {
reportError("msg.bad.prop");
return false;
}
int fnIndex = f.getExistingIntProp(Node.FUNCTION_PROP);
FunctionNode fn = currentScriptOrFn.getFunctionNode(fnIndex);
if (fn.getFunctionName().length() != 0) {
reportError("msg.bad.prop");
return false;
}
elems.add(property);
if (isGetter) {
elems.add(nf.createUnary(Token.GET, f));
} else {
elems.add(nf.createUnary(Token.SET, f));
}
return true;
}
}
代码示例来源:origin: geogebra/geogebra
private void visitSetConst(Node node, Node child)
{
String name = node.getFirstChild().getString();
while (child != null) {
generateExpression(child, node);
child = child.getNext();
}
cfw.addALoad(contextLocal);
cfw.addPush(name);
addScriptRuntimeInvoke(
"setConst",
"(Lorg/mozilla/javascript/Scriptable;"
+"Ljava/lang/Object;"
+"Lorg/mozilla/javascript/Context;"
+"Ljava/lang/String;"
+")Ljava/lang/Object;");
}
代码示例来源:origin: rhino/js
private static boolean isArithmeticNode(Node node)
{
int type = node.getType();
return (type == Token.SUB)
|| (type == Token.MOD)
|| (type == Token.DIV)
|| (type == Token.MUL);
}
代码示例来源:origin: rhino/js
private static Node replaceCurrent(Node parent, Node previous,
Node current, Node replacement)
{
if (previous == null) {
if (!(current == parent.getFirstChild())) Kit.codeBug();
parent.replaceChild(current, replacement);
} else if (previous.next == current) {
// Check cachedPrev.next == current is necessary due to possible
// tree mutations
parent.replaceChildAfter(previous, replacement);
} else {
parent.replaceChild(current, replacement);
}
return replacement;
}
代码示例来源:origin: wala/WALA
private static boolean isPrimitiveCreation(WalkContext context, NewExpression n) {
Node target = getNewTarget(n);
return isPrologueScript(context) && n.getType() == Token.NEW && target.getType() == Token.NAME
&& target.getString().equals("Primitives");
}
代码示例来源:origin: rhino/js
private boolean convertParameter(Node n)
{
if (inDirectCallFunction && n.getType() == Token.GETVAR) {
int varIndex = theFunction.getVarIndex(n);
if (theFunction.isParameter(varIndex)) {
n.removeProp(Node.ISNUMBER_PROP);
return true;
}
}
return false;
}
代码示例来源:origin: geogebra/geogebra
/**
* Sets the JsDoc comment string attached to this node.
*/
public void setJsDocNode(Comment jsdocNode) {
putProp(JSDOC_PROP, jsdocNode);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
private Node expr(boolean inForInit)
throws IOException, ParserException
{
Node pn = assignExpr(inForInit);
while (matchToken(Token.COMMA)) {
decompiler.addToken(Token.COMMA);
if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
addStrictWarning("msg.no.side.effects", "");
pn = nf.createBinary(Token.COMMA, pn, assignExpr(inForInit));
}
return pn;
}
代码示例来源:origin: rhino/js
/**
* Leaf
*/
Node createLeaf(int nodeType)
{
return new Node(nodeType);
}
代码示例来源:origin: org.teavm/teavm-jso-impl
private static AstNode isSingleStatement(AstNode ast) {
if (ast.getFirstChild() == null || ast.getFirstChild().getNext() != null) {
return null;
}
if (ast.getFirstChild().getType() == Token.BLOCK) {
return isSingleStatement((AstNode) ast.getFirstChild());
}
return (AstNode) ast.getFirstChild();
}
代码示例来源:origin: rhino/js
/**
* Regular expressions
*/
Node createRegExp(int regexpIndex)
{
Node n = new Node(Token.REGEXP);
n.putIntProp(Node.REGEXP_PROP, regexpIndex);
return n;
}
代码示例来源:origin: rhino/js
Node createPropertyGet(Node target, String namespace, String name,
int memberTypeFlags)
{
if (namespace == null && memberTypeFlags == 0) {
if (target == null) {
return createName(name);
}
checkActivationName(name, Token.GETPROP);
if (ScriptRuntime.isSpecialProperty(name)) {
Node ref = new Node(Token.REF_SPECIAL, target);
ref.putProp(Node.NAME_PROP, name);
return new Node(Token.GET_REF, ref);
}
return new Node(Token.GETPROP, target, createString(name));
}
Node elem = createString(name);
memberTypeFlags |= Node.PROPERTY_FLAG;
return createMemberRefGet(target, namespace, elem, memberTypeFlags);
}
内容来源于网络,如有侵权,请联系作者删除!