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

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

Processes function calls and script references. Links to a datum. Opens one or more datums. Pops a value type. Pushes parameter types.
public EnterCall ( HS_Gen1Parser.CallContext context ) : void
context HS_Gen1Parser.CallContext
Результат void
        public override void EnterCall(HS_Gen1Parser.CallContext context)
        {
            if (_debug)
            {
                _logger.Call(context, CompilerContextAction.Enter);
            }

            LinkDatum();

            // Retrieve information from the context.
            string name = context.callID().GetTextSanitized();
            string expectedType = _expectedTypes.PopType();
            int contextParameterCount = context.expression().Length;

            // Handle script references.
            if (IsScriptReference(expectedType, contextParameterCount, context))
            {
                return;
            }

            // Handle functions.
            var functions = _opcodes.GetFunctionInfo(name);
            foreach(var func in functions)
            {
                if(!CheckParameterSanity(context, func))
                {
                    continue;
                }

                string returnType = DetermineReturnType(func, expectedType, context);

                // If a function, which satisfies the requirements, was found, perform the necessary push operations and create expression nodes.
                if (!(returnType is null))
                {
                    EqualityPush(func.ReturnType);
                    PushCallParameters(func, contextParameterCount, expectedType, context);
                    CreateFunctionCall(func, _opcodes.GetTypeInfo(returnType).Opcode, context.GetCorrectTextPosition(_missingCarriageReturnPositions), GetLineNumber(context));
                    return;
                }
            }

            string errorMessage = contextParameterCount == 1 ?
                    $"Failed to process the call {name} with 1 parameter." :
                    $"Failed to process the call {name} with {contextParameterCount} parameters.";
            throw new CompilerException(errorMessage + $" The expected return type was {expectedType}.", context);
        }