function-primitives.red 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. %
  2. % FUNCTION-PRIMITIVES.RED - primitives used by PUTD/GETD and EVAL/APPLY
  3. % P20: version
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 23 August 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % Every ID has a "function cell". It does not necessarily contain a legal
  12. % Lisp item, and therefore should not be accessed directly by Lisp functions.
  13. % In this implementation the function cell contains an instruction to be
  14. % executed. There are 3 possibilites for this instruction, for which the
  15. % following predicates and updating functions exist:
  16. %
  17. % FUnBoundP(ID) -- the function is not defined
  18. % FLambdaLinkP(ID) -- the function is interpreted
  19. % FCodeP(ID) -- the function is compiled
  20. %
  21. % MakeFUnBound(ID) -- undefine the function
  22. % MakeFLambdaLink(ID) -- specify that the function is interpreted
  23. % MakeFCode(ID, CodePtr) -- specify that the function is compiled,
  24. % and that the code resides at the address
  25. % associated with CodePtr
  26. %
  27. % GetFCodePointer(ID) -- returns the contents of the function cell as a
  28. % code pointer
  29. % These functions currently check that they have proper arguments, but this may
  30. % change since they are only used by functions that have checked them already.
  31. % Note that MakeFCode is necessarily machine-dependent -- this file currently
  32. % contains the PDP-10 version. This function should be moved to a file of
  33. % system-dependent routines. Of course, other things in this file will
  34. % probably have to change for a different machine as well.
  35. on SysLisp;
  36. internal WVar UnDefn = 8#265500000000 + &SymFnc IDLoc UndefinedFunction;
  37. internal WVar LamLnk = 8#265500000000 % JSP T5,xxx
  38. + &SymFnc IDLoc CompiledCallingInterpreted;
  39. % currently the WVars UnDefn and LamLnk contain the instructions which will
  40. % be found in the function cells of undefined and interpreted functions.
  41. syslsp procedure FUnBoundP U; %. does U not have a function defn?
  42. if IDP U then SymFnc U eq UnDefn
  43. else NonIDError(U, 'FUnBoundP);
  44. syslsp procedure FLambdaLinkP U; %. is U an interpreted function?
  45. if IDP U then SymFnc U eq LamLnk
  46. else NonIDError(U, 'FLambdaLinkP);
  47. syslsp procedure FCodeP U; %. is U a compiled function?
  48. if IDP U then SymFnc U neq UnDefn and SymFnc U neq LamLnk
  49. else NonIDError(U, 'FCodeP);
  50. syslsp procedure MakeFUnBound U; %. Make U an undefined function
  51. if IDP U then
  52. << SymFnc U := UnDefn;
  53. NIL >>
  54. else NonIDError(U, 'MakeFUnBound);
  55. syslsp procedure MakeFLambdaLink U; %. Make U an interpreted function
  56. if IDP U then
  57. << SymFnc U := LamLnk;
  58. NIL >>
  59. else NonIDError(U, 'MakeFLambdaLink);
  60. syslsp procedure MakeFCode(U, CodePtr); %. Make U a compiled function
  61. if IDP U then
  62. if CodeP CodePtr then
  63. << SymFnc U := CodePtr;
  64. PutField(SymFnc U, 0, 9, 8#254); % JRST
  65. NIL >>
  66. else NonIDError(U, 'MakeFCode);
  67. syslsp procedure GetFCodePointer U; %. Get code pointer for U
  68. if IDP U then MkCODE SymFnc U
  69. else NonIDError(U, 'GetFCodePointer);
  70. off SysLisp;
  71. END;