fixed namespace/Math issue
This commit is contained in:
		
							parent
							
								
									c65f711ee3
								
							
						
					
					
						commit
						939e391a20
					
				@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user