Beispiel #1
0
        internal static object?CallMethod <TScope, TRootScope>(ILanguageDefinition languageDefinition, ScopeStack <TScope, TRootScope> scopeStack, object?left, object?[] args)
            where TScope : class, IScope
            where TRootScope : class, TScope
        {
            switch (left)
            {
            case FunctionMethodGroup methodGroup:
                return(methodGroup.FunctionDefinition.Invoke(languageDefinition, args));

            case UserDefinedFunction userDefinedFunction:
                return(userDefinedFunction.Invoke(languageDefinition, args));

            case PipelineMethodGroup pipelineGroup:
                return(pipelineGroup.FunctionDefinition.Invoke(languageDefinition, pipelineGroup.ReferredObject, args));

            case ScopedFunctionMethodGroup scopedMethodGroup:
                return(scopedMethodGroup.FunctionDefinition.Invoke(languageDefinition, scopeStack.Current, args));

            default:
                var callable = ReflectionHelpers.GetCallable(left);
                if (callable != null)
                {
                    return(callable.Invoke(left, new object[] { args }));
                }
                throw new NotImplementedException();
            }
Beispiel #2
0
 internal DynamicTransformer <TScope, TRootScope> CreateDynamicTransformer <TScope, TRootScope>(ScopeStack <TScope, TRootScope> scopeStack)
     where TScope : DynamicScope
     where TRootScope : TScope
 {
     return(new DynamicTransformer <TScope, TRootScope>(scopeStack, LanguageDefinition));
 }