Ejemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="GlobalInfo" /> class. Used for map globals.
 /// </summary>
 /// <param name="context">The parser rule context of the global.</param>
 /// <param name="index">The index of the map global.</param>
 public GlobalInfo(HS_Gen1Parser.GlobalDeclarationContext context, ushort index)
 {
     Name        = context.ID().GetTextSanitized();
     ReturnType  = context.VALUETYPE().GetTextSanitized();
     Opcode      = index;
     Implemented = true;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes global declarations. Opens a datum. Creates the global node. Pushes the value type.
        /// </summary>
        /// <param name="context"></param>
        public override void EnterGlobalDeclaration(HS_Gen1Parser.GlobalDeclarationContext context)
        {
            if (_debug)
            {
                _logger.Global(context, CompilerContextAction.Enter);
            }

            // Create a new Global and add it to the table.
            string valueType = context.VALUETYPE().GetTextSanitized();
            ScriptGlobal glo = new ScriptGlobal()
            {
                Name = context.ID().GetTextSanitized(),
                Type = (short)_opcodes.GetTypeInfo(valueType).Opcode,
                ExpressionIndex = _currentIndex,
            };

            _globals.Add(glo);

            if (_debug)
            {
                _logger.Information($"A global declaration was detected by the parser. The index {_globalPushIndex} will be opened.");
            }
            OpenDatum(_globalPushIndex);
            _expectedTypes.PushType(valueType);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Closes a datum.
        /// </summary>
        /// <param name="context"></param>
        public override void ExitGlobalDeclaration(HS_Gen1Parser.GlobalDeclarationContext context)
        {
            if (_debug)
            {
                _logger.Global(context, CompilerContextAction.Exit);
            }

            CloseDatum();
            ReportProgress();
        }
Ejemplo n.º 4
0
 public void Global(HS_Gen1Parser.GlobalDeclarationContext context, CompilerContextAction action)
 {
     string name = context.ID().GetTextSanitized();
     WriteContextIndent("GLOBAL", context, action, name);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="HS_Gen1Parser.globalDeclaration"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitGlobalDeclaration([NotNull] HS_Gen1Parser.GlobalDeclarationContext context)
 {
 }