コード例 #1
0
        public AphidObject CallFunctionWithScope(
            [PexAssumeUnderTest] AphidInterpreter target,
            AphidFunction function,
            AphidObject scope,
            object[] parms
            )
        {
            AphidObject result = target.CallFunctionWithScope(function, scope, parms);

            return(result);
            // TODO: add assertions to method AphidInterpreterTest.CallFunctionWithScope(AphidInterpreter, AphidFunction, AphidObject, Object[])
        }
コード例 #2
0
        private byte[] TryInterpretHandlerUnsafe(
            AphidInterpreter handlerInterpreter,
            HttpListenerContext context,
            AphidObject session)
        {
            var scope = AphidObject.Scope();

            SetupInterpreterScope(handlerInterpreter, scope, null, context, session);

            var handler = handlerInterpreter
                          .CurrentScope["http"]["handlers"]
                          .GetList()
                          .Select(x => x.Value)
                          .Cast <dynamic>()
                          .Select(x => new
            {
                x.Callback,
                Result = ValueHelper.Unwrap(handlerInterpreter.CallFunction(x.Predicate, scope))
            })
                          .FirstOrDefault(x => x.Result is bool && (bool)x.Result);

            if (handler != null)
            {
                var callback = handler.Callback;
                //AphidFunction callback = handler.Callback.Clone();
                //callback.Body = callback.Body.ToList();

                //var include = string.Format(
                //    "#'{0}'",
                //    GetHeaderFile().FullName.Replace("\\", "\\\\"));

                //callback.Body.Insert(0, AphidParser.ParseExpression(include));

                return(RenderResponse(
                           handlerInterpreter,
                           () => handlerInterpreter.CallFunctionWithScope(
                               callback,
                               scope,
                               scope),
                           scope,
                           context));
            }

            return(null);
        }