Env

class Env(val parent: Env? = null)

A lexically-scoped symbol table that maps MiniKotlin source names to their generated Java names and VarType.

Each syntactic block creates a child Env(parent) so that bindings introduced inside the block do not leak into the enclosing scope. Lookup walks the parent chain, so inner scopes can read bindings from outer scopes.

Example scope chain for:

fun f(x: Int): Int {        // Env A: x -> (x, PARAM)
var y: Int = x + 1 // Env B (child of A): y -> (y_0, VAR)
return y
}

Constructors

Link copied to clipboard
constructor(parent: Env? = null)

Properties

Link copied to clipboard
val parent: Env? = null

The enclosing scope, or null for the top-level function scope.

Functions

Link copied to clipboard
fun define(name: String, javaName: String, kind: VarType)

Registers name in this scope.

Link copied to clipboard

Resolves name by searching this scope and then each ancestor.