programs.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright 2001,2009-2014,2018
  2. Free Software Foundation, Inc.
  3. This file is part of Guile.
  4. Guile is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Guile is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with Guile. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _SCM_PROGRAMS_H_
  16. #define _SCM_PROGRAMS_H_
  17. #include <libguile/gc.h>
  18. /*
  19. * Programs
  20. */
  21. #define SCM_PROGRAM_P(x) (SCM_HAS_TYP7 (x, scm_tc7_program))
  22. #define SCM_PROGRAM_CODE(x) ((uint32_t *) SCM_CELL_WORD_1 (x))
  23. #define SCM_PROGRAM_FREE_VARIABLES(x) (SCM_CELL_OBJECT_LOC (x, 2))
  24. #define SCM_PROGRAM_FREE_VARIABLE_REF(x,i) (SCM_PROGRAM_FREE_VARIABLES (x)[i])
  25. #define SCM_PROGRAM_FREE_VARIABLE_SET(x,i,v) (SCM_PROGRAM_FREE_VARIABLES (x)[i]=(v))
  26. #define SCM_PROGRAM_NUM_FREE_VARIABLES(x) (SCM_CELL_WORD_0 (x) >> 16)
  27. #define SCM_VALIDATE_PROGRAM(p,x) SCM_MAKE_VALIDATE (p, x, PROGRAM_P)
  28. #define SCM_F_PROGRAM_IS_BOOT 0x100
  29. #define SCM_F_PROGRAM_IS_PRIMITIVE 0x200
  30. #define SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC 0x400
  31. #define SCM_F_PROGRAM_IS_CONTINUATION 0x800
  32. #define SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION 0x1000
  33. #define SCM_F_PROGRAM_IS_FOREIGN 0x2000
  34. #define SCM_PROGRAM_IS_BOOT(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_BOOT)
  35. #define SCM_PROGRAM_IS_PRIMITIVE(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PRIMITIVE)
  36. #define SCM_PROGRAM_IS_PRIMITIVE_GENERIC(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC)
  37. #define SCM_PROGRAM_IS_CONTINUATION(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_CONTINUATION)
  38. #define SCM_PROGRAM_IS_PARTIAL_CONTINUATION(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION)
  39. #define SCM_PROGRAM_IS_FOREIGN(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_FOREIGN)
  40. #ifdef BUILDING_LIBGUILE
  41. static inline SCM
  42. scm_i_make_program (const uint32_t *code)
  43. {
  44. return scm_cell (scm_tc7_program, (scm_t_bits)code);
  45. }
  46. #endif
  47. SCM_INTERNAL SCM scm_program_p (SCM obj);
  48. SCM_INTERNAL SCM scm_program_code (SCM program);
  49. SCM_INTERNAL SCM scm_primitive_code_p (SCM code);
  50. SCM_INTERNAL SCM scm_primitive_code_name (SCM code);
  51. SCM_INTERNAL SCM scm_primitive_call_ip (SCM prim);
  52. SCM_INTERNAL SCM scm_i_program_name (SCM program);
  53. SCM_INTERNAL SCM scm_i_program_documentation (SCM program);
  54. SCM_INTERNAL SCM scm_i_program_properties (SCM program);
  55. SCM_INTERNAL SCM scm_find_source_for_addr (SCM ip);
  56. SCM_INTERNAL SCM scm_program_address_range (SCM program);
  57. SCM_API SCM scm_program_num_free_variables (SCM program);
  58. SCM_API SCM scm_program_free_variable_ref (SCM program, SCM i);
  59. SCM_API SCM scm_program_free_variable_set_x (SCM program, SCM i, SCM x);
  60. SCM_INTERNAL int scm_i_program_arity (SCM program, int *req, int *opt, int *rest);
  61. SCM_INTERNAL void scm_i_program_print (SCM program, SCM port,
  62. scm_print_state *pstate);
  63. SCM_INTERNAL void scm_bootstrap_programs (void);
  64. SCM_INTERNAL void scm_init_programs (void);
  65. #endif /* _SCM_PROGRAMS_H_ */