[Swift] Make ATNSimulator.sharedContextCache non-optional.
Make ATNSimulator.sharedContextCache declared as non-optional. It was used this way anyway, so it was just being pointlessly forced at the use-sites.
This commit is contained in:
parent
b4c34da1f0
commit
4baedb5e7b
|
@ -1022,11 +1022,10 @@ open class Parser: Recognizer<ParserATNSimulator> {
|
|||
if !(interp is ProfilingATNSimulator) {
|
||||
setInterpreter(ProfilingATNSimulator(self))
|
||||
}
|
||||
} else {
|
||||
if interp is ProfilingATNSimulator {
|
||||
let sim = ParserATNSimulator(self, getATN(), interp.decisionToDFA, interp.getSharedContextCache()!)
|
||||
setInterpreter(sim)
|
||||
}
|
||||
}
|
||||
else if interp is ProfilingATNSimulator {
|
||||
let sim = ParserATNSimulator(self, getATN(), interp.decisionToDFA, interp.getSharedContextCache())
|
||||
setInterpreter(sim)
|
||||
}
|
||||
getInterpreter().setPredictionMode(saveMode)
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ open class ATNSimulator {
|
|||
/// more time I think and doesn't save on the overall footprint
|
||||
/// so it's not worth the complexity.
|
||||
///
|
||||
internal final var sharedContextCache: PredictionContextCache?
|
||||
internal let sharedContextCache: PredictionContextCache
|
||||
|
||||
public init(_ atn: ATN,
|
||||
_ sharedContextCache: PredictionContextCache) {
|
||||
|
@ -68,21 +68,17 @@ open class ATNSimulator {
|
|||
throw ANTLRError.unsupportedOperation(msg: "This ATN simulator does not support clearing the DFA. ")
|
||||
}
|
||||
|
||||
open func getSharedContextCache() -> PredictionContextCache? {
|
||||
open func getSharedContextCache() -> PredictionContextCache {
|
||||
return sharedContextCache
|
||||
}
|
||||
|
||||
open func getCachedContext(_ context: PredictionContext) -> PredictionContext {
|
||||
if sharedContextCache == nil {
|
||||
return context
|
||||
}
|
||||
|
||||
//TODO: synced (sharedContextCache!)
|
||||
//synced (sharedContextCache!) {
|
||||
let visited = HashMap<PredictionContext, PredictionContext>()
|
||||
|
||||
return PredictionContext.getCachedContext(context,
|
||||
sharedContextCache!,
|
||||
sharedContextCache,
|
||||
visited)
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ProfilingATNSimulator: ParserATNSimulator {
|
|||
super.init(parser,
|
||||
parser.getInterpreter().atn,
|
||||
parser.getInterpreter().decisionToDFA,
|
||||
parser.getInterpreter().sharedContextCache!)
|
||||
parser.getInterpreter().sharedContextCache)
|
||||
|
||||
numDecisions = atn.decisionToState.count
|
||||
for i in 0..<numDecisions {
|
||||
|
|
Loading…
Reference in New Issue