Esempio n. 1
0
        /// <summary>
        /// Calls the custom function.
        /// </summary>
        /// <param name="name">Name of the function</param>
        /// <param name="exp"></param>
        /// <returns></returns>
        public object Call(string name, FunctionCallExpr exp)
        {
            var callback = GetByName(name);

            // 1. Resolve parameter froms expressions into Lang values.
            ParamHelper.ResolveParametersToHostLangValues(exp.ParamListExpressions, exp.ParamList);
            object result = callback(exp);

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Executes a call to a language binding class.
        /// </summary>
        /// <param name="expr"></param>
        /// <returns></returns>
        public object VisitBindingCall(BindingCallExpr expr)
        {
            var method = expr.Name;

            // 1. Resolve the parameters.
            ParamHelper.ResolveParametersToHostLangValues(expr.ParamListExpressions, expr.ParamList, this);

            // 2. Push call into stack
            expr.Ctx.State.Stack.Push(expr.FullName, null);

            // 3. Call language binding method/function.
            var binding = new MetaCompiler();

            binding.Ctx = expr.Ctx;
            var result = binding.ExecuteFunction(method, new object[] { expr });

            result = FunctionHelper.CheckConvert(result);
            // 4. Pop the call stack
            expr.Ctx.State.Stack.Pop();
            return(result);
        }