-
Notifications
You must be signed in to change notification settings - Fork 2
/
SpadNodeRewrite.spad
56 lines (47 loc) · 2.39 KB
/
SpadNodeRewrite.spad
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
)abbrev category SNRW SpadNodeRewrite
SpadNodeRewrite() : Category == Definition where
)include SpadTypeDefs.inc
Definition ==> SpadNodeWalk(N) add
walk (a : APP) == nodeApp(walk a.function, map(walk, a.args))
walk (a : ASS) == nodeAssign(walk a.lval, walk a.rval)
walk (cn : CE) ==
nodeCondExpr(walk cn.cond, walk cn.truebr, walk cn.falsebr)
walk (fn : FN) ==
nodeFun(fn.name, map(walk, fn.args), walk fn.type, walk fn.body)
walk (ft : FT) ==
nodeFtor(ft.name, [(walk [arg]) :: TD for arg in ft.args],
walk ft.type, walk ft.extends, walk ft.capsule)
walk (im : IM) == nodeImport(walk im.type)
walk (it : IT) == nodeIterator(it.var, walk it.seq)
walk (lp : LP) ==
nodeLoop(lp.kind, map(walk, lp.itors), map(walk, lp.guards),
walk lp.body)
walk (m : SM) == nodeMacro(m.name, m.args, walk m.body)
walk (mr : MR) == [mr]
walk (nr : NR) == [nr]
walk (mt : MT) == nodeMappingType(map(walk, mt.args), walk mt.result)
walk (rt : RT) == nodeRecordType [(walk [f]) :: TD for f in fields rt]
walk (seg : SEG) == nodeSeg(walk seg.start, walk seg.end)
walk (s : AGG) == [collapse [s.kind, map(walk, s.list)]]
walk (te : SC) == nodeCase(walk te.expr, walk te.type)
walk (te : ST) == nodeSubType(walk te.expr, walk te.type)
walk (te : TC) == nodeTypeCoerce(walk te.expr, walk te.type)
walk (te : TD) == nodeTypeDecl(walk te.expr, walk te.type)
walk (te : TG) == nodeTypeGuard(walk te.expr, walk te.type)
walk (te : TEH) == nodeTypeHas(walk te.expr, walk te.type)
walk (te : TEI) == nodeTypeIs(walk te.expr, walk te.type)
walk (te : TEP) == nodeTypePretend(walk te.expr, walk te.type)
walk (ti : TI) ==
nodeTypeInfo((walk ti.body) :: AGG, map(walk, ti.hasList),
map(walk, ti.constraints), walk ti.superType)
walk (te : TO) == nodeTypeOrigin(walk te.expr, walk te.type)
walk (te : TS) == nodeTypeSelect(walk te.expr, walk te.type)
walk (tv : TVL) == nodeTypeValue(walk tv.type, walk tv.value)
walk (tv : TV) == [tv]
walk (ut : UT) == nodeUnionType map(walk, variants ut)
walk (w : SW) == nodeWhere(walk w.body, walk w.env)
walk (s : String) == [s]
walk (s : Symbol) == [s]
walk (i : Integer) == [i]
walk (f : DoubleFloat) == [f]
walk () == null