Top Inners Fields Constructors Methods
org.antlr.v4.runtime.atn

public abstract Class PredictionContext

extends Object
Class Inheritance
Known Direct Subclasses
org.antlr.v4.runtime.atn.SingletonPredictionContext, org.antlr.v4.runtime.atn.ArrayPredictionContext, org.antlr.v4.runtime.atn.EmptyPredictionContext
Imports
org.antlr.v4.runtime.Recognizer, .RuleContext, org.antlr.v4.runtime.misc.AbstractEqualityComparator, .FlexibleHashMap, .MurmurHash, .NotNull, java.util.ArrayList, .Arrays, .List, java.util.concurrent.ConcurrentMap

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
private final int
cachedHashCode

Stores the computed hash code of this PredictionContext.

public static final PredictionContext
public static final int
public static final PredictionContext
public static final int
private static final int

Constructor Summary

AccessConstructor and Description
protected
PredictionContext(int cachedHashCode)

Method Summary

Modifier and TypeMethod and Description
protected abstract PredictionContext
private static PredictionContext
public PredictionContext
appendContext(int returnContext, PredictionContextCache contextCache)

public abstract PredictionContext
protected static int
protected static int
calculateHashCode(PredictionContext parent, int returnState)

protected static int
calculateHashCode(PredictionContext[] parents, int[] returnStates)

public abstract boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public abstract int
findReturnState(int returnState)

public static PredictionContext
fromRuleContext(ATN atn, RuleContext outerContext)

public static PredictionContext
fromRuleContext(ATN atn, RuleContext outerContext, boolean fullContext)

public static PredictionContext
public PredictionContext
getChild(int returnState)

public abstract PredictionContext
getParent(int index)

public abstract int
getReturnState(int index)

public abstract boolean
public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public abstract boolean
public static boolean
public static PredictionContext
pack-priv static PredictionContext
join(final PredictionContext context0, final PredictionContext context1, PredictionContextCache contextCache)

protected abstract PredictionContext
private static PredictionContext
public abstract int
size()

public String[]
toStrings(Recognizer<?, ?> recognizer, int currentState)

public String[]
toStrings(Recognizer<?, ?> recognizer, PredictionContext stop, int currentState)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedHashCodeback to summary
private final int cachedHashCode

Stores the computed hash code of this PredictionContext. The hash code is computed in parts to match the following reference algorithm.

 private int referenceHashCode() {
     int hash = MurmurHash.initialize(INITIAL_HASH);

     for (int i = 0; i < size(); i++) {
         hash = MurmurHash.update(hash, getParent(i));
     }

     for (int i = 0; i < size(); i++) {
         hash = MurmurHash.update(hash, getReturnState(i));
     }

     hash = MurmurHash.finish(hash, 2 * size());
     return hash;
 }
EMPTY_FULLback to summary
public static final PredictionContext EMPTY_FULL
Annotations
@NotNull
EMPTY_FULL_STATE_KEYback to summary
public static final int EMPTY_FULL_STATE_KEY
EMPTY_LOCALback to summary
public static final PredictionContext EMPTY_LOCAL
Annotations
@NotNull
EMPTY_LOCAL_STATE_KEYback to summary
public static final int EMPTY_LOCAL_STATE_KEY
INITIAL_HASHback to summary
private static final int INITIAL_HASH

Constructor Detail

PredictionContextback to summary
protected PredictionContext(int cachedHashCode)

Method Detail

addEmptyContextback to summary
protected abstract PredictionContext addEmptyContext()
addEmptyContextback to summary
private static PredictionContext addEmptyContext(PredictionContext context)
appendContextback to summary
public PredictionContext appendContext(int returnContext, PredictionContextCache contextCache)
appendContextback to summary
public abstract PredictionContext appendContext(PredictionContext suffix, PredictionContextCache contextCache)
calculateEmptyHashCodeback to summary
protected static int calculateEmptyHashCode()
calculateHashCodeback to summary
protected static int calculateHashCode(PredictionContext parent, int returnState)
calculateHashCodeback to summary
protected static int calculateHashCode(PredictionContext[] parents, int[] returnStates)
equalsback to summary
public abstract boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findReturnStateback to summary
public abstract int findReturnState(int returnState)
fromRuleContextback to summary
public static PredictionContext fromRuleContext(ATN atn, RuleContext outerContext)
fromRuleContextback to summary
public static PredictionContext fromRuleContext(ATN atn, RuleContext outerContext, boolean fullContext)
getCachedContextback to summary
public static PredictionContext getCachedContext(PredictionContext context, ConcurrentMap<PredictionContext, PredictionContext> contextCache, PredictionContext.IdentityHashMap visited)
getChildback to summary
public PredictionContext getChild(int returnState)
getParentback to summary
public abstract PredictionContext getParent(int index)
Annotations
@NotNull
getReturnStateback to summary
public abstract int getReturnState(int index)
hasEmptyback to summary
public abstract boolean hasEmpty()
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isEmptyback to summary
public abstract boolean isEmpty()
isEmptyLocalback to summary
public static boolean isEmptyLocal(PredictionContext context)
joinback to summary
public static PredictionContext join(PredictionContext context0, PredictionContext context1)
joinback to summary
pack-priv static PredictionContext join(final PredictionContext context0, final PredictionContext context1, PredictionContextCache contextCache)
removeEmptyContextback to summary
protected abstract PredictionContext removeEmptyContext()
removeEmptyContextback to summary
private static PredictionContext removeEmptyContext(PredictionContext context)
sizeback to summary
public abstract int size()
toStringsback to summary
public String[] toStrings(Recognizer<?, ?> recognizer, int currentState)
toStringsback to summary
public String[] toStrings(Recognizer<?, ?> recognizer, PredictionContext stop, int currentState)
org.antlr.v4.runtime.atn back to summary

public final Class PredictionContext.IdentityEqualityComparator

extends AbstractEqualityComparator<PredictionContext>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PredictionContext.IdentityEqualityComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(PredictionContext
The first object to compare.
a
,
PredictionContext
The second object to compare.
b
)

Implements org.antlr.v4.runtime.misc.EqualityComparator.equals.

This method tests if two objects are equal.
public int
hashCode(PredictionContext
The object.
obj
)

Implements org.antlr.v4.runtime.misc.EqualityComparator.hashCode.

This method returns a hash code for the specified object.

Field Detail

INSTANCEback to summary
public static final PredictionContext.IdentityEqualityComparator INSTANCE

Constructor Detail

IdentityEqualityComparatorback to summary
private IdentityEqualityComparator()

Method Detail

equalsback to summary
public boolean equals(PredictionContext a, PredictionContext b)

Implements org.antlr.v4.runtime.misc.EqualityComparator.equals.

Doc from org.antlr.v4.runtime.misc.EqualityComparator.equals.

This method tests if two objects are equal.

Parameters
a:PredictionContext

The first object to compare.

b:PredictionContext

The second object to compare.

Returns:boolean

true if a equals b, otherwise false.

Annotations
@Override
hashCodeback to summary
public int hashCode(PredictionContext obj)

Implements org.antlr.v4.runtime.misc.EqualityComparator.hashCode.

Doc from org.antlr.v4.runtime.misc.EqualityComparator.hashCode.

This method returns a hash code for the specified object.

Parameters
obj:PredictionContext

The object.

Returns:int

The hash code for obj.

Annotations
@Override
org.antlr.v4.runtime.atn back to summary

public final Class PredictionContext.IdentityHashMap

extends FlexibleHashMap<PredictionContext, PredictionContext>
Class Inheritance

Field Summary

Inherited from org.antlr.v4.runtime.misc.FlexibleHashMap:
bucketscomparatorcurrentPrimeINITAL_BUCKET_CAPACITYINITAL_CAPACITYinitialBucketCapacityLOAD_FACTORnthreshold

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.antlr.v4.runtime.misc.FlexibleHashMap:
clearcontainsKeycontainsValueentrySetequalsexpandgetgetBuckethashCodeisEmptykeySetmainputputAllremovesizetoStringtoTableStringvalues

Constructor Detail

IdentityHashMapback to summary
public IdentityHashMap()