fixed objClass initialization in ObjInt.Zero, added Buffer.toBitInput, minimal descrription of Lynon

This commit is contained in:
sergeych committed 2025-08-17 23:51:50 +03:00
1 parent eefecae7b4
commit 835333dfad
8 files changed
+118 -15

No files matched your search

@@ -85,13 +85,15 @@ open class Obj {
name: String,
args: Arguments = Arguments.EMPTY,
onNotFoundResult: Obj?=null
): Obj =
objClass.getInstanceMemberOrNull(name)?.value?.invoke(
): Obj {
return objClass.getInstanceMemberOrNull(name)?.value?.invoke(
scope,
this,
args)
args
)
?: onNotFoundResult
?: scope.raiseSymbolNotFound(name)
}
open suspend fun getInstanceMethod(
scope: Scope,
@@ -24,6 +24,7 @@ import net.sergeych.bintools.encodeToHex
import net.sergeych.bintools.toDump
import net.sergeych.lyng.Scope
import net.sergeych.lyng.statement
import net.sergeych.lynon.BitArray
import net.sergeych.lynon.LynonDecoder
import net.sergeych.lynon.LynonEncoder
import net.sergeych.lynon.LynonType
@@ -200,6 +201,9 @@ open class ObjBuffer(val byteArray: UByteArray) : Obj() {
thisAs<ObjBuffer>().byteArray.toByteArray().toDump()
)
}
addFn("toBitInput") {
ObjBitBuffer(BitArray(thisAs<ObjBuffer>().byteArray, 8))
}
}
}
}
@@ -62,7 +62,7 @@ class ObjInt(var value: Long, override val isConst: Boolean = false) : Obj(), Nu
override fun toString(): String = value.toString()
override val objClass: ObjClass = type
override val objClass: ObjClass by lazy { type }
override suspend fun plus(scope: Scope, other: Obj): Obj =
if (other is ObjInt)