Class VariableStruct
java.lang.Object
org.cloudburstmc.mojava.runtime.struct.VariableStruct
- Direct Known Subclasses:
ArrayStruct,ContextStruct
Two-segment variable/temp values (
v.x, t.y) are the hot read path. The compiler
resolves each name to a stable int slot (via slotFor(java.lang.String)) at compile time and reads it
with an array load instead of a HashMap.get.
The map stays the canonical store, so getMap(), for_each, dynamic keys and
nested structs behave exactly as before. slots is a write-through fast cache: every mutation
funnels through slotSet(int, java.lang.String, org.cloudburstmc.mojava.runtime.value.MoValue), so a slot read never goes stale. (External callers that mutate the
map directly via getMap().put(...) would bypass it — use setDirectly(java.lang.String, org.cloudburstmc.mojava.runtime.value.MoValue) instead.)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidvoidsetDirectly(String name, MoValue value) static intStable slot for a variable name, assigned once and shared across all structs/runtimes.slotGet(int slot) Fast read of a compile-time slot; null when unset (caller maps that to 0.0).voidWrite-through: updates both the slot cache and the canonical map.
-
Field Details
-
map
-
-
Constructor Details
-
VariableStruct
public VariableStruct()
-
-
Method Details
-
slotFor
Stable slot for a variable name, assigned once and shared across all structs/runtimes. -
slotGet
Fast read of a compile-time slot; null when unset (caller maps that to 0.0). -
slotSet
Write-through: updates both the slot cache and the canonical map. -
set
-
setDirectly
-
get
-
getRaw
-
clear
public void clear()
-