Antlr4.Runtime.Atn.ATNSimulator.getCachedContext C# (CSharp) Method

getCachedContext() public method

public getCachedContext ( PredictionContext context ) : PredictionContext
context PredictionContext
return PredictionContext
        public PredictionContext getCachedContext(PredictionContext context)
        {
            if (sharedContextCache == null) return context;

            lock (sharedContextCache)
            {
                PredictionContext.IdentityHashMap visited =
                    new PredictionContext.IdentityHashMap();
                return PredictionContext.GetCachedContext(context,
                                                          sharedContextCache,
                                                          visited);
            }
        }

Usage Example

コード例 #1
0
ファイル: ATNConfigSet.cs プロジェクト: geektcp/alpha-antlr4
        public void OptimizeConfigs(ATNSimulator interpreter)
        {
            if (readOnly)
            {
                throw new Exception("This set is readonly");
            }
            if (configLookup.Count == 0)
            {
                return;
            }

            foreach (ATNConfig config in configs)
            {
                //			int before = PredictionContext.getAllContextNodes(config.context).size();
                config.context = interpreter.getCachedContext(config.context);
                //			int after = PredictionContext.getAllContextNodes(config.context).size();
                //			System.out.println("configs "+before+"->"+after);
            }
        }