Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions runtime/Go/antlr/atn_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
)

type Comparable interface {
type comparable interface {
equals(other interface{}) bool
}

Expand All @@ -18,9 +18,9 @@ type Comparable interface {
// state. The semantic context is the tree of semantic predicates encountered
// before reaching an ATN state.
type ATNConfig interface {
Comparable
comparable

HashCode() int
hash() int

GetState() ATNState
GetAlt() int
Expand Down Expand Up @@ -166,18 +166,18 @@ func (b *BaseATNConfig) equals(o interface{}) bool {
return nums && alts && cons && sups && equal
}

func (b *BaseATNConfig) HashCode() int {
func (b *BaseATNConfig) hash() int {
var c int
if b.context != nil {
c = b.context.HashCode()
c = b.context.hash()
}

h := initHash(7)
h = update(h, b.state.GetStateNumber())
h = update(h, b.alt)
h = update(h, c)
h = update(h, b.semanticContext.HashCode())
return finish(h, 4)
h := murmurInit(7)
h = murmurUpdate(h, b.state.GetStateNumber())
h = murmurUpdate(h, b.alt)
h = murmurUpdate(h, c)
h = murmurUpdate(h, b.semanticContext.hash())
return murmurFinish(h, 4)
}

func (b *BaseATNConfig) String() string {
Expand Down Expand Up @@ -243,21 +243,21 @@ func NewLexerATNConfig1(state ATNState, alt int, context PredictionContext) *Lex
return &LexerATNConfig{BaseATNConfig: NewBaseATNConfig5(state, alt, context, SemanticContextNone)}
}

func (l *LexerATNConfig) HashCode() int {
func (l *LexerATNConfig) hash() int {
var f int
if l.passedThroughNonGreedyDecision {
f = 1
} else {
f = 0
}
h := initHash(7)
h = update(h, l.state.HashCode())
h = update(h, l.alt)
h = update(h, l.context.HashCode())
h = update(h, l.semanticContext.HashCode())
h = update(h, f)
h = update(h, l.lexerActionExecutor.HashCode())
h = finish(h, 6)
h := murmurInit(7)
h = murmurUpdate(h, l.state.hash())
h = murmurUpdate(h, l.alt)
h = murmurUpdate(h, l.context.hash())
h = murmurUpdate(h, l.semanticContext.hash())
h = murmurUpdate(h, f)
h = murmurUpdate(h, l.lexerActionExecutor.hash())
h = murmurFinish(h, 6)
return h
}

Expand Down
10 changes: 5 additions & 5 deletions runtime/Go/antlr/atn_config_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package antlr
import "fmt"

type ATNConfigSet interface {
HashCode() int
hash() int
Add(ATNConfig, *DoubleDict) bool
AddAll([]ATNConfig) bool

Expand Down Expand Up @@ -223,7 +223,7 @@ func (b *BaseATNConfigSet) Equals(other interface{}) bool {
b.dipsIntoOuterContext == other2.dipsIntoOuterContext
}

func (b *BaseATNConfigSet) HashCode() int {
func (b *BaseATNConfigSet) hash() int {
if b.readOnly {
if b.cachedHash == -1 {
b.cachedHash = b.hashCodeConfigs()
Expand All @@ -236,13 +236,13 @@ func (b *BaseATNConfigSet) HashCode() int {
}

func (b *BaseATNConfigSet) hashCodeConfigs() int {
h := initHash(1)
h := murmurInit(1)
for _, c := range b.configs {
if c != nil {
h = update(h, c.HashCode())
h = murmurUpdate(h, c.hash())
}
}
return finish(h, len(b.configs))
return murmurFinish(h, len(b.configs))
}

func (b *BaseATNConfigSet) Length() int {
Expand Down
4 changes: 2 additions & 2 deletions runtime/Go/antlr/atn_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ATNState interface {
AddTransition(Transition, int)

String() string
HashCode() int
hash() int
}

type BaseATNState struct {
Expand Down Expand Up @@ -123,7 +123,7 @@ func (as *BaseATNState) SetNextTokenWithinRule(v *IntervalSet) {
as.NextTokenWithinRule = v
}

func (as *BaseATNState) HashCode() int {
func (as *BaseATNState) hash() int {
return as.stateNumber
}

Expand Down
14 changes: 7 additions & 7 deletions runtime/Go/antlr/dfa_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,23 @@ func (d *DFAState) String() string {
return fmt.Sprintf("%d:%s%s", fmt.Sprint(d.configs), s)
}

func (d *DFAState) HashCode() int {
h := initHash(11)
func (d *DFAState) hash() int {
h := murmurInit(11)

c := 1
if d.isAcceptState {
if d.predicates != nil {
for _, p := range d.predicates {
h = update(h, p.alt)
h = update(h, p.pred.HashCode())
h = murmurUpdate(h, p.alt)
h = murmurUpdate(h, p.pred.hash())
c += 2
}
} else {
h = update(h, d.prediction)
h = murmurUpdate(h, d.prediction)
c += 1
}
}

h = update(h, d.configs.HashCode())
return finish(h, c)
h = murmurUpdate(h, d.configs.hash())
return murmurFinish(h, c)
}
68 changes: 34 additions & 34 deletions runtime/Go/antlr/lexer_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type LexerAction interface {
getActionType() int
getIsPositionDependent() bool
execute(lexer Lexer)
HashCode() int
hash() int
equals(other LexerAction) bool
}

Expand Down Expand Up @@ -51,7 +51,7 @@ func (b *BaseLexerAction) getIsPositionDependent() bool {
return b.isPositionDependent
}

func (b *BaseLexerAction) HashCode() int {
func (b *BaseLexerAction) hash() int {
return b.actionType
}

Expand Down Expand Up @@ -104,11 +104,11 @@ func (l *LexerTypeAction) execute(lexer Lexer) {
lexer.setType(l.thetype)
}

func (l *LexerTypeAction) HashCode() int {
h := initHash(0)
h = update(h, l.actionType)
h = update(h, l.thetype)
return finish(h, 2)
func (l *LexerTypeAction) hash() int {
h := murmurInit(0)
h = murmurUpdate(h, l.actionType)
h = murmurUpdate(h, l.thetype)
return murmurFinish(h, 2)
}

func (l *LexerTypeAction) equals(other LexerAction) bool {
Expand Down Expand Up @@ -148,11 +148,11 @@ func (l *LexerPushModeAction) execute(lexer Lexer) {
lexer.pushMode(l.mode)
}

func (l *LexerPushModeAction) HashCode() int {
h := initHash(0)
h = update(h, l.actionType)
h = update(h, l.mode)
return finish(h, 2)
func (l *LexerPushModeAction) hash() int {
h := murmurInit(0)
h = murmurUpdate(h, l.actionType)
h = murmurUpdate(h, l.mode)
return murmurFinish(h, 2)
}

func (l *LexerPushModeAction) equals(other LexerAction) bool {
Expand Down Expand Up @@ -245,11 +245,11 @@ func (l *LexerModeAction) execute(lexer Lexer) {
lexer.setMode(l.mode)
}

func (l *LexerModeAction) HashCode() int {
h := initHash(0)
h = update(h, l.actionType)
h = update(h, l.mode)
return finish(h, 2)
func (l *LexerModeAction) hash() int {
h := murmurInit(0)
h = murmurUpdate(h, l.actionType)
h = murmurUpdate(h, l.mode)
return murmurFinish(h, 2)
}

func (l *LexerModeAction) equals(other LexerAction) bool {
Expand Down Expand Up @@ -303,12 +303,12 @@ func (l *LexerCustomAction) execute(lexer Lexer) {
lexer.Action(nil, l.ruleIndex, l.actionIndex)
}

func (l *LexerCustomAction) HashCode() int {
h := initHash(0)
h = update(h, l.actionType)
h = update(h, l.ruleIndex)
h = update(h, l.actionIndex)
return finish(h, 3)
func (l *LexerCustomAction) hash() int {
h := murmurInit(0)
h = murmurUpdate(h, l.actionType)
h = murmurUpdate(h, l.ruleIndex)
h = murmurUpdate(h, l.actionIndex)
return murmurFinish(h, 3)
}

func (l *LexerCustomAction) equals(other LexerAction) bool {
Expand Down Expand Up @@ -344,11 +344,11 @@ func (l *LexerChannelAction) execute(lexer Lexer) {
lexer.setChannel(l.channel)
}

func (l *LexerChannelAction) HashCode() int {
h := initHash(0)
h = update(h, l.actionType)
h = update(h, l.channel)
return finish(h, 2)
func (l *LexerChannelAction) hash() int {
h := murmurInit(0)
h = murmurUpdate(h, l.actionType)
h = murmurUpdate(h, l.channel)
return murmurFinish(h, 2)
}

func (l *LexerChannelAction) equals(other LexerAction) bool {
Expand Down Expand Up @@ -412,12 +412,12 @@ func (l *LexerIndexedCustomAction) execute(lexer Lexer) {
l.lexerAction.execute(lexer)
}

func (l *LexerIndexedCustomAction) HashCode() int {
h := initHash(0)
h = update(h, l.actionType)
h = update(h, l.offset)
h = update(h, l.lexerAction.HashCode())
return finish(h, 3)
func (l *LexerIndexedCustomAction) hash() int {
h := murmurInit(0)
h = murmurUpdate(h, l.actionType)
h = murmurUpdate(h, l.offset)
h = murmurUpdate(h, l.lexerAction.hash())
return murmurFinish(h, 3)
}

func (l *LexerIndexedCustomAction) equals(other LexerAction) bool {
Expand Down
6 changes: 3 additions & 3 deletions runtime/Go/antlr/lexer_action_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func NewLexerActionExecutor(lexerActions []LexerAction) *LexerActionExecutor {

// Caches the result of {@link //hashCode} since the hash code is an element
// of the performance-critical {@link LexerATNConfig//hashCode} operation.
l.cachedHash = initHash(57)
l.cachedHash = murmurInit(57)
for _, a := range lexerActions {
l.cachedHash = update(l.cachedHash, a.HashCode())
l.cachedHash = murmurUpdate(l.cachedHash, a.hash())
}

return l
Expand Down Expand Up @@ -151,7 +151,7 @@ func (l *LexerActionExecutor) execute(lexer Lexer, input CharStream, startIndex
}
}

func (l *LexerActionExecutor) HashCode() int {
func (l *LexerActionExecutor) hash() int {
if l == nil {
return 61
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/Go/antlr/lexer_atn_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func (l *LexerATNSimulator) addDFAState(configs ATNConfigSet) *DFAState {
proposed.lexerActionExecutor = firstConfigWithRuleStopState.(*LexerATNConfig).lexerActionExecutor
proposed.setPrediction(l.atn.ruleToTokenType[firstConfigWithRuleStopState.GetState().GetRuleIndex()])
}
hash := proposed.HashCode()
hash := proposed.hash()
dfa := l.decisionToDFA[l.mode]
existing := dfa.GetStates()[hash]
if existing != nil {
Expand Down
2 changes: 1 addition & 1 deletion runtime/Go/antlr/parser_atn_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ func (p *ParserATNSimulator) addDFAState(dfa *DFA, D *DFAState) *DFAState {
if D == ATNSimulatorError {
return D
}
hash := D.HashCode()
hash := D.hash()
var existing, ok = dfa.GetStates()[hash]
if ok {
return existing
Expand Down
Loading