programs.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public License
  5. * as published by the Free Software Foundation; either version 3 of
  6. * the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. */
  18. #ifndef _SCM_PROGRAMS_H_
  19. #define _SCM_PROGRAMS_H_
  20. #include <libguile.h>
  21. #include <libguile/objcodes.h>
  22. /*
  23. * Programs
  24. */
  25. #define SCM_F_PROGRAM_IS_BOOT 0x100
  26. #define SCM_F_PROGRAM_IS_PRIMITIVE 0x200
  27. #define SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC 0x400
  28. #define SCM_F_PROGRAM_IS_CONTINUATION 0x800
  29. #define SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION 0x1000
  30. #define SCM_PROGRAM_P(x) (SCM_HAS_TYP7 (x, scm_tc7_program))
  31. #define SCM_PROGRAM_OBJCODE(x) (SCM_CELL_OBJECT_1 (x))
  32. #define SCM_PROGRAM_OBJTABLE(x) (SCM_CELL_OBJECT_2 (x))
  33. #define SCM_PROGRAM_FREE_VARIABLES(x) (SCM_CELL_OBJECT_LOC (x, 3))
  34. #define SCM_PROGRAM_FREE_VARIABLE_REF(x,i) (SCM_PROGRAM_FREE_VARIABLES (x)[i])
  35. #define SCM_PROGRAM_FREE_VARIABLE_SET(x,i,v) (SCM_PROGRAM_FREE_VARIABLES (x)[i]=(v))
  36. #define SCM_PROGRAM_NUM_FREE_VARIABLES(x) (SCM_CELL_WORD_0 (x) >> 16)
  37. #define SCM_PROGRAM_DATA(x) (SCM_OBJCODE_DATA (SCM_PROGRAM_OBJCODE (x)))
  38. #define SCM_VALIDATE_PROGRAM(p,x) SCM_MAKE_VALIDATE (p, x, PROGRAM_P)
  39. #define SCM_PROGRAM_IS_BOOT(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_BOOT)
  40. #define SCM_PROGRAM_IS_PRIMITIVE(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PRIMITIVE)
  41. #define SCM_PROGRAM_IS_PRIMITIVE_GENERIC(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC)
  42. #define SCM_PROGRAM_IS_CONTINUATION(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_CONTINUATION)
  43. #define SCM_PROGRAM_IS_PARTIAL_CONTINUATION(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION)
  44. SCM_API SCM scm_make_program (SCM objcode, SCM objtable, SCM free_variables);
  45. SCM_API SCM scm_program_p (SCM obj);
  46. SCM_API SCM scm_program_base (SCM program);
  47. SCM_API SCM scm_program_meta (SCM program);
  48. SCM_API SCM scm_program_bindings (SCM program);
  49. SCM_API SCM scm_program_sources (SCM program);
  50. SCM_API SCM scm_program_source (SCM program, SCM ip, SCM sources);
  51. SCM_API SCM scm_program_arities (SCM program);
  52. SCM_API SCM scm_program_objects (SCM program);
  53. SCM_API SCM scm_program_module (SCM program);
  54. SCM_API SCM scm_program_num_free_variables (SCM program);
  55. SCM_API SCM scm_program_free_variable_ref (SCM program, SCM i);
  56. SCM_API SCM scm_program_free_variable_set_x (SCM program, SCM i, SCM x);
  57. SCM_API SCM scm_program_objcode (SCM program);
  58. SCM_API SCM scm_c_program_source (SCM program, size_t ip);
  59. SCM_INTERNAL SCM scm_i_program_properties (SCM program);
  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_ */
  66. /*
  67. Local Variables:
  68. c-file-style: "gnu"
  69. End:
  70. */