//--- Class Methods ---
        public static void Generate(DekiScriptGenerator expr, DekiScriptEval callback, DekiScriptExpressionEvaluationState state)
        {
            // set counter variable
            int counter         = 0;
            var previousCounter = state.Env.Vars[DekiScriptRuntime.COUNT_ID];

            try {
                state.Env.Vars.Add(DekiScriptRuntime.COUNT_ID, DekiScriptExpression.Constant(counter));
                expr.VisitWith(Instance, new DekiScriptGeneratorEvaluationState(innerEnv => {
                    callback(innerEnv);
                    state.Env.Vars.Add(DekiScriptRuntime.COUNT_ID, DekiScriptExpression.Constant(++counter));
                }, state));
            } finally {
                state.Env.Vars.Add(DekiScriptRuntime.COUNT_ID, previousCounter);
            }
        }
 public virtual DekiScriptLiteral Evaluate(DekiScriptExpression expr, DekiScriptEvalMode mode, DekiScriptEnv env) {
     DekiScriptExpressionEvaluationState state = new DekiScriptExpressionEvaluationState(mode, env, this);
     try {
         return state.Pop(expr.VisitWith(DekiScriptExpressionEvaluation.Instance, state));
     } catch(DekiScriptReturnException e) {
         state.Push(e.Value);
         return state.PopAll();
     }
 }
 //--- Constructors ---
 public DekiScriptGeneratorEvaluationState(DekiScriptEval callback, DekiScriptExpressionEvaluationState state)
 {
     this.Callback = callback;
     this.State    = state;
 }