public static void Lock(AphidInterpreter interpreter, AphidObject obj, AphidFunction body)
 {
     lock (obj)
     {
         interpreter.CallFunction(body);
     }
 }
Example #2
0
 static void Main(string[] args)
 {
     var interpreter = new AphidInterpreter();
     interpreter.Interpret("add = @(x, y) x + y;");
     var x = interpreter.CallFunction("add", 3, 7).Value;
     Console.WriteLine(x);
 }
        private static ManualResetEvent ThreadCore(AphidInterpreter interpreter, Action<Action> start, AphidFunction function, params object[] parms)
        {
            var reset = new ManualResetEvent(false);
            var interpreter2 = new AphidInterpreter(interpreter.CurrentScope);

            Action call = () =>
            {
                interpreter2.CallFunction(function, parms);
                reset.Set();
            };

            start(call);

            return reset;
        }
Example #4
0
        private static List<AphidObject> ListOrder(
            AphidInterpreter interpreter,
            AphidObject items,
            AphidObject keySelector,
            Func<IEnumerable<AphidObject>, Func<AphidObject, object>, IOrderedEnumerable<AphidObject>> action)
        {
            var list = (List<AphidObject>)items.Value;
            var func = (AphidFunction)keySelector.Value;

            return action(list, x => interpreter.CallFunction(func, x).Value).ToList();
        }