removed unnecessary debug traces
This commit is contained in:
parent
758f49603f
commit
9ae9752634
@ -501,10 +501,9 @@ class Compiler {
|
||||
var closure: Context? = null
|
||||
|
||||
val fnBody = statement(t.pos) { callerContext ->
|
||||
// remember closure where the function was defined:
|
||||
// restore closure where the function was defined:
|
||||
val context = closure ?: Context()
|
||||
// load params from caller context
|
||||
println("calling function $name in context $context <- ${context.parent}")
|
||||
for ((i, d) in params.withIndex()) {
|
||||
if (i < callerContext.args.size)
|
||||
context.addItem(d.name, false, callerContext.args.list[i].value)
|
||||
@ -523,9 +522,12 @@ class Compiler {
|
||||
fnStatements.execute(context)
|
||||
}
|
||||
return statement(start) { context ->
|
||||
println("adding function $name to context $context")
|
||||
// we added fn in the context. now we must save closure
|
||||
// for the function
|
||||
closure = context
|
||||
context.addItem(name, false, fnBody)
|
||||
// as the function can be called from anywhere, we have
|
||||
// saved the proper context in the closure
|
||||
fnBody
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ class Context(
|
||||
fun copy(args: Arguments = Arguments.EMPTY): Context = Context(this, args)
|
||||
|
||||
fun addItem(name: String, isMutable: Boolean, value: Obj?) {
|
||||
println("ading item $name=$value in $this <- ${this.parent}")
|
||||
objects.put(name, StoredObj(name, value, isMutable))
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,6 @@ class Script(
|
||||
) : Statement() {
|
||||
|
||||
override suspend fun execute(context: Context): Obj {
|
||||
// todo: run script
|
||||
println("exec script in $context <- ${context.parent}")
|
||||
var lastResult: Obj = ObjVoid
|
||||
for (s in statements) {
|
||||
lastResult = s.execute(context)
|
||||
|
@ -425,7 +425,6 @@ class ScriptTest {
|
||||
"""
|
||||
val count = 3
|
||||
val res = if( count > 10 ) "too much" else "just " + count
|
||||
println(res)
|
||||
res
|
||||
""".trimIndent()
|
||||
)
|
||||
@ -438,26 +437,10 @@ class ScriptTest {
|
||||
val count = 3
|
||||
var res = if( count > 10 ) "too much" else "it's " + count
|
||||
res = if( count > 10 ) "too much" else "just " + count
|
||||
println(res)
|
||||
res
|
||||
""".trimIndent()
|
||||
)
|
||||
.toString()
|
||||
)
|
||||
}
|
||||
@Test
|
||||
fun bookTest1() = runTest {
|
||||
// assertEquals(
|
||||
// "just 3",
|
||||
eval(
|
||||
"""
|
||||
val count = 3
|
||||
println(
|
||||
if( count > 10 ) "too much" else "just " + count
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
// .toString()
|
||||
// )
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user