Class RuntimeIndex

java.lang.Object
io.github.protasm.jvmud.compiler.runtime.RuntimeIndex

public final class RuntimeIndex extends Object
Runtime indexing helpers for dynamically typed LPC values.
  • Method Details

    • fromEnd

      public static Object fromEnd(int distance)
    • get

      public static Object get(Object target, int index)
    • get

      public static Object get(Object target, Object index)
      Reads a value through a dynamically typed LPC index target.

      Missing mapping keys evaluate as LPC false, represented by 0, rather than leaking Java null into generated LPC code.

    • get

      public static Object get(Object target, Object key, Object valueIndex)
      Reads an indexed mapping value slot such as mapping[key, 1].

      For non-mapping targets, only slot zero delegates to ordinary dynamic indexing. Other slots evaluate as LPC false.

    • set

      public static Object set(Object target, Object index, Object value)
      Stores a value through a dynamically typed LPC index target.
    • mutateNumber

      public static Object mutateNumber(Object target, Object index, int delta)
      Mutates a numeric indexed array or mapping value and returns the previous value for postfix operators.
    • mutateNumberPrefix

      public static Object mutateNumberPrefix(Object target, Object index, int delta)
      Mutates a numeric indexed array or mapping value and returns the updated value for prefix operators.
    • stringCharCode

      public static int stringCharCode(String text, Object index)
    • slice

      public static Object slice(Object target, Object startValue, Object endValue)
    • replaceSlice

      public static Object replaceSlice(Object target, Object startValue, Object endValue, Object replacement)
      Replaces an LPC array or string slice.

      Array targets are mutable and are updated in place. String targets produce a replacement string because Java strings are immutable; generated code stores that result back into the original local or field when compiling string slice assignment.