示例#1
0
        public void RegisterBuiltIn(string name, ClrFunction clrFunction)
        {
            if (BuiltIns.ContainsKey(name))
            {
                throw new InvalidOperationException($"Built-in function '{name}' has already been registered.");
            }

            BuiltIns.Add(name, clrFunction);
        }
        private DynValue ExecuteClrFunction(ClrFunction clrFunction, string name, ClrFunctionArguments args)
        {
            var csi = new StackFrame($"CLR!{name}");

            Environment.CallStack.Push(csi);

            DynValue retVal;

            try
            {
                retVal = clrFunction.Invokable(this, args);
            }
            finally
            {
                Environment.CallStack.Pop();
            }

            return(retVal);
        }