Auxiliary libraries for Scala Native runtime providing essential runtime support including boxed types, concurrent collections, and utility functions
—
Abstract base classes and utilities for Scala's numeric type hierarchy, providing foundation for custom numeric types and mathematical operations. Includes runtime utilities, hash functions, and function interoperability support.
import scala.math.ScalaNumber
import scala.runtime.Statics
import scala.runtime.function.{JProcedure0, JProcedure1, JProcedure2} // Scala 3 only
import scala.scalanative.runtime.BoxedUnitAbstract base class for Scala's numeric type hierarchy.
abstract class ScalaNumber extends java.lang.Number {
protected def isWhole(): Boolean
def underlying(): Object
}Core runtime utilities for hashing, memory operations, and error handling.
object Statics {
// Hash functions
def mix(hash: Int, data: Int): Int
def mixLast(hash: Int, data: Int): Int
def finalizeHash(hash: Int, length: Int): Int
def avalanche(h: Int): Int
def longHash(lv: Long): Int
def longHashShifted(lv: Long): Int
def doubleHash(dv: Double): Int
def floatHash(fv: Float): Int
def anyHash(x: Object): Int
// Utilities
def pfMarker: java.lang.Object
def releaseFence(): Unit
def ioobe[T](n: Int): T
}Java-compatible procedure traits that return Unit but integrate with Java Function interfaces.
trait JProcedure0 extends scala.Function0[Object] with java.io.Serializable {
def applyVoid(): Unit
def apply(): Object
}
trait JProcedure1[T1] extends scala.Function1[T1, Object] with java.io.Serializable {
def applyVoid(t1: T1): Unit
def apply(t1: T1): Object
}
trait JProcedure2[T1, T2] extends scala.Function2[T1, T2, Object] with java.io.Serializable {
def applyVoid(t1: T1, t2: T2): Unit
def apply(t1: T1, t2: T2): Object
}
// ... Additional JProcedure traits from JProcedure3 to JProcedure22Marker class for trait initialization support.
class TraitSetterScala Native-specific BoxedUnit implementation.
object BoxedUnit extends scala.runtime.BoxedUnitimport scala.math.ScalaNumber
import scala.runtime.Statics
// Extending ScalaNumber for custom numeric types
class MyNumber(value: Double) extends ScalaNumber {
protected def isWhole(): Boolean = value == value.toLong
def underlying(): Object = Double.box(value)
def intValue(): Int = value.toInt
def longValue(): Long = value.toLong
def floatValue(): Float = value.toFloat
def doubleValue(): Double = value
}
// Using hash functions
val hash1 = Statics.mix(0, 42)
val hash2 = Statics.longHash(123456789L)
val hash3 = Statics.doubleHash(3.14159)
val anyHash = Statics.anyHash("hello")
// Using JProcedure traits (Scala 3)
import scala.runtime.function.JProcedure1
class MyProcedure extends JProcedure1[String] {
def applyVoid(s: String): Unit = println(s"Processing: $s")
}
val proc = new MyProcedure()
proc.applyVoid("test") // Prints: Processing: test
val result = proc.apply("test") // Returns BoxedUnit.UNITThe Statics object provides optimized hash functions used internally by the Scala Native runtime:
mix and mixLast: MurmurHash3-based mixing functionsfinalizeHash and avalanche: Hash finalization with bit avalanchingLong, Double, Float with proper handling of special valuesanyHash: Universal hash function for any object with null safetyThe JProcedure traits (available in Scala 3) provide Java interoperability for functions that return Unit:
JProcedure0 through JProcedure22 support 0-22 parametersFunction traitapplyVoid method performs the actual Unit-returning operationapply method wraps the result in BoxedUnit.UNIT for Java compatibilityInstall with Tessl CLI
npx tessl i tessl/maven-org-scala-native--auxlib-native0-5-3