예제 #1
0
 private static void fnSwap(IVIMStack stack)
 {
     var expr0 = stack.Pop();
     var expr1 = stack.Pop();
     stack.Push(expr0);
     stack.Push(expr1);
 }
예제 #2
0
 private static void fnEval(IVIMStack stack)
 {
     var sysExpr = (ISystemExpression)stack.Pop();
     var fn = sysExpr.GetDelegate();
     var parameters = Enumerable.Range(0, fn.Method.GetParameters().Count())
         .Select(i => stack.Pop())
         .Select(expression => ((DoubleExpression)expression).dVal)
         .Cast<object>()
         .ToArray();
     stack.Push(new DoubleExpression((double)fn.DynamicInvoke(parameters)));
 }
예제 #3
0
        private static void fnFn(IVIMStack stack)
        {
            var numExpr = (DoubleExpression) stack.Pop();
            var numArgs = (int) numExpr.dVal;

            var exprs = Enumerable.Range(0, numArgs)
                .Select(i => stack.Pop())
                .Cast<StringExpression>()
                .Reverse()
                .ToList();

            stack.Push(new FunctionExpression(exprs, (ISystemExpression)stack.Pop()));
        }
예제 #4
0
 private static void fnArray(IVIMStack stack)
 {
     var numExpr = (DoubleExpression)stack.Pop();
     var arrayVals = Enumerable.Range(0, (int) numExpr.dVal)
         .Select(i => stack.Pop());
     stack.Push(new ArrayExpression(arrayVals));
 }