src/class-output.lisp: Output effective methods directly from the class.
[sod] / pre-reorg / tables.lisp
1 ;;; -*-lisp-*-
2 ;;;
3 ;;; Main tables for the translator
4 ;;;
5 ;;; (c) 2009 Straylight/Edgeware
6 ;;;
7
8 ;;;----- Licensing notice ---------------------------------------------------
9 ;;;
10 ;;; This file is part of the Simple Object Definition system.
11 ;;;
12 ;;; SOD is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
16 ;;;
17 ;;; SOD is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with SOD; if not, write to the Free Software Foundation,
24 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 (cl:in-package #:sod)
27
28 ;;;--------------------------------------------------------------------------
29 ;;; Main tables.
30
31 (defvar *module-map* (make-hash-table :test #'equal)
32 "A hash table mapping file truenames (pathnames) to modules.
33
34 This is used to prevent multiple inclusion of a single module, which would
35 be bad. Usually it maps pathnames to MODULE objects. As a special case,
36 the truename a module which is being parsed maps to :IN-PROGRESS, which
37 can be used to detect dependency cycles.")
38
39 (defvar *type-map* (make-hash-table :test #'equal)
40 "A hash table mapping type names to the C types they describe.
41
42 Since a class is a C type, it gets its own entry in here as a C-CLASS-TYPE
43 object. This is how we find classes by name: the C-CLASS-TYPE object has
44 a reference to the underlying SOD-CLASS instance.")
45
46 (defparameter *builtin-module* nil
47 "Built-in module; populated later.")
48
49 ;;;--------------------------------------------------------------------------
50 ;;; Utilities.
51
52 (defparameter *clear-the-decks-functions*
53 '(reset-type-and-module-map
54 reset-builtin-module))
55
56 (defun reset-type-and-module-map ()
57 "Reset the main hash tables, clearing the translator's state.
58
59 One of the *CLEAR-THE-DECKS-FUNCTIONS*."
60
61 (setf *module-map* (make-hash-table :test #'equal)
62 *type-map* (make-hash-table :test #'equal)))
63
64 (defun populate-type-map ()
65 "Store some important simple types in the type map."
66 (dolist (name '("va_list" "size_t" "ptrdiff_t"))
67 (setf (gethash name *type-map*)
68 (make-simple-type name))))
69
70 (defun clear-the-decks ()
71 "Reinitialize the translator's state.
72
73 This is mainly useful when testing the translator from a Lisp REPL."
74 (dolist (func *clear-the-decks-functions*)
75 (funcall func)))
76
77 #+test
78 (clear-the-decks)
79
80 ;;;----- That's all, folks --------------------------------------------------