|
@@ -43,6 +43,7 @@ import java.security.*
|
|
|
* @author A. Sundararajan
|
|
* @author A. Sundararajan
|
|
|
* @since 1.6
|
|
* @since 1.6
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Suppress("MemberVisibilityCanBePrivate")
|
|
|
class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|
class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|
|
var accessContext: AccessControlContext? = null
|
|
var accessContext: AccessControlContext? = null
|
|
|
private var topLevel: RhinoTopLevel? = null
|
|
private var topLevel: RhinoTopLevel? = null
|
|
@@ -120,12 +121,11 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|
|
val localScope = if (thiz1 != null) thiz1 as Scriptable else engineScope
|
|
val localScope = if (thiz1 != null) thiz1 as Scriptable else engineScope
|
|
|
val obj = ScriptableObject.getProperty(localScope, name) as? Function
|
|
val obj = ScriptableObject.getProperty(localScope, name) as? Function
|
|
|
?: throw NoSuchMethodException("no such method: $name")
|
|
?: throw NoSuchMethodException("no such method: $name")
|
|
|
- val func = obj
|
|
|
|
|
- var scope = func.parentScope
|
|
|
|
|
|
|
+ var scope = obj.parentScope
|
|
|
if (scope == null) {
|
|
if (scope == null) {
|
|
|
scope = engineScope
|
|
scope = engineScope
|
|
|
}
|
|
}
|
|
|
- val result = func.call(cx, scope, localScope, wrapArguments(args as? Array<Any?>))
|
|
|
|
|
|
|
+ val result = obj.call(cx, scope, localScope, wrapArguments(args as? Array<Any?>))
|
|
|
var11 = unwrapReturnValue(result)!!
|
|
var11 = unwrapReturnValue(result)!!
|
|
|
} catch (re: RhinoException) {
|
|
} catch (re: RhinoException) {
|
|
|
val line = if (re.lineNumber() == 0) -1 else re.lineNumber()
|
|
val line = if (re.lineNumber() == 0) -1 else re.lineNumber()
|
|
@@ -299,7 +299,9 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Suppress("unused")
|
|
|
companion object {
|
|
companion object {
|
|
|
|
|
+
|
|
|
private const val DEBUG = false
|
|
private const val DEBUG = false
|
|
|
|
|
|
|
|
@Language("js")
|
|
@Language("js")
|
|
@@ -324,6 +326,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|
|
|
|
|
|
|
init {
|
|
init {
|
|
|
ContextFactory.initGlobal(object : ContextFactory() {
|
|
ContextFactory.initGlobal(object : ContextFactory() {
|
|
|
|
|
+
|
|
|
override fun makeContext(): Context {
|
|
override fun makeContext(): Context {
|
|
|
val cx = super.makeContext()
|
|
val cx = super.makeContext()
|
|
|
cx.languageVersion = 200
|
|
cx.languageVersion = 200
|