-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclast-elements.lisp
1392 lines (942 loc) · 34 KB
/
clast-elements.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;; -*- Mode: Lisp -*-
;;;; clast-elements.lisp --
;;;; Some code lifted from IT.BESE.ARNESI and CL-WALKER.
;;;; See file COPYING in main folder for licensing and copyright information.
(in-package "CLAST")
;;;---------------------------------------------------------------------------
;;; CLAST-ELEMENT
;;;
;;; Top class just for convenience.
(defclass clast-element () ()
(:documentation "The CLast Element Class.
The top element class."))
(defun is-clast-element (x)
(typep x 'clast-element))
;;;---------------------------------------------------------------------------
;;; FORM
;;;
;;; Main class, other "top" classes are "mixins" (or "traits").
;;; The main "protocol" is also named after FORM.
(defclass form (clast-element)
((type :accessor form-type
:initarg :type
:initform t ; The declared or (possibly) inferred type of the form.
)
(top :accessor form-top
:initarg :top
:initform nil ; The 'enclosing form'; NIL for top-level forms.
)
(source :accessor form-source
:initarg :source
:documentation
"The source form of the ... form."
)
#| This is probably just useful here.
(env :accessor form-environment
:initarg :environment
:initform nil ; Valid null lexical environment.
:documentation
"The environment the form is parsed in."
)
|#
)
(:documentation "The FORM Class.
The top of the FORMs hierarchy."))
(defun is-form (x)
(typep x 'form))
(defun form-p (x)
(typep x 'form))
;;;---------------------------------------------------------------------------
;;; EXPANSION-COMPONENT
(defclass expansion-component (clast-element)
((expansion :accessor form-expansion
:initarg :expansion))
(:documentation "The EXPANSION-COMPONENT Class.
A mixin class used for all forms which may result in a macro
expansion; i.e., macro applications and symbol macros.")
)
(defun expansion-component-p (x) (typep x 'expansion-component))
;;;---------------------------------------------------------------------------
;;; CONSTANT-FORM
(defclass constant-form (form)
((value :accessor form-value
:initarg :value
)
)
(:documentation "The CONSTANT-FORM Class.
The class of forms representing 'constants', e.g., literal numbers.
"))
(defun constant-form-p (x)
(typep x 'constant-form))
;;;---------------------------------------------------------------------------
;;; BINDING-FORMs
(defclass binding-form (form)
((binds :accessor form-binds
:initarg :binds
:initform ()
)
)
(:documentation "The BINDING-FORM Class.
The class representing all 'forms' that bind 'names'."
))
(defun binding-form-p (x)
(typep x 'binding-form))
(defclass vbinding-form (binding-form) ()
(:documentation "The VBINDING-FORM Class.
The class representing all 'forms' that bind 'variables'."
))
(defun vbinding-form-p (x)
(typep x 'vbinding-form))
(defclass fbinding-form (binding-form) ()
(:documentation "The FBINDING-FORM Class.
The class representing all 'forms' that bind 'functions'."
))
(defun fbinding-form-p (x)
(typep x 'fbinding-form))
;;;---------------------------------------------------------------------------
;;; IMPLICIT-PROGN
;;;
;;; A "mixin" class.
(defclass implicit-progn (clast-element)
((iprogn-forms :accessor form-progn
:accessor form-body
:initarg :progn
:initarg :body
:initform ())
(body-env :accessor form-body-env
:initarg :body-env
:initform () #| (make-env) |#
)
)
(:documentation "The IMPLICIT-PROGN CLass.
A mixin class that is used whenever a form contains an 'implicit progn'.")
)
(defun implicit-progn-p (x)
(typep x 'implicit-progn))
;;;---------------------------------------------------------------------------
;;; SYMBOL-REFs
(defclass symbol-ref (form)
((symbol :accessor form-symbol :initarg :symbol)
(local :accessor form-local
:initarg :local
:initform nil
)
)
(:documentation "The SYMBOL-REF Class.
The class of references to 'names' (be they variables, functions etc)."
))
(defun symbol-ref-p (x) (typep x 'symbol-ref))
(defclass variable-ref (symbol-ref) ()
(:documentation "The VARIABLE-REF Class.
The class of references to 'variables'."
))
(defun variable-ref-p (x) (typep x 'variable-ref))
(defclass constant-ref (variable-ref constant-form) ()
(:documentation "The CONSTANT-REF Class.
The class of references to 'constants'."
))
(defun constant-ref-p (x) (typep x 'constant-ref))
(defclass free-variable-ref (variable-ref) ()
(:documentation "The FREE-VARIABLE-REF Class.
The class of references to 'variables' that are 'free' in a form."
))
(defun free-variable-ref-p (x) (typep x 'free-variable-ref))
(defclass special-variable-ref (variable-ref) ()
(:documentation "The SPECIAL-VARIABLE-REF Class.
The class of references to 'special variables'."
))
(defun special-variable-ref-p (x) (typep x 'special-variable-ref))
(defclass symbol-macro-ref (symbol-ref expansion-component) ()
(:documentation "The SYMBOL-MACRO-REF Class.
The class of references to 'symbol macros'."
))
(defun symbol-macro-ref-p (x) (typep x 'symbol-macro-ref))
(defclass function-name-ref (symbol-ref) ()
(:documentation "The FUNCTION-NAME-REF Class.
The class of references to 'function' names."
))
(defun function-name-ref-p (x) (typep x 'function-name-ref))
(defclass macro-name-ref (symbol-ref) ()
(:documentation "The MACRO-NAME-REF Class.
The class of references to 'macro' names."
))
(defun macro-name-ref-p (x) (typep x 'macro-name-ref))
(defclass block-name-ref (symbol-ref)
((symbol :accessor form-name
:initarg :name))
(:documentation "The BLOCK-NAME-REF Class.
The class of references to 'block' names.")
)
(defun block-name-ref-p (x) (typep x 'block-name-ref))
(defclass go-tag (symbol-ref)
((symbol :accessor tag-name
:initarg :tag)
)
(:documentation "The GO-TAG Class.
The instances of this represents references to GO tags. I.e., they
are essetially SYMBOL-REFs that are found in TAGBODYs and in GO
expressions.")
)
(defun go-tag-p (x) (typep x 'go-tag))
;;;---------------------------------------------------------------------------
;;; Applications
(defclass application (form)
((operator :accessor form-operator :initarg :operator)
(args :accessor form-args :initarg :arguments))
(:documentation "The APPLICATION Class.
The class representing all 'applications' in Common Lisp forms.")
)
(defun application-p (x) (typep x 'application))
(defclass function-application (application) ()
(:documentation "The FUNCTION-APPLICATION Class.
The class representing all 'regular' function applications in Common
Lisp forms."))
(defun function-application-p (x) (typep x 'function-application))
(defclass lambda-application (function-application) ()
(:documentation "The LAMBDA-APPLICATION Class.
The class representing all anonymous LAMBDA function applications in
Common Lisp forms."))
(defun lambda-application-p (x) (typep x 'lambda-application))
(defclass functional-operator-application (function-application)
()
(:documentation "The Functional Operator Application CLass.
This class represents functional applications where the operator is
non-standard with respect to the Common Lisp Standard; i.e.,
applications where the operator is not a symbol or a lambda expression."))
(defun functional-operator-application-p (x)
(typep x 'functional-operator-application))
(defclass local-function-application (function-application) ())
(defun local-function-application-p (x) (typep x 'local-function-application))
(defclass macro-application (application expansion-component) ()
(:documentation "The MACRO-APPLICATION Class.
The class representing all MACRO applications in Common Lisp forms.
The class also inherits the 'expansion' mixin."))
(defun macro-application-p (x) (typep x 'macro-application))
(defclass local-macro-application (macro-application) ())
(defun local-macro-application-p (x) (typep x 'local-macro-application))
;;;---------------------------------------------------------------------------
;;; Type specifiers
(defclass type-specifier-form (form)
((spec :accessor type-specifier-form-spec
:initarg :spec
)
)
(:documentation "The Type Specifier Form Class.
The class representing 'type'specifiers. Note that the content of the
SPEC slot is always 'as is', i.e., not parsed.")
)
(defun is-type-specifier-form (form)
(typep form 'type-specifier-form))
(defun type-specifier-form-p (form)
(is-type-specifier-form form))
;;;---------------------------------------------------------------------------
;;; Declarations
;;; declaration-form
(defclass declaration-form (form)
((decls :accessor declaration-form-declarations
:initarg :declarations
)
(new-env :accessor declaration-form-resulting-environment
:accessor form-resulting-environment
:initarg :resulting-environment)
)
(:documentation "The Declaration Form Class.
The class of all 'declarations' in Common Lisp.")
)
(defun declaration-form-p (x) (typep x 'declaration-form))
;;; declaration-specifier-form
;;; tf-declaration-specifier-form
;;; type-declaration-specifier-form
;;; ftype-declaration-specifier-form
;;; id-declaration-specifier-form
(defclass declaration-specifier-form (form)
((identifier :accessor declaration-specifier-form-identifier
:accessor declaration-specifier-identifier
)
)
(:documentation "The DECLARATION-SPECIFIER-FORM Class.
The class of all 'declaration specifiers' in Common Lisp.")
)
(defun declaration-specifier-form-p (x)
(typep x 'declaration-specifier-form))
(defclass tf-declaration-specifier-form (declaration-specifier-form)
((type-spec :accessor declaration-type-spec
:initarg :spec)
(symbol-refs :accessor declaration-type-spec-symbols
:initarg :symbols)
)
)
(defun tf-declaration-specifier-form-p (x)
(typep x 'tf-declaration-specifier-form))
(defclass type-declaration-specifier-form (tf-declaration-specifier-form)
((identifier :initform 'type))
(:documentation "The TYPE-DECLARATION-SPECIFIER-FORM Class.
The class of all 'type declaration specifiers' in Common Lisp.")
)
(defun type-declaration-specifier-form-p (x)
(typep x 'type-declaration-specifier-form))
(defclass ftype-declaration-specifier-form (tf-declaration-specifier-form)
((identifier :initform 'ftype))
(:documentation "The FTYPE-DECLARATION-SPECIFIER-FORM Class.
The class of all 'ftype declaration specifiers' in Common Lisp.")
)
(defun ftype-declaration-specifier-form-p (x)
(typep x 'ftype-declaration-specifier-form))
(defclass id-declaration-specifier-form (declaration-specifier-form)
((identifier :initarg :id)
)
(:documentation "The ID-DECLARATION-SPECIFIER-FORM Class.
The class of all 'id declaration specifiers' in Common Lisp. E.g.,
OPTIMIZE declarations.")
)
(defun id-declaration-specifier-form-p (x)
(typep x 'id-declaration-specifier-form))
(defmethod declaration-type-spec-symbols ((idd id-declaration-specifier-form))
(case (declaration-specifier-identifier idd)
(special (rest (form-source idd)))
((noinline inline) (rest (form-source idd)))
(t ())
))
;;;---------------------------------------------------------------------------
;;; Declamations
(defclass declaim-form (declaration-form)
())
;;;;---------------------------------------------------------------------------
;;;; "Composite" forms.
(defclass block-form (form implicit-progn)
((name :accessor form-name
:accessor block-name
:initarg :name)
)
(:documentation "The BLOCK-FORM Class.
The class of forms that are Common Lisp BLOCKs.")
)
(defun block-form-p (x) (typep x 'block-form))
(defclass catch-form (form implicit-progn)
((tag :accessor form-catch-tag
:initarg :tag)
)
(:documentation "The CATCH-FORM Class.
The class of forms that are Common Lisp CATCHes. The slot TAG
contains the catch TAG.")
)
(defun catch-form-p (x) (typep x 'block-form))
(defclass throw-form (form)
((tag :accessor form-throw-tag
:initarg :tag)
(result :accessor form-result
:initarg :result)
)
(:documentation "The THROW-FORM Class.")
)
(defun throw-form-p (x) (typep x 'block-form))
(defclass eval-when-form (form implicit-progn)
((situations :accessor form-situations
:initarg :situations)
)
(:documentation "The EVAL-WHEN-FORM CLass.")
)
(defun eval-when-form-p (x) (typep x 'block-form))
;;;;---------------------------------------------------------------------------
;;;; Binding forms.
(defclass flet-form (fbinding-form implicit-progn)
()
(:documentation "The FLET-FORM Class.")
)
(defun flet-form-p (x) (typep x 'flet-form))
(defclass labels-form (fbinding-form implicit-progn)
()
(:documentation "The LABELS-FORM Class.")
)
(defun labels-form-p (x) (typep x 'labels-form))
(defclass macrolet-form (fbinding-form implicit-progn)
()
(:documentation "The MACROLET-FORM Class.")
)
(defun macrolet-form-p (x) (typep x 'macrolet-form))
(defclass symbol-macrolet-form (vbinding-form implicit-progn)
()
(:documentation "The SYMBOL-MACROLET-FORM Class.")
)
(defun symbol-macrolet-form-p (x) (typep x 'symbol-macrolet-form))
(defclass let-form (vbinding-form implicit-progn)
()
(:documentation "The LET-FORM Class.")
)
(defun let-form-p (x) (typep x 'let-form))
(defclass let*-form (vbinding-form implicit-progn)
()
(:documentation "The LET*-FORM Class.")
)
(defun let*-form-p (x) (typep x 'let*-form))
;;;---------------------------------------------------------------------------
;;; Function forms.
(defclass function-form (form)
((funct :accessor form-function
:initarg :function
:initarg :name)
(type :initform 'function)
)
(:documentation "The FUNCTION-FORM Class.
The instances of this class represent the (FUNCTION <function-name>) forms.")
)
(defun function-form-p (x) (typep x 'function-form))
(defclass lambda-form (function-form implicit-progn)
((lambda-list :accessor form-args
:accessor form-lambda-list
:initarg :args
:initarg :lambda-list)
(funct :initform 'lambda)
)
(:documentation "The LAMBDA-FORM Class.
The instances of this class represent LAMBDA espressions.")
)
(defun lambda-form-p (x) (typep x 'lambda-form))
;;;---------------------------------------------------------------------------
;;; Flow control.
(defclass go-form (form)
((name :accessor form-name
:accessor form-tag
:initarg :name
:initarg :tag)
(enclosing-tagbody :accessor form-tagbody
:initarg :enclosing-tagbody)
)
(:documentation "The GO-FORM Class.
The instances of ths class are the forms (GO <tag>).")
)
(defun go-form-p (x) (typep x 'go-form))
(defclass if-form (form)
((condition :accessor form-condition
:initarg :condition)
(then :accessor form-then
:initarg :then)
(else :accessor form-else
:initarg :else)
)
(:documentation "The IF-FORM Class.
Basic conditional IF forms.")
)
(defun if-form-p (x) (typep x 'if-form))
(defclass selection-form (form)
((clauses :accessor form-clauses
:initarg :clauses
)
)
(:documentation "The SELECTION-FORM Class.
Subclasses of SELECTION-FORM contain a list of 'clauses' (subclasses
of CLAUSE-FORM) representing the code associated to the form specific
syntax.")
)
(defun selection-form-p (x) (typep x 'selection-form))
(defclass clause-form (form implicit-progn)
((selector-form :accessor form-selector
:initarg :selector
)
)
)
(defclass selector-form (selection-form)
((selector :initarg :selector
:accessor selector-form-selection)
)
(:documentation "The SELECTOR-FORM CLass.
The superclass of classes representing 'forms with a selector', e.g.,
TYPECASE.")
)
(defclass cond-form (selection-form)
()
(:documentation "The COND-FORM Class.
A SELECTION-FORM where each 'clause' is interpreted in the 'cond' sense.")
)
(defun cond-form-p (x) (typep x 'cond-form))
(defclass case-form (selector-form) ())
(defun case-form-p (x) (typep x 'case-form))
(defclass ccase-form (selector-form) ())
(defun ccase-form-p (x) (typep x 'ccase-form))
(defclass ecase-form (selector-form) ())
(defun ecase-form-p (x) (typep x 'ecase-form))
(defclass typecase-form (selector-form) ())
(defun typecase-form-p (x) (typep x 'typecase-form))
(defclass etypecase-form (selector-form) ())
(defun etypecase-form-p (x) (typep x 'etypecase-form))
;;;---------------------------------------------------------------------------
;;; Multiple values.
(defclass mvb-form (vbinding-form implicit-progn)
((values-form :accessor form-values-form
:initarg :values-form)
)
(:documentation "The MVB-FORM CLass.
Representation for MULTIPLE-VALUE-BINDs forms.")
)
(defun mvb-form-p (x) (typep x 'mvb-form))
(defun multiple-value-bind-form-p (x) (typep x 'mvb-form))
(defclass multiple-value-call-form (form implicit-progn)
;; Misnomer. 'implicit-progn' should be 'forms-sequence'.
((funct :accessor form-function
:initarg :function)
)
(:documentation "The MULTIPLE-VALUE-CALL-FORM CLass.
Representation for MULTIPLE-VALUE-CALL forms.")
)
(defun multiple-value-call-form-p (x) (typep x 'multiple-value-call-form))
(defclass multiple-value-prog1-form (form implicit-progn)
()
(:documentation "The MULTIPLE-VALUE-PROG1-FORM CLass.
Representation for MULTIPLE-VALUE-PROG1 forms.")
)
(defun multiple-value-prog1-form-p (x) (typep x 'multiple-value-prog1-form))
;;;---------------------------------------------------------------------------
;;; Other special operators.
(defclass load-time-value-form (form)
((ltv-form :accessor form-load-time-form
:initarg :load-time-form)
(read-only :accessor is-read-only
:accessor read-only-p
:initarg :read-only-p
:initarg :is-read-only)
)
(:documentation "The LOAD-TIME-VALUE-FORM CLass.
Representation for LOAD-TIME-VALUE forms.")
)
(defun load-time-value-form-p (x) (typep x 'load-time-value-form))
(defclass locally-form (form implicit-progn)
((decls :accessor form-declarations
:initarg :declarations)
)
(:documentation "The LOCALLY-FORM Class.
Representation for LOCALLY forms. Instances of this class contain a
list of declarations, accessible via FORMS-DECLARATIONS.")
)
(defun locally-form-p (x) (typep x 'locally-form))
(defclass quote-form (constant-form)
()
(:documentation "The QUOTE-FORM Class.
The class representing quoted expressions.")
)
(defun quote-form-p (x) (typep x 'quote-form))
(defclass return-from-form (form)
((name :accessor form-name
:initarg :name)
(result :accessor form-result
:initarg :result)
(enclosing-block :accessor form-enclosing-block
:accessor form-block
:initarg :block)
)
(:documentation "The RETURN-FROM-FORM CLass.
Instances representing RETURN-FROM expressions. THe slots NAME and
RESULT represent the syntactic elements of th form, while the
ENCLOSING-BLOCK is a link to the actual form where NAME is named.
Notes:
The ENCLOSING-BLOCK slot is currently initialized in a possibly
improper way. Do not use.")
)
(defun return-from-form-p (x) (typep x 'return-from-form))
(defclass the-form (form)
((type-cast :accessor form-type-cast
:initarg :type)
(form :accessor form-expr
:initarg :expr)
)
(:documentation "The THE-FORM Class.
The class of instances of the 'the' form. The accessors
FORM-TYPE-CAST and FORM-EXPR can be used to access the parts of this
class instances.")
)
(defun the-form-p (x) (typep x 'the-form))
;;;---------------------------------------------------------------------------
;;; PROGx forms.
(defclass progn-form (form implicit-progn)
()
(:documentation "The PROGN-FORM Class.
The instances of this class are (PROGN ...) forms. It assumes
IMPLICIT-PROGN but it used for explicit PROGN forms.")
)
(defun progn-form-p (x) (typep x 'progn-form))
(defclass progv-form (form implicit-progn)
((symbols :accessor form-symbols
:initarg :symbols)
(vals :accessor form-values
:initarg :values)
)
(:documentation "The PROGV-FORM Class.")
)
(defun progv-form-p (x) (typep x 'progv-form))
;;;---------------------------------------------------------------------------
;;; Assignment forms.
(defclass assignment-form (form)
((places :accessor form-places
:initarg :places)
(vals :accessor form-values
:initarg :values)
)
(:documentation "The ASSIGNMENT-FORM CLass.
The superclass of all 'assignment' forms.")
)
(defun assignment-form-p (x) (typep x 'assignment-form))
(defclass set-form (assignment-form) ()
(:documentation "The SET-FORM Class."))
(defun set-form-p (x) (typep x 'set-form))
(defclass setq-form (assignment-form)
((places :initarg :symbols))
(:documentation "The SET-FORM Class.
An assignment form with a different keyword initializer.")
)
(defun setq-form-p (x) (typep x 'setq-form))
(defclass setf-form (assignment-form) ()
(:documentation "The SETF-FORM Class.")
)
(defun setf-form-p (x) (typep x 'setf-form))
;;;---------------------------------------------------------------------------
;;; tagbody and prog/prog*
(defclass tagbody-form (form)
((tagbody :accessor form-body
:initarg :body
)
(tags :accessor form-tags
:initarg :tags
:initform ()
)
)
(:documentation "The TAGBODY-FORM Class.
The class of instances of 'tagbody' forms. The slot TAGBODY (accessed
via FORM-BODY) contains the list of subforms, including the 'go-tags'
that are parsed specially. The 'go-tags' are held in the TAGS slot
and accessed via the FORM-TAGS accessor.")
)
(defun tagbody-form-p (x) (typep x 'tagbody-form))
(defclass prog-form (vbinding-form tagbody-form)
((body-env :accessor form-body-env
:initarg :body-env
:initform () #| (make-env) |#
)
)
(:documentation "The PROG-FORM Class.
The class of 'prog' forms. Since it is also a VBINDING-FORM, it also
has an associated 'form environment', accessible via FORM-BODY-ENV.")
)
(defun prog-form-p (x) (typep x 'prog-form))
(defclass prog*-form (prog-form)
()
(:documentation "The PROG-FORM Class.
See Also:
PROG-FORM")
)
(defun prog*-form-p (x) (typep x 'prog*-form))
;;;---------------------------------------------------------------------------
;;; Error handling forms.
(defclass unwind-protect-form (form)
((protected-form :accessor form-protected-form
:initarg :protected-form
)
(cleanup-forms :accessor form-cleanup-forms
:initarg :cleanup-forms)
)
(:documentation "The UNWIND-PROTECT-FORM Class")
)
(defclass error-clause-form (form implicit-progn) ; Should inherit for SELECTION-CLAUSE-FORM.
((datum :accessor form-datum
:initarg :datum)
(lambda-list :accessor form-lambda-list
:accessor form-args
:initarg :lambda-list
:initarg :args)
)
(:documentation "The ERROR-CLAUSE-FORM Class.")
)
(defclass condition-case-form (form)
((handled-form :accessor form-handled-form
:initarg :handled-form
)
(clauses :accessor form-clauses
:initarg :clauses
)
)
(:documentation "The CONDITION-CLAUSE-FORM Class.")
)
(defclass handler-case-form (condition-case-form) ()
(:documentation "The HANDLER-CASE-FORM Class.")
)
(defclass restart-case-form (condition-case-form) ()
(:documentation "The RESTART-CASE-FORM Class.")
)
(defclass handler-bind-form (fbinding-form implicit-progn) ()
(:documentation "The HANDLER-BIND-FORM Class.")
)
(defclass restart-bind-form (fbinding-form implicit-progn) ()
(:documentation "The RESTART-BIND-FORM Class.")
)
;;;;---------------------------------------------------------------------------
;;;; Definition forms.
(defclass function-definition-form (lambda-form)
()
(:documentation "The FUNCTION-DEFINITION-FORM CLass.")