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

DetermineReturnType() приватный Метод

private DetermineReturnType ( IScriptingConstantInfo info, string expectedType, ParserRuleContext context ) : string
info IScriptingConstantInfo
expectedType string
context ParserRuleContext
Результат string
        private string DetermineReturnType(IScriptingConstantInfo info, string expectedType, ParserRuleContext context)
        {
            string calculatedType = expectedType switch
            {
                "ANY" when info.ReturnType == "passthrough" => "void",
                "ANY" => info.ReturnType,
                // Cast globals in arithmetic functions to real.
                "NUMBER" when info is GlobalInfo && TypeHelper.IsNumType(info.ReturnType) => "real",
                "NUMBER" when TypeHelper.IsNumType(info.ReturnType) => info.ReturnType,
                "NUMBER" when !TypeHelper.IsNumType(info.ReturnType) => "",
                "void" => "void",
                "GLOBALREFERENCE" when info is GlobalInfo => info.ReturnType,
                "SCRIPTREFERENCE" when info is ScriptInfo => info.ReturnType,
                _ when expectedType == info.ReturnType => expectedType,
                _ when info.ReturnType == "passthrough" => expectedType,
                _ when TypeHelper.CanBeCasted(info.ReturnType, expectedType, _opcodes) => expectedType,
                _ => null
            };

            return calculatedType;
        }