优化
This commit is contained in:
@@ -56,7 +56,12 @@ internal class RhinoCompiledScript(
|
|||||||
|
|
||||||
override fun eval(scope: Scriptable, coroutineContext: CoroutineContext?): Any? {
|
override fun eval(scope: Scriptable, coroutineContext: CoroutineContext?): Any? {
|
||||||
val cx = Context.enter() as RhinoContext
|
val cx = Context.enter() as RhinoContext
|
||||||
cx.checkRecursive()
|
try {
|
||||||
|
cx.checkRecursive()
|
||||||
|
} catch (e: RhinoRecursionError) {
|
||||||
|
Context.exit()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
val previousCoroutineContext = cx.coroutineContext
|
val previousCoroutineContext = cx.coroutineContext
|
||||||
if (coroutineContext != null && coroutineContext[Job] != null) {
|
if (coroutineContext != null && coroutineContext[Job] != null) {
|
||||||
cx.coroutineContext = coroutineContext
|
cx.coroutineContext = coroutineContext
|
||||||
@@ -88,6 +93,12 @@ internal class RhinoCompiledScript(
|
|||||||
|
|
||||||
override suspend fun evalSuspend(scope: Scriptable): Any? {
|
override suspend fun evalSuspend(scope: Scriptable): Any? {
|
||||||
val cx = Context.enter() as RhinoContext
|
val cx = Context.enter() as RhinoContext
|
||||||
|
try {
|
||||||
|
cx.checkRecursive()
|
||||||
|
} catch (e: RhinoRecursionError) {
|
||||||
|
Context.exit()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
var ret: Any?
|
var ret: Any?
|
||||||
withContext(VMBridgeReflect.contextLocal.asContextElement()) {
|
withContext(VMBridgeReflect.contextLocal.asContextElement()) {
|
||||||
cx.allowScriptRun = true
|
cx.allowScriptRun = true
|
||||||
|
|||||||
@@ -91,7 +91,12 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|||||||
coroutineContext: CoroutineContext?
|
coroutineContext: CoroutineContext?
|
||||||
): Any? {
|
): Any? {
|
||||||
val cx = Context.enter() as RhinoContext
|
val cx = Context.enter() as RhinoContext
|
||||||
cx.checkRecursive()
|
try {
|
||||||
|
cx.checkRecursive()
|
||||||
|
} catch (e: RhinoRecursionError) {
|
||||||
|
Context.exit()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
val previousCoroutineContext = cx.coroutineContext
|
val previousCoroutineContext = cx.coroutineContext
|
||||||
if (coroutineContext != null && coroutineContext[Job] != null) {
|
if (coroutineContext != null && coroutineContext[Job] != null) {
|
||||||
cx.coroutineContext = coroutineContext
|
cx.coroutineContext = coroutineContext
|
||||||
@@ -127,7 +132,12 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|||||||
@Throws(ContinuationPending::class)
|
@Throws(ContinuationPending::class)
|
||||||
override suspend fun evalSuspend(reader: Reader, scope: Scriptable): Any? {
|
override suspend fun evalSuspend(reader: Reader, scope: Scriptable): Any? {
|
||||||
val cx = Context.enter() as RhinoContext
|
val cx = Context.enter() as RhinoContext
|
||||||
cx.checkRecursive()
|
try {
|
||||||
|
cx.checkRecursive()
|
||||||
|
} catch (e: RhinoRecursionError) {
|
||||||
|
Context.exit()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
var ret: Any?
|
var ret: Any?
|
||||||
withContext(VMBridgeReflect.contextLocal.asContextElement()) {
|
withContext(VMBridgeReflect.contextLocal.asContextElement()) {
|
||||||
cx.allowScriptRun = true
|
cx.allowScriptRun = true
|
||||||
|
|||||||
Reference in New Issue
Block a user