@@ -25,23 +25,23 @@ class BlockTraverser(subst: SymbolSubst):
25
25
case HandleBlockReturn (res) => applyResult(res)
26
26
case Match (scrut, arms, dflt, rst) =>
27
27
val scrut2 = applyPath(scrut)
28
- arms.map : arm =>
28
+ arms.foreach : arm =>
29
29
applyCase(arm._1); applySubBlock(arm._2)
30
- dflt.map (applySubBlock)
30
+ dflt.foreach (applySubBlock)
31
31
applySubBlock(rst)
32
32
case Label (lbl, bod, rst) => applyLocal(lbl); applySubBlock(bod); applySubBlock(rst)
33
33
case Begin (sub, rst) => applySubBlock(sub); applySubBlock(rst)
34
34
case TryBlock (sub, fin, rst) => applySubBlock(sub); applySubBlock(fin); applySubBlock(rst)
35
35
case Assign (l, r, rst) => applyLocal(l); applyResult(r); applySubBlock(rst)
36
36
case b @ AssignField (l, n, r, rst) =>
37
- applyPath(l); applyResult(r); applySubBlock(rst); b.symbol.map (_.subst)
37
+ applyPath(l); applyResult(r); applySubBlock(rst); b.symbol.foreach (_.subst)
38
38
case Define (defn, rst) => applyDefn(defn); applySubBlock(rst)
39
39
case HandleBlock (l, res, par, args, cls, hdr, bod, rst) =>
40
40
applyLocal(l)
41
41
applyLocal(res)
42
42
applyPath(par)
43
- args.map (applyPath)
44
- hdr.map (applyHandler)
43
+ args.foreach (applyPath)
44
+ hdr.foreach (applyHandler)
45
45
applySubBlock(bod)
46
46
applySubBlock(rst)
47
47
case AssignDynField (lhs, fld, arrayIdx, rhs, rest) =>
@@ -51,55 +51,57 @@ class BlockTraverser(subst: SymbolSubst):
51
51
applySubBlock(rest)
52
52
53
53
def applyResult (r : Result ): Unit = r match
54
- case r @ Call (fun, args) => applyPath(fun); args.map (applyArg)
55
- case Instantiate (cls, args) => ; applyPath(cls); args.map (applyPath)
54
+ case r @ Call (fun, args) => applyPath(fun); args.foreach (applyArg)
55
+ case Instantiate (cls, args) => ; applyPath(cls); args.foreach (applyPath)
56
56
case p : Path => applyPath(p)
57
57
58
58
def applyPath (p : Path ): Unit = p match
59
59
case DynSelect (qual, fld, arrayIdx) =>
60
60
applyPath(qual); applyPath(fld)
61
61
case p @ Select (qual, name) =>
62
- applyPath(qual); p.symbol.map (_.subst)
62
+ applyPath(qual); p.symbol.foreach (_.subst)
63
63
case v : Value => applyValue(v)
64
64
65
65
def applyValue (v : Value ): Unit = v match
66
66
case Value .Ref (l) => l.subst
67
67
case Value .This (sym) => sym.subst
68
68
case Value .Lit (lit) => ()
69
69
case v @ Value .Lam (params, body) => applyLam(v)
70
- case Value .Arr (elems) => elems.map(applyArg)
70
+ case Value .Arr (elems) => elems.foreach(applyArg)
71
+ case Value .Rcd (fields) => fields.foreach:
72
+ case RcdArg (idx, value) => idx.foreach(applyPath); applyPath(value)
71
73
72
74
def applyLocal (sym : Local ): Unit = sym.subst
73
75
74
76
def applyFunDefn (fun : FunDefn ): Unit =
75
- fun.owner.map (_.subst)
77
+ fun.owner.foreach (_.subst)
76
78
fun.sym.subst
77
- fun.params.map (applyParamList)
79
+ fun.params.foreach (applyParamList)
78
80
applySubBlock(fun.body)
79
81
80
82
def applyDefn (defn : Defn ): Unit = defn match
81
83
case defn : FunDefn => applyFunDefn(defn)
82
- case ValDefn (owner, k, sym, rhs) => owner.map (_.subst); sym.subst; applyPath(rhs)
84
+ case ValDefn (owner, k, sym, rhs) => owner.foreach (_.subst); sym.subst; applyPath(rhs)
83
85
case ClsLikeDefn (own, isym, sym, k, paramsOpt, auxParams, parentPath, methods,
84
86
privateFields, publicFields, preCtor, ctor) =>
85
- own.map (_.subst)
87
+ own.foreach (_.subst)
86
88
isym.subst
87
89
sym.subst
88
- paramsOpt.map (applyParamList)
89
- auxParams.map (applyParamList)
90
- parentPath.map (applyPath)
91
- methods.map (applyFunDefn)
92
- privateFields.map (_.subst)
93
- publicFields.map (applyTermDefinition)
90
+ paramsOpt.foreach (applyParamList)
91
+ auxParams.foreach (applyParamList)
92
+ parentPath.foreach (applyPath)
93
+ methods.foreach (applyFunDefn)
94
+ privateFields.foreach (_.subst)
95
+ publicFields.foreach (applyTermDefinition)
94
96
applySubBlock(preCtor)
95
97
applySubBlock(ctor)
96
98
97
99
def applyArg (arg : Arg ): Unit =
98
100
applyPath(arg.value)
99
101
100
102
def applyParamList (pl : ParamList ): Unit =
101
- pl.params.map (_.sym.subst)
102
- pl.restParam.map (_.sym.subst)
103
+ pl.params.foreach (_.sym.subst)
104
+ pl.restParam.foreach (_.sym.subst)
103
105
104
106
def applyCase (cse : Case ): Unit = cse match
105
107
case Case .Lit (lit) => ()
@@ -111,17 +113,17 @@ class BlockTraverser(subst: SymbolSubst):
111
113
def applyHandler (hdr : Handler ): Unit =
112
114
hdr.sym.subst
113
115
hdr.resumeSym.subst
114
- hdr.params.map (applyParamList)
116
+ hdr.params.foreach (applyParamList)
115
117
applySubBlock(hdr.body)
116
118
117
119
def applyLam (lam : Value .Lam ): Unit =
118
120
applyParamList(lam.params)
119
121
applySubBlock(lam.body)
120
122
121
123
def applyTermDefinition (td : TermDefinition ): Unit =
122
- td.owner.map (_.subst)
124
+ td.owner.foreach (_.subst)
123
125
td.sym.subst
124
- td.params.map (applyParamList)
126
+ td.params.foreach (applyParamList)
125
127
td.resSym.subst
126
128
127
129
class BlockTraverserShallow (subst : SymbolSubst ) extends BlockTraverser (subst):
@@ -138,11 +140,11 @@ class BlockTraverserShallow(subst: SymbolSubst) extends BlockTraverser(subst):
138
140
applyLocal(l)
139
141
applyLocal(res)
140
142
applyPath(par)
141
- args.map (applyPath)
143
+ args.foreach (applyPath)
142
144
cls.subst
143
- hdr.map (applyHandler)
145
+ hdr.foreach (applyHandler)
144
146
applySubBlock(rst)
145
147
case _ => super .applyBlock(b)
146
148
147
- class BlockDataTraverse (subst : SymbolSubst ) extends BlockTraverserShallow (subst):
149
+ class BlockDataTraverser (subst : SymbolSubst ) extends BlockTraverserShallow (subst):
148
150
override def applySubBlock (b : Block ): Unit = ()
0 commit comments