var _emptyPredictionContextHash … func init() { … } func calculateEmptyHash() int { … } const BasePredictionContextEmptyReturnState … var BasePredictionContextglobalNodeCount … var BasePredictionContextid … const PredictionContextEmpty … const PredictionContextSingleton … const PredictionContextArray … type PredictionContext … func NewEmptyPredictionContext() *PredictionContext { … } func NewBaseSingletonPredictionContext(parent *PredictionContext, returnState int) *PredictionContext { … } func SingletonBasePredictionContextCreate(parent *PredictionContext, returnState int) *PredictionContext { … } func NewArrayPredictionContext(parents []*PredictionContext, returnStates []int) *PredictionContext { … } func (p *PredictionContext) Hash() int { … } func (p *PredictionContext) Equals(other Collectable[*PredictionContext]) bool { … } func (p *PredictionContext) ArrayEquals(o Collectable[*PredictionContext]) bool { … } func (p *PredictionContext) SingletonEquals(other Collectable[*PredictionContext]) bool { … } func (p *PredictionContext) GetParent(i int) *PredictionContext { … } func (p *PredictionContext) getReturnState(i int) int { … } func (p *PredictionContext) GetReturnStates() []int { … } func (p *PredictionContext) length() int { … } func (p *PredictionContext) hasEmptyPath() bool { … } func (p *PredictionContext) String() string { … } func (p *PredictionContext) isEmpty() bool { … } func (p *PredictionContext) Type() int { … } func calculateHash(parent *PredictionContext, returnState int) int { … } // Convert a {@link RuleContext} tree to a {@link BasePredictionContext} graph. // Return {@link //EMPTY} if {@code outerContext} is empty or nil. // / func predictionContextFromRuleContext(a *ATN, outerContext RuleContext) *PredictionContext { … } func merge(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { … } func convertToArray(pc *PredictionContext) *PredictionContext { … } // mergeSingletons merges two Singleton [PredictionContext] instances. // // Stack tops equal, parents merge is same return left graph. // <embed src="images/SingletonMerge_SameRootSamePar.svg" // type="image/svg+xml"/></p> // // <p>Same stack top, parents differ merge parents giving array node, then // remainders of those graphs. A new root node is created to point to the // merged parents.<br> // <embed src="images/SingletonMerge_SameRootDiffPar.svg" // type="image/svg+xml"/></p> // // <p>Different stack tops pointing to same parent. Make array node for the // root where both element in the root point to the same (original) // parent.<br> // <embed src="images/SingletonMerge_DiffRootSamePar.svg" // type="image/svg+xml"/></p> // // <p>Different stack tops pointing to different parents. Make array node for // the root where each element points to the corresponding original // parent.<br> // <embed src="images/SingletonMerge_DiffRootDiffPar.svg" // type="image/svg+xml"/></p> // // @param a the first {@link SingletonBasePredictionContext} // @param b the second {@link SingletonBasePredictionContext} // @param rootIsWildcard {@code true} if this is a local-context merge, // otherwise false to indicate a full-context merge // @param mergeCache // / func mergeSingletons(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { … } // Handle case where at least one of {@code a} or {@code b} is // {@link //EMPTY}. In the following diagrams, the symbol {@code $} is used // to represent {@link //EMPTY}. // // <h2>Local-Context Merges</h2> // // <p>These local-context merge operations are used when {@code rootIsWildcard} // is true.</p> // // <p>{@link //EMPTY} is superset of any graph return {@link //EMPTY}.<br> // <embed src="images/LocalMerge_EmptyRoot.svg" type="image/svg+xml"/></p> // // <p>{@link //EMPTY} and anything is {@code //EMPTY}, so merged parent is // {@code //EMPTY} return left graph.<br> // <embed src="images/LocalMerge_EmptyParent.svg" type="image/svg+xml"/></p> // // <p>Special case of last merge if local context.<br> // <embed src="images/LocalMerge_DiffRoots.svg" type="image/svg+xml"/></p> // // <h2>Full-Context Merges</h2> // // <p>These full-context merge operations are used when {@code rootIsWildcard} // is false.</p> // // <p><embed src="images/FullMerge_EmptyRoots.svg" type="image/svg+xml"/></p> // // <p>Must keep all contexts {@link //EMPTY} in array is a special value (and // nil parent).<br> // <embed src="images/FullMerge_EmptyRoot.svg" type="image/svg+xml"/></p> // // <p><embed src="images/FullMerge_SameRoot.svg" type="image/svg+xml"/></p> // // @param a the first {@link SingletonBasePredictionContext} // @param b the second {@link SingletonBasePredictionContext} // @param rootIsWildcard {@code true} if this is a local-context merge, // otherwise false to indicate a full-context merge // / func mergeRoot(a, b *PredictionContext, rootIsWildcard bool) *PredictionContext { … } // Merge two {@link ArrayBasePredictionContext} instances. // // <p>Different tops, different parents.<br> // <embed src="images/ArrayMerge_DiffTopDiffPar.svg" type="image/svg+xml"/></p> // // <p>Shared top, same parents.<br> // <embed src="images/ArrayMerge_ShareTopSamePar.svg" type="image/svg+xml"/></p> // // <p>Shared top, different parents.<br> // <embed src="images/ArrayMerge_ShareTopDiffPar.svg" type="image/svg+xml"/></p> // // <p>Shared top, all shared parents.<br> // <embed src="images/ArrayMerge_ShareTopSharePar.svg" // type="image/svg+xml"/></p> // // <p>Equal tops, merge parents and reduce top to // {@link SingletonBasePredictionContext}.<br> // <embed src="images/ArrayMerge_EqualTop.svg" type="image/svg+xml"/></p> // //goland:noinspection GoBoolExpressions func mergeArrays(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { … } // Make pass over all M parents and merge any Equals() ones. // Note that we pass a pointer to the slice as we want to modify it in place. // //goland:noinspection GoUnusedFunction func combineCommonParents(parents *[]*PredictionContext) { … } func getCachedBasePredictionContext(context *PredictionContext, contextCache *PredictionContextCache, visited *VisitRecord) *PredictionContext { … }