JimCompiler

Compiles a JIM script (TypeScript / modern JS) straight to JVM bytecode using swc4j's ByteCodeCompiler. Scripts run as native JVM classes — every export function becomes a static method on the default $ class, and scripts reach the JIM API by importing our Kotlin objects by package, e.g. import { Jim, Event } from 'ratph6.jim.api'.

Because the compiler does not execute top-level statements, the source is first rewritten so any top-level code (e.g. Jim.register(...)) is moved into a generated __jimEntry() function that the engine runs on load — so scripts need neither a main() nor export. Two wrap strategies exist (see compile): a textual one (default; deterministic) and an AST one (fallback).

Types

Link copied to clipboard

Functions

Link copied to clipboard
fun check(source: String, fileName: String)
Link copied to clipboard
fun compile(source: String, fileName: String, parentClassLoader: ClassLoader): ByteCodeRunner

Compile source to runnable JVM classes (inlining Event.*, auto-wrapping top-level code).