Posted to c by dbohdan at Fri May 12 19:52:05 GMT 2017view raw

  1. static LILCALLBACK lil_value_t fnc_upeval(lil_t lil, size_t argc, lil_value_t* argv)
  2. {
  3. lil_env_t thisenv = lil->env;
  4. lil_env_t thisdownenv = lil->downenv;
  5. lil_value_t r;
  6. if (lil->rootenv == thisenv) return fnc_eval(lil, argc, argv);
  7. lil->env = thisenv->parent;
  8. lil->downenv = thisenv;
  9. r = fnc_eval(lil, argc, argv);
  10. lil->env = thisenv;
  11. lil->downenv = thisdownenv;
  12. return r;
  13. }
  14.  
  15. static LILCALLBACK lil_value_t fnc_downeval(lil_t lil, size_t argc, lil_value_t* argv)
  16. {
  17. lil_value_t r;
  18. lil_env_t upenv = lil->env;
  19. lil_env_t downenv = lil->downenv;
  20. if (!downenv) return fnc_eval(lil, argc, argv);
  21. lil->downenv = NULL;
  22. lil->env = downenv;
  23. r = fnc_eval(lil, argc, argv);
  24. lil->downenv = downenv;
  25. lil->env = upenv;
  26. return r;
  27. }