Blamite.Blam.Scripting.Compiler.ScriptCompiler.EnterHsc C# (CSharp) Метод

EnterHsc() публичный Метод

Generate script and global lookups.
public EnterHsc ( HS_Gen1Parser.HscContext context ) : void
context HS_Gen1Parser.HscContext
Результат void
        public override void EnterHsc(HS_Gen1Parser.HscContext context)
        {
            // Generate the globals lookup.
            if (context.globalDeclaration() != null)
            {
                _mapGlobalsLookup = context.globalDeclaration().Select((g, index) => new GlobalInfo(g, (ushort)index)).ToDictionary(g => g.Name);

            }

            // Generate the script lookup and determine the index, which the next generated branch script will have.
            var declarations = context.scriptDeclaration();
            if (declarations != null)
            {
                _nextGenBranchIndex = (ushort)declarations.Length;
                _scriptLookup = new Dictionary<string, List<ScriptInfo>>();

                for(ushort i = 0; i < context.scriptDeclaration().Length; i++)
                {
                    var info = new ScriptInfo(declarations[i], i);
                    AddScriptToLookup(info);
                }
            }

            // The declaration count is used to calculate the current progress.
            _declarationCount = context.scriptDeclaration().Length + context.globalDeclaration().Length;

            // Find all missing carriage returns. Somehow antlr removes them under certain circumstances and messes up the text position indeces.
            string text = context.Start.InputStream.GetText(new Interval(0, context.Start.InputStream.Size));
            string otherText = context.GetText();
            bool same = text == otherText;
            var missingCarriageReturns = Regex.Matches(text, @"(?<!\r)\n");
            foreach (Match match in missingCarriageReturns)
            {
                _missingCarriageReturnPositions.Add(match.Index);
            }
        }