Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Rhino JavaScript Java Library Source Code
Rhino JavaScript Java Library is an open-source implementation of JavaScript
written entirely in Java.
Rhino JavaScript Java Library Source Code files are provided in binary package (rhino-1.7.14.zip).
You can also browse the source code below:
✍: FYIcenter.com
⏎ org/mozilla/javascript/optimizer/OptTransformer.java
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript.optimizer;
import java.util.Map;
import org.mozilla.javascript.Kit;
import org.mozilla.javascript.Node;
import org.mozilla.javascript.NodeTransformer;
import org.mozilla.javascript.ObjArray;
import org.mozilla.javascript.Token;
import org.mozilla.javascript.ast.ScriptNode;
/**
* This class performs node transforms to prepare for optimization.
*
* @see NodeTransformer
* @author Norris Boyd
*/
class OptTransformer extends NodeTransformer {
OptTransformer(Map<String, OptFunctionNode> possibleDirectCalls, ObjArray directCallTargets) {
this.possibleDirectCalls = possibleDirectCalls;
this.directCallTargets = directCallTargets;
}
@Override
protected void visitNew(Node node, ScriptNode tree) {
detectDirectCall(node, tree);
super.visitNew(node, tree);
}
@Override
protected void visitCall(Node node, ScriptNode tree) {
detectDirectCall(node, tree);
super.visitCall(node, tree);
}
private void detectDirectCall(Node node, ScriptNode tree) {
if (tree.getType() == Token.FUNCTION) {
Node left = node.getFirstChild();
// count the arguments
int argCount = 0;
if (left != null) {
Node arg = left.getNext();
while (arg != null) {
arg = arg.getNext();
argCount++;
}
}
if (argCount == 0) {
OptFunctionNode.get(tree).itsContainsCalls0 = true;
}
/*
* Optimize a call site by converting call("a", b, c) into :
*
* FunctionObjectFor"a" <-- instance variable init'd by constructor
*
* // this is a DIRECTCALL node
* fn = GetProp(tmp = GetBase("a"), "a");
* if (fn == FunctionObjectFor"a")
* fn.call(tmp, b, c)
* else
* ScriptRuntime.Call(fn, tmp, b, c)
*/
if (possibleDirectCalls != null) {
String targetName = null;
if (left.getType() == Token.NAME) {
targetName = left.getString();
} else if (left.getType() == Token.GETPROP) {
targetName = left.getFirstChild().getNext().getString();
} else if (left.getType() == Token.GETPROPNOWARN) {
throw Kit.codeBug();
}
if (targetName != null) {
OptFunctionNode ofn;
ofn = possibleDirectCalls.get(targetName);
if (ofn != null
&& argCount == ofn.fnode.getParamCount()
&& !ofn.fnode.requiresActivation()) {
// Refuse to directCall any function with more
// than 32 parameters - prevent code explosion
// for wacky test cases
if (argCount <= 32) {
node.putProp(Node.DIRECTCALL_PROP, ofn);
if (!ofn.isTargetOfDirectCall()) {
int index = directCallTargets.size();
directCallTargets.add(ofn);
ofn.setDirectTargetIndex(index);
}
}
}
}
}
}
}
private Map<String, OptFunctionNode> possibleDirectCalls;
private ObjArray directCallTargets;
}
⏎ org/mozilla/javascript/optimizer/OptTransformer.java
Or download all of them as a single archive file:
File name: rhino-1.7.14-sources.jar File size: 1029165 bytes Release date: 2022-01-06 Download
⇒ Example code to Test rhino-runtime-1.7.14.jar
⇐ Download Rhino JavaScript Binary Package
2022-05-03, ≈133🔥, 1💬
Popular Posts:
JDK 17 jdk.internal.le.jmod is the JMOD file for JDK 17 Internal Line Editing module. JDK 17 Interna...
JDK 6 tools.jar is the JAR file for JDK 6 tools. It contains Java classes to support different JDK t...
What Is poi-ooxml-3.5.jar? poi-ooxml-3.5.jar is one of the JAR files for Apache POI 3.5, which provi...
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
commons-fileupload-1.3.3 -sources.jaris the source JAR file for Apache Commons FileUpload 1.3., whic...