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

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

Processes regular expressions, script variables and global references. Links to a datum. Opens a datum.
public EnterLiteral ( HS_Gen1Parser.LiteralContext context ) : void
context HS_Gen1Parser.LiteralContext
Результат void
        public override void EnterLiteral(HS_Gen1Parser.LiteralContext context)
        {
            if (_debug)
            {
                _logger.Literal(context, CompilerContextAction.Enter);
            }

            LinkDatum();

            string text = context.GetTextSanitized();
            string expectedType = _expectedTypes.PopType();

            // Handle "none" expressions. The Value field of ai_line expressions stores their string offset.
            // Therefore the Value is not -1 if the expression is "none".
            if(IsNone(text) && expectedType != "ai_line" && expectedType != "string")
            {                
                ushort opcode = _opcodes.GetTypeInfo(expectedType).Opcode;
                var expression = new ScriptExpression
                {
                    Index = _currentIndex,
                    Opcode = opcode,
                    ReturnType = opcode,
                    Type = ScriptExpressionType.Expression,
                    Next = DatumIndex.Null,
                    StringOffset = _strings.Cache(text),
                    Value = new LongExpressionValue(0xFFFFFFFF),
                    LineNumber = GetLineNumber(context)
                };
                OpenDatumAddExpressionIncrement(expression);
                return;
            }

            // handle script variable references
            if (IsScriptParameter(expectedType, context))
                return;

            // handle global references
            if (IsGlobalsReference(expectedType, context))
                return;
            
            // handle regular expressions
            if (ProcessLiteral(expectedType, context))
                return;

            throw new CompilerException($"Failed to process the expression \"{text.Trim('"')}\". A \"{expectedType}\" expression was expected.", context);
        }