src/class-output.lisp: Output effective methods directly from the class.
[sod] / pre-reorg / codegen.lisp
1 ;;; -*-lisp-*-
2 ;;;
3 ;;; Code generator for effective methods
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 ;;; Temporary names.
30
31 ;;;--------------------------------------------------------------------------
32 ;;; Instructions.
33
34 ;;;--------------------------------------------------------------------------
35 ;;; Instruction types.
36 ;; Top level things.
37
38 ;;;--------------------------------------------------------------------------
39 ;;; Code generator objects.
40
41 (defgeneric emit-inst (codegen inst)
42 (:documentation
43 "Add INST to the end of CODEGEN's list of instructions.")
44 (:method ))
45
46 (defgeneric emit-insts (codegen insts)
47 (:documentation
48 "Add a list of INSTS to the end of CODEGEN's list of instructions.")
49 (:method))
50
51 (defgeneric ensure-var (codegen name type &optional init)
52 (:documentation
53 "Add a variable to CODEGEN's list.
54
55 The variable is called NAME (which should be comparable using EQUAL and
56 print to an identifier) and has the given TYPE. If INIT is present and
57 non-nil it is an expression INST used to provide the variable with an
58 initial value.")
59 (:method))
60
61 (defgeneric codegen-push (codegen)
62 (:documentation
63 "Pushes the current code generation state onto a stack.
64
65 The state consists of the accumulated variables and instructions, i.e.,
66 what is representable by a BASIC-CODEGEN.")
67 (:method))
68
69 (defgeneric codegen-pop (codegen)
70 (:documentation
71 "Pops a saved state off of the CODEGEN's stack.
72
73 Returns the newly accumulated variables and instructions as lists, as
74 separate values.")
75 (:method))
76
77 (defgeneric codegen-add-function (codegen function)
78 (:documentation
79 "Adds a function to CODEGEN's list.
80
81 Actually, we're not picky: FUNCTION can be any kind of object that you're
82 willing to find in the list returned by CODEGEN-FUNCTIONS.")
83 (:method ))
84
85
86 ;;;--------------------------------------------------------------------------
87 ;;; Code generation idioms.
88
89 ;;;----- That's all, folks --------------------------------------------------