private ushort GetGlobalOpCode(ushort globalOpcode, RuleContext context)
{
RuleContext grandparent = GetParentContext(context, HS_Gen1Parser.RULE_call);
ushort opcode = globalOpcode;
// "set" and (in)equality functions are special.
if (grandparent is HS_Gen1Parser.CallContext call)
{
string funcName = call.callID().GetTextSanitized();
List<FunctionInfo> funcInfo = _opcodes.GetFunctionInfo(funcName);
if (funcInfo != null)
{
if (funcInfo[0].Group == "Equality" || funcInfo[0].Group == "Inequality")
{
opcode = GetEqualityArgumentOP(globalOpcode);
}
else if (_set && funcInfo[0].Group == "Set")
{
opcode = 0xFFFF;
if (_debug)
{
_logger.Information("The Global belongs to a set call. It's value type will be pushed to the stack.");
}
// The next parameter must have the same return type as this global
_expectedTypes.PushType(_opcodes.GetTypeInfo(globalOpcode).Name);
_set = false;
}
}
}
EqualityPush(_opcodes.GetTypeInfo(globalOpcode).Name);
return opcode;
}