优化
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
update fork / build (push) Has been cancelled

This commit is contained in:
Horis
2025-04-10 14:39:09 +08:00
parent 0aef05a5e4
commit f80c4965be
2 changed files with 4 additions and 24 deletions

View File

@@ -56,12 +56,6 @@ internal class RhinoCompiledScript(
override fun eval(scope: Scriptable, coroutineContext: CoroutineContext?): Any? {
val cx = Context.enter() as RhinoContext
try {
cx.checkRecursive()
} catch (e: RhinoRecursionError) {
Context.exit()
throw e
}
val previousCoroutineContext = cx.coroutineContext
if (coroutineContext != null && coroutineContext[Job] != null) {
cx.coroutineContext = coroutineContext
@@ -70,6 +64,7 @@ internal class RhinoCompiledScript(
cx.recursiveCount++
val result: Any?
try {
cx.checkRecursive()
val ret = script.exec(cx, scope)
result = engine.unwrapReturnValue(ret)
} catch (re: RhinoException) {
@@ -93,17 +88,12 @@ internal class RhinoCompiledScript(
override suspend fun evalSuspend(scope: Scriptable): Any? {
val cx = Context.enter() as RhinoContext
try {
cx.checkRecursive()
} catch (e: RhinoRecursionError) {
Context.exit()
throw e
}
var ret: Any?
withContext(VMBridgeReflect.contextLocal.asContextElement()) {
cx.allowScriptRun = true
cx.recursiveCount++
try {
cx.checkRecursive()
try {
ret = cx.executeScriptWithContinuations(script, scope)
} catch (e: ContinuationPending) {

View File

@@ -91,12 +91,6 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
coroutineContext: CoroutineContext?
): Any? {
val cx = Context.enter() as RhinoContext
try {
cx.checkRecursive()
} catch (e: RhinoRecursionError) {
Context.exit()
throw e
}
val previousCoroutineContext = cx.coroutineContext
if (coroutineContext != null && coroutineContext[Job] != null) {
cx.coroutineContext = coroutineContext
@@ -105,6 +99,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
cx.recursiveCount++
val ret: Any?
try {
cx.checkRecursive()
var filename = this["javax.script.filename"] as? String
filename = filename ?: "<Unknown source>"
ret = cx.evaluateReader(scope, reader, filename, 1, null)
@@ -132,17 +127,12 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
@Throws(ContinuationPending::class)
override suspend fun evalSuspend(reader: Reader, scope: Scriptable): Any? {
val cx = Context.enter() as RhinoContext
try {
cx.checkRecursive()
} catch (e: RhinoRecursionError) {
Context.exit()
throw e
}
var ret: Any?
withContext(VMBridgeReflect.contextLocal.asContextElement()) {
cx.allowScriptRun = true
cx.recursiveCount++
try {
cx.checkRecursive()
var filename = this@RhinoScriptEngine["javax.script.filename"] as? String
filename = filename ?: "<Unknown source>"
val script = cx.compileReader(reader, filename, 1, null)