Merge pull request #5 from moe-charm/codex/fix-infinite-loop-in-nyash-execution
Fix ConsoleStd print recursion when plugins are disabled
This commit is contained in:
@ -1,20 +1,26 @@
|
||||
// ConsoleStd — minimal standard console helpers (commonized API)
|
||||
|
||||
// Global helper to avoid name shadowing when invoking the language-level print.
|
||||
function __console_std_emit(value) {
|
||||
print(value)
|
||||
return 0
|
||||
}
|
||||
|
||||
static box ConsoleStd {
|
||||
// print/println/log: convert null to "" and return 0
|
||||
print(x) {
|
||||
if x == null { x = "" }
|
||||
print(x)
|
||||
__console_std_emit(x)
|
||||
return 0
|
||||
}
|
||||
println(x) {
|
||||
if x == null { x = "" }
|
||||
print(x)
|
||||
__console_std_emit(x)
|
||||
return 0
|
||||
}
|
||||
log(x) {
|
||||
if x == null { x = "" }
|
||||
print(x)
|
||||
__console_std_emit(x)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user