package moe.nea.lisp class StackFrame(val parent: StackFrame?) { val variables = mutableMapOf() interface MetaKey private val meta: MutableMap, Any> = mutableMapOf() fun getMeta(key: MetaKey): T? { return meta[key]?.let { it as T } ?: parent?.meta?.get(key)?.let { it as T } } fun reportError(name: String, position: HasLispPosition): LispData.LispNil { OutputCapture.print(this, "Error: $name ${position.position}\n") return LispData.LispNil } fun setMeta(key: MetaKey, value: T) { meta[key] = value } fun resolveReference(label: String): LispData? = variables[label] ?: parent?.resolveReference(label) fun setValueLocal(label: String, value: LispData): LispData { variables[label] = value return value } fun fork(): StackFrame { return StackFrame(this) } }