Class RuntimeCollectionTransform
java.lang.Object
io.github.protasm.jvmud.compiler.runtime.RuntimeCollectionTransform
Runtime helpers for LPC collection callbacks.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Objectfilter(Object source, RuntimeCallable callback, Object[] extras, RuntimeContext runtime) Applies LPCfilter()semantics to arrays, strings, and mappings.static Objectmap(Object source, RuntimeCallable callback, Object[] extras, RuntimeContext runtime) Applies LPCmap()semantics to arrays, strings, and mappings.static ObjectsortArray(Object source, RuntimeCallable callback, Object[] extras, RuntimeContext runtime) Applies callable-form LPCsort_array()semantics.
-
Method Details
-
filter
public static Object filter(Object source, RuntimeCallable callback, Object[] extras, RuntimeContext runtime) Applies LPCfilter()semantics to arrays, strings, and mappings.Mappings are filtered as key/value pairs and return a mapping. Other iterable values keep the existing JVMud behavior: each item is passed as the first callback argument and matching items are returned as an array.
-
map
public static Object map(Object source, RuntimeCallable callback, Object[] extras, RuntimeContext runtime) Applies LPCmap()semantics to arrays, strings, and mappings.Mappings are traversed as key/value pairs and return a mapping with the original keys and transformed values. Other iterable values return an array of callback results.
-
sortArray
public static Object sortArray(Object source, RuntimeCallable callback, Object[] extras, RuntimeContext runtime) Applies callable-form LPCsort_array()semantics.The callback receives the two candidate values as
$1and$2. Additional arguments are forwarded starting at$3. A truthy callback result swaps the two candidate values, matching the selection-sort behavior historically used by JVMud's compiler lowering forsort_array(values, (: ... :)).
-