public override void EnterScriptDeclaration(HS_Gen1Parser.ScriptDeclarationContext context)
{
if(_debug)
{
_logger.Script(context, CompilerContextAction.Enter);
}
// Create new script object and add it to the table.
Script script = ScriptObjectCreation.GetScriptFromContext(context, _currentIndex, _opcodes);
_scripts.Add(script);
// Generate the parameter lookup.
for(ushort i = 0; i < script.Parameters.Count; i++)
{
ScriptParameter parameter = script.Parameters[i];
var info = new ParameterInfo(parameter.Name, _opcodes.GetTypeInfo(parameter.Type).Name, i);
_parameterLookup.Add(info.Name, info);
}
string returnType = context.VALUETYPE().GetTextSanitized();
int expressionCount = context.expression().Count();
// The final expression must match the return type of this script.
_expectedTypes.PushType(returnType);
// The other expressions can be of any type.
if (expressionCount > 1)
{
_expectedTypes.PushTypes("void", expressionCount - 1);
}
CreateInitialBegin(returnType, context.GetCorrectTextPosition(_missingCarriageReturnPositions));
}