Class ReachConfigSource
ParserATNSimulator.computeTargetState(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.dfa.DFAState, org.antlr.v4.runtime.ParserRuleContext, int, boolean, org.antlr.v4.runtime.atn.PredictionContextCache) invocation.
Starts as a zero-allocation view over the source ATNConfigSet. When
full-context prediction must rewrite every config with an appended return
state, the view materializes a mutable list once and all subsequent reads go
through that list. Callers iterate with size() / get(int)
only — no dual-null checks in the reach loop.
PERF: A single instance is retained on ReachComputation (one per
ParserATNSimulator) and rebound via
reset(ATNConfigSet)/release() around each edge so the
view object and the full-context rewrite ArrayList keep capacity
across predictions. SLL paths never touch the list.
Package-private: owned by the ATN prediction hot path.
-
Field Summary
FieldsModifier and TypeFieldDescriptionActive read source after the firstappendContext(int, org.antlr.v4.runtime.atn.PredictionContextCache);nullwhile still viewingsetdirectly.Capacity-preserving rewrite buffer.private ATNConfigSet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidappendContext(int returnState, PredictionContextCache contextCache) AppendsreturnStateto every configuration's prediction context.(package private) ATNConfigget(int index) (package private) booleanWhether this source has materialized a mutable list (full-context rewrite path).(package private) voidrelease()Drop config-graph references held by the rewrite buffer; keep list capacity.(package private) voidreset(ATNConfigSet set) Bind this source tosetfor a new edge computation.Retained rewrite scratch after first materialization, elsenull.(package private) intsize()
-
Field Details
-
set
-
list
Active read source after the firstappendContext(int, org.antlr.v4.runtime.atn.PredictionContextCache);nullwhile still viewingsetdirectly. -
rewriteScratch
-
-
Constructor Details
-
ReachConfigSource
ReachConfigSource()
-
-
Method Details
-
reset
Bind this source tosetfor a new edge computation. Always starts as a zero-copy view (no materialization). -
release
void release()Drop config-graph references held by the rewrite buffer; keep list capacity. Safe to call whenreset(org.antlr.v4.runtime.atn.ATNConfigSet)was never invoked.After
release(), this view is invalid until the nextreset(ATNConfigSet).size()/get(int)throwIllegalStateExceptionif used while unbound. -
size
int size() -
get
-
appendContext
AppendsreturnStateto every configuration's prediction context. Materializes a mutable copy of the source set on first call, reusing the retained rewrite scratch list when available. -
isMaterialized
boolean isMaterialized()Whether this source has materialized a mutable list (full-context rewrite path). Package-private for tests. -
rewriteScratch
Retained rewrite scratch after first materialization, elsenull. Same-package tests may observe capacity-preserving reuse.
-