fixed namespace/Math issue

This commit is contained in:
Sergey Chernov 2025-06-02 06:28:40 +04:00
parent c65f711ee3
commit 939e391a20
2 changed files with 9 additions and 8 deletions

View File

@ -64,13 +64,10 @@ class Context(
return StoredObj(value, isMutable).also { objects.put(name, it) }
}
fun getOrCreateNamespace(name: String): ObjNamespace =
(objects.getOrPut(name) {
StoredObj(
ObjNamespace(name),
isMutable = false
)
}.value as ObjNamespace)
fun getOrCreateNamespace(name: String): ObjClass {
val ns = objects.getOrPut(name) { StoredObj(ObjNamespace(name), isMutable = false) }.value
return ns!!.objClass
}
inline fun addVoidFn(vararg names: String, crossinline fn: suspend Context.() -> Unit) {
addFn<ObjVoid>(*names) {

View File

@ -292,8 +292,12 @@ fun Obj.toBool(): Boolean =
data class ObjNamespace(val name: String) : Obj() {
override val objClass by lazy { ObjClass(name) }
override fun inspect(): String = "Ns[$name]"
override fun toString(): String {
return "namespace ${name}"
return "package $name"
}
}