|
1 | 1 | package effekt.core |
2 | 2 |
|
3 | 3 | import effekt.{Template, core, symbols} |
4 | | -import effekt.context.Context |
5 | | -import effekt.core.Type.{PromptSymbol, ResumeSymbol} |
6 | 4 |
|
7 | 5 | /** |
8 | 6 | * Freshens bound names in a given term for tests. |
@@ -52,13 +50,12 @@ class TestRenamer(names: Names = Names(Map.empty)) extends core.Tree.Rewrite { |
52 | 50 | case bnds if bnds.contains(id) => bnds(id) |
53 | 51 | }.getOrElse { |
54 | 52 | scopes match { |
55 | | - case Nil => |
56 | | - id |
57 | | - case head :: tail => { |
| 53 | + case Nil => id |
| 54 | + case _ => |
58 | 55 | val freshId = freshIdFor(id) |
59 | | - scopes = (head + (id -> freshId)) :: tail |
| 56 | + val updatedLast = scopes.last + (id -> freshId) |
| 57 | + scopes = scopes.init :+ updatedLast |
60 | 58 | freshId |
61 | | - } |
62 | 59 | } |
63 | 60 | } |
64 | 61 | } |
@@ -188,17 +185,11 @@ class TestRenamer(names: Names = Names(Map.empty)) extends core.Tree.Rewrite { |
188 | 185 | } |
189 | 186 |
|
190 | 187 | override def rewrite(p: Property) = p match { |
191 | | - case Property(id: Id, tpe: BlockType) => |
192 | | - withBinding(id) { |
193 | | - Property(rewrite(id), rewrite(tpe)) |
194 | | - } |
| 188 | + case Property(id: Id, tpe: BlockType) => Property(rewrite(id), rewrite(tpe)) |
195 | 189 | } |
196 | 190 |
|
197 | 191 | override def rewrite(f: Field) = f match { |
198 | | - case Field(id, tpe) => |
199 | | - withBinding(id) { |
200 | | - Field(rewrite(id), rewrite(tpe)) |
201 | | - } |
| 192 | + case Field(id, tpe) => Field(rewrite(id), rewrite(tpe)) |
202 | 193 | } |
203 | 194 |
|
204 | 195 | override def rewrite(b: BlockType): BlockType = b match { |
@@ -229,15 +220,11 @@ class TestRenamer(names: Names = Names(Map.empty)) extends core.Tree.Rewrite { |
229 | 220 | } |
230 | 221 |
|
231 | 222 | override def rewrite(b: BlockParam): BlockParam = b match { |
232 | | - case BlockParam(id, tpe, capt) => withBinding(id) { |
233 | | - BlockParam(rewrite(id), rewrite(tpe), rewrite(capt)) |
234 | | - } |
| 223 | + case BlockParam(id, tpe, capt) => BlockParam(rewrite(id), rewrite(tpe), rewrite(capt)) |
235 | 224 | } |
236 | 225 |
|
237 | 226 | override def rewrite(v: ValueParam): ValueParam = v match { |
238 | | - case ValueParam(id, tpe) => withBinding(id) { |
239 | | - ValueParam(rewrite(id), rewrite(tpe)) |
240 | | - } |
| 227 | + case ValueParam(id, tpe) => ValueParam(rewrite(id), rewrite(tpe)) |
241 | 228 | } |
242 | 229 |
|
243 | 230 | def apply(m: core.ModuleDecl): core.ModuleDecl = |
|
0 commit comments