aboutsummaryrefslogtreecommitdiffstats
path: root/csc/ir2.csc
blob: 46dbad1311641088078ac05e481d80cdfb082b70 (plain) (blame)
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
(define-library (csc ir2)
  (export
    lambda-body
    lambda-case-alternate
    lambda-case-arguments
    lambda-case-body
    lambda-case-gensyms
    lambda-case-rest
    lambda-case?
    make-lambda-case

    ; Re-exports from IR1.
    call-arguments
    call-procedure
    call?
    constant-expression
    constant?
    if-alternate
    if-consequent
    if-test
    if?
    lambda?
    make-call
    make-constant
    make-if
    make-lambda
    make-sequence
    make-toplevel-define
    make-toplevel-ref
    make-void
    sequence-head
    sequence-tail
    sequence?
    toplevel-define-expression
    toplevel-define-name
    toplevel-define?
    toplevel-ref-name
    toplevel-ref?
    void?)
  (import (scheme base)
          (only (csc ir1)
            call-arguments
            call-procedure
            call?
            constant-expression
            constant?
            if-alternate
            if-consequent
            if-test
            if?
            lambda-body
            lambda?
            make-call
            make-constant
            make-if
            make-lambda
            make-sequence
            make-toplevel-define
            make-void
            sequence-head
            sequence-tail
            sequence?
            toplevel-define-expression
            toplevel-define-name
            toplevel-define?
            void?))
  (begin
    ; This library defines the intermediate representation IR2.
    ; It's CPS time bitch.


    ; An atom consists of an ir1 expression and a continuation.
    (define-record-type <atom>
      (make-atom expression continuation)
      atom?
      (expression atom-expression)
      (continuation atom-continuation))


    ; <variable> 
    (define-record-type <variable>
      (make-variable k var


    ; <closure-ref> idx
    ; Reference to a variable by index in the closure.
    (define-record-type <closure-ref>
      (make-closure-ref idx)
      closure-ref?
      (idx closure-ref-index))


    ; <lambda-case> arguments rest