package siilinkari.vm

import siilinkari.objects.Value

/**
 * Frame of local variables.
 */
class Frame(size: Int) {

    private val bindings = Array<Value>(size) { Value.Bool.False }

    /**
     * Assigns a new value to existing variable.
     */
    operator fun set(index: Int, value: Value) {
        bindings[index] = value
    }

    /**
     * Returns the value bound to given variable.
     */
    operator fun get(index: Int): Value =
        bindings[index]
}

package siilinkari.vm

import siilinkari.objects.Value

/**
 * Frame of local variables.
 */
class Frame(size: Int) {

    private val bindings = arrayOfNulls<Value?>(size)

    /**
     * Assigns a new value to existing variable.
     */
    operator fun set(index: Int, value: Value) {
        bindings[index] = value
    }

    /**
     * Returns the value bound to given variable.
     */
    operator fun get(index: Int): Value =
        bindings[index]!!
}

Initialize frame bindings to array of nulls
Initialize frame bindings to array of nulls

komu/siilinkari