srcprop.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* classes: h_files */
  2. #ifndef SRCPROPH
  3. #define SRCPROPH
  4. /* Copyright (C) 1995,1996, 2000, 2002 Free Software Foundation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this software; see the file COPYING. If not, write to
  18. * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  19. * Boston, MA 02111-1307 USA
  20. *
  21. * As a special exception, the Free Software Foundation gives permission
  22. * for additional uses of the text contained in its release of GUILE.
  23. *
  24. * The exception is that, if you link the GUILE library with other files
  25. * to produce an executable, this does not by itself cause the
  26. * resulting executable to be covered by the GNU General Public License.
  27. * Your use of that executable is in no way restricted on account of
  28. * linking the GUILE library code into it.
  29. *
  30. * This exception does not however invalidate any other reasons why
  31. * the executable file might be covered by the GNU General Public License.
  32. *
  33. * This exception applies only to the code released by the
  34. * Free Software Foundation under the name GUILE. If you copy
  35. * code from other Free Software Foundation releases into a copy of
  36. * GUILE, as the General Public License permits, the exception does
  37. * not apply to the code that you add in this way. To avoid misleading
  38. * anyone as to the status of such modified files, you must delete
  39. * this exception notice from them.
  40. *
  41. * If you write modifications of your own for GUILE, it is your choice
  42. * whether to permit this exception to apply to your modifications.
  43. * If you do not wish that, delete this exception notice.
  44. *
  45. * The author can be reached at djurfeldt@nada.kth.se
  46. * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
  47. #include "libguile/__scm.h"
  48. /* {The old whash table interface}
  49. * *fixme* This is a temporary solution until weak hash table access
  50. * has been optimized for speed (which is quite necessary, if they are
  51. * used for recording of source code positions...)
  52. */
  53. #define scm_whash_handle SCM
  54. #define scm_whash_get_handle(whash, key) scm_hash_fn_get_handle (whash, key, scm_ihashq, scm_sloppy_assq, 0)
  55. #define SCM_WHASHFOUNDP(h) (!SCM_FALSEP (h))
  56. #define SCM_WHASHREF(whash, handle) SCM_CDR (handle)
  57. #define SCM_WHASHSET(whash, handle, obj) SCM_SETCDR (handle, obj)
  58. #define scm_whash_create_handle(whash, key) scm_hash_fn_create_handle_x (whash, key, SCM_UNSPECIFIED, scm_ihashq, scm_sloppy_assq, 0)
  59. #define scm_whash_lookup(whash, obj) scm_hash_fn_ref (whash, obj, SCM_BOOL_F, scm_ihashq, scm_sloppy_assq, 0)
  60. #define scm_whash_insert(whash, key, obj) \
  61. do { \
  62. register SCM w = (whash); \
  63. SCM_WHASHSET (w, scm_whash_create_handle (w, key), obj); \
  64. } while (0)
  65. /* {Source properties}
  66. */
  67. extern long scm_tc16_srcprops;
  68. typedef struct scm_srcprops
  69. {
  70. unsigned long pos;
  71. SCM fname;
  72. SCM copy;
  73. SCM plist;
  74. } scm_srcprops;
  75. #define SRCPROPS_CHUNKSIZE 2047 /* Number of srcprops per chunk */
  76. typedef struct scm_srcprops_chunk
  77. {
  78. struct scm_srcprops_chunk *next;
  79. scm_srcprops srcprops[1];
  80. } scm_srcprops_chunk;
  81. #define SRCPROPSP(p) (SCM_NIMP(p) && (SCM_TYP16 (p) == scm_tc16_srcprops))
  82. #define SRCPROPBRK(p) (SCM_BOOL (SCM_CELL_WORD_0 (p) & (1L << 16)))
  83. #define SRCPROPPOS(p) ((scm_srcprops *) SCM_CELL_WORD_1 (p))->pos
  84. #define SRCPROPLINE(p) (SRCPROPPOS(p) >> 12)
  85. #define SRCPROPCOL(p) (SRCPROPPOS(p) & 0x0fffL)
  86. #define SRCPROPFNAME(p) ((scm_srcprops *) SCM_CELL_WORD_1 (p))->fname
  87. #define SRCPROPCOPY(p) ((scm_srcprops *) SCM_CELL_WORD_1 (p))->copy
  88. #define SRCPROPPLIST(p) ((scm_srcprops *) SCM_CELL_WORD_1 (p))->plist
  89. #define SETSRCPROPBRK(p) (SCM_SETOR_CAR (p, (1L << 16)))
  90. #define CLEARSRCPROPBRK(p) SCM_SETAND_CAR (p, ~(1L << 16))
  91. #define SRCPROPMAKPOS(l,c) (((l) << 12) + (c))
  92. #define SETSRCPROPPOS(p,l,c) (SRCPROPPOS (p) = SRCPROPMAKPOS (l, c))
  93. #define SETSRCPROPLINE(p,l) SETSRCPROPPOS (p, l, SRCPROPCOL (p))
  94. #define SETSRCPROPCOL(p,c) SETSRCPROPPOS (p, SRCPROPLINE (p), c)
  95. #define SRCBRKP(x) (SCM_NIMP (t.arg1 = scm_whash_lookup (scm_source_whash, (x)))\
  96. && SRCPROPSP (t.arg1)\
  97. && (SCM_CELL_WORD_0 (t.arg1) & (1L << 16)))
  98. #define PROCTRACEP(x) SCM_NFALSEP (scm_procedure_property (x, scm_sym_trace))
  99. extern SCM scm_sym_filename;
  100. extern SCM scm_sym_copy;
  101. extern SCM scm_sym_line;
  102. extern SCM scm_sym_column;
  103. extern SCM scm_sym_breakpoint;
  104. extern SCM scm_srcprops_to_plist (SCM obj);
  105. extern SCM scm_make_srcprops (int line, int col, SCM fname, SCM copy, SCM plist);
  106. extern SCM scm_source_property (SCM obj, SCM key);
  107. extern SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum);
  108. extern SCM scm_source_properties (SCM obj);
  109. extern SCM scm_set_source_properties_x (SCM obj, SCM props);
  110. extern void scm_finish_srcprop (void);
  111. extern void scm_init_srcprop (void);
  112. #endif /* SRCPROPH */
  113. /*
  114. Local Variables:
  115. c-file-style: "gnu"
  116. End:
  117. */