p-lambind.sl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. %
  2. % P-LAMBIND.SL - Portable cmacro definitions *LAMBIND, *PROGBIND and *FREERSTR
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 6 August 1982
  9. % Copyright (c) 1982 University of Utah
  10. %
  11. % Modification by MLG to preserve REG 1 across FREERSTR
  12. % 19 March,1983
  13. (compiletime (load useful))
  14. (imports '(syslisp)) % requires SYSLISP for AddrUnitsPerItem
  15. (de *lambind (regs fluids)
  16. (prog (n firstreg)
  17. (setq n 0)
  18. (setq regs (rest regs)) % remove REGISTERS at the front
  19. (setq fluids (rest fluids)) % remove NONLOCALVARS at the front
  20. (setq fluids % convert fluids list into vector
  21. (list2vector (foreach x in fluids collect (second x))))
  22. (setq firstreg (first regs))
  23. (setq regs (rest regs))
  24. (return (if (null regs) % only one to bind
  25. `((*move ,firstreg (reg 2))
  26. (*move `,',(getv fluids 0) (reg 1))
  27. (*call lbind1))
  28. `((*move ,firstreg (memory (fluid LambindArgs*) (wconst 0)))
  29. (*move (fluid LambindArgs*) ,firstreg)
  30. ,@(foreach x in regs collect
  31. (progn (setq n (add1 n))
  32. `(*move ,x
  33. (memory ,firstreg
  34. (wconst (wtimes2 (wconst AddressingUnitsPerItem)
  35. (wconst ,n)))))))
  36. (*move `,',fluids (reg 1))
  37. (*call lambind))))))
  38. (defcmacro *lambind)
  39. (de *progbind (fluids)
  40. (if (null (rest (rest fluids)))
  41. `((*move `,',(second (first (rest fluids))) (reg 1))
  42. (*call pbind1))
  43. `((*move `,',(list2vector (foreach x in (rest fluids) collect
  44. (second x)))
  45. (reg 1))
  46. (*call progbind))))
  47. (defcmacro *progbind)
  48. (de *freerstr (fluids)
  49. `((*move (reg 1) (Fluid FreeRstrSave!*))
  50. (*move `,',(length (rest fluids)) (reg 1))
  51. (*call UnBindN)
  52. (*move (Fluid FreeRstrSave!*) (reg 1))))
  53. (defcmacro *freerstr)
  54. (setq *unsafebinder t) % has to save registers across calls