public void GetLambdaStatement(PortableLambdaType expecting)
        {
            bool found = false;

            _type = expecting;
            foreach (var func in Group.Functions)
            {
                if (func.Parameters.Length == expecting.Parameters.Length)
                {
                    // Make sure the method implements the target lambda.
                    for (int i = 0; i < func.Parameters.Length; i++)
                    {
                        if (func.Parameters[i].Type != null && !func.Parameters[i].Type.Implements(expecting.Parameters[i]))
                        {
                            continue;
                        }
                    }

                    _chosenFunction = func;
                    found           = true;
                    break;
                }
            }

            // If a compatible function was found, get the handler.
            if (found)
            {
                _functionInvoker = GetLambdaHandler(_chosenFunction);
                if (!_type.IsConstant())
                {
                    _identifier = _functionInvoker.GetIdentifier(_parseInfo);
                }

                // Get the variable's invoke info from the parameters.
                InvokedState = new IBridgeInvocable[_functionInvoker.ParameterCount()];
                for (int i = 0; i < _functionInvoker.ParameterCount(); i++)
                {
                    if (_functionInvoker.GetParameterVar(i) is Var var)
                    {
                        InvokedState[i] = var.BridgeInvocable;
                    }
                }
            }
            else
            {
                _parseInfo.Script.Diagnostics.Error("No overload for '" + Group.Name + "' implements " + expecting.GetName(), _range);
            }
        }
Exemple #2
0
        public void Finalize(PortableLambdaType expecting)
        {
            _type = expecting;

            // If a compatible function was found, get the handler.
            if (ChosenFunction != null || SelectFunction(expecting))
            {
                _constFunctionInvoker = GetLambdaHandler(ChosenFunction);

                // Get the variable's invoke info from the parameters.
                InvokedState = new IBridgeInvocable[_constFunctionInvoker.ParameterCount()];
                for (int i = 0; i < _constFunctionInvoker.ParameterCount(); i++)
                {
                    if (_constFunctionInvoker.GetParameterVar(i) is Var var)
                    {
                        InvokedState[i] = var.BridgeInvocable;
                    }
                }
            }
            else
            {
                _parseInfo.Script.Diagnostics.Error("No overload for '" + Group.Name + "' implements " + expecting.GetName(), _range);
            }
        }