blob: b945c132783303897e380b6c990cebbb0de98844 (
plain)
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
|
(.module:
[lux #*
[control
[equivalence (#+ Equivalence)]
[hash (#+ Hash)]
pipe]
[data
[text
format]]])
(type: #export Register Nat)
(type: #export Variable
(#Local Register)
(#Foreign Register))
(type: #export Reference
(#Variable Variable)
(#Constant Name))
(structure: #export _ (Equivalence Variable)
(def: (= reference sample)
(case [reference sample]
(^template [<tag>]
[(<tag> reference') (<tag> sample')]
(n/= reference' sample'))
([#Local] [#Foreign])
_
#0)))
(structure: #export _ (Hash Variable)
(def: eq Equivalence<Variable>)
(def: (hash var)
(case var
(#Local register)
(n/* 1 register)
(#Foreign register)
(n/* 2 register))))
(do-template [<name> <family> <tag>]
[(template: #export (<name> content)
(<| <family>
<tag>
content))]
[local #..Variable #..Local]
[foreign #..Variable #..Foreign]
)
(do-template [<name> <tag>]
[(template: #export (<name> content)
(<| <tag>
content))]
[variable #..Variable]
[constant #..Constant]
)
(def: #export self Reference (..local 0))
(def: #export self?
(-> Variable Bit)
(|>> ..variable
(case> (^ (..local 0))
#1
_
#0)))
(def: #export (%variable variable)
(Format Variable)
(case variable
(#Local local)
(format "+" (%n local))
(#Foreign foreign)
(format "-" (%n foreign))))
(def: #export (%reference reference)
(Format Reference)
(case reference
(#Variable variable)
(%variable variable)
(#Constant constant)
(%name constant)))
|