/// <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; }
/// <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); }
public void Global(HS_Gen1Parser.GlobalDeclarationContext context, CompilerContextAction action) { string name = context.ID().GetTextSanitized(); WriteContextIndent("GLOBAL", context, action, name); }