diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-04-27 18:33:07 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-04-30 14:26:07 +0200 |
commit | 75588e966906ddb89edb1ffde9ea7af8d6185dab (patch) | |
tree | ed965ca8321899ba559cf48b7a4188f9b71d4091 /src/dotty/tools/dotc/ast/tpd.scala | |
parent | d0f9d6df8bfa185019004740ea8dd6472f3e7ed9 (diff) | |
download | dotty-75588e966906ddb89edb1ffde9ea7af8d6185dab.tar.gz dotty-75588e966906ddb89edb1ffde9ea7af8d6185dab.tar.bz2 dotty-75588e966906ddb89edb1ffde9ea7af8d6185dab.zip |
tpd.WhileDo helper.
Diffstat (limited to 'src/dotty/tools/dotc/ast/tpd.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 56d916bdd..03feafafa 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -243,6 +243,17 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { ta.assignType(untpd.TypeDef(cls.name, impl), cls) } + // { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() } + def WhileDo(owner: Symbol, cond: Tree, body: List[Tree])(implicit ctx: Context): Tree = { + val sym = ctx.newSymbol(owner, nme.WHILE_PREFIX, Flags.Label | Flags.Synthetic, + MethodType(Nil, defn.UnitType), coord = cond.pos) + + val call = Apply(ref(sym), Nil) + val rhs = If(cond, Block(body, call), unitLiteral) + Block(List(DefDef(sym, rhs)), call) + } + + def Import(expr: Tree, selectors: List[untpd.Tree])(implicit ctx: Context): Import = ta.assignType(untpd.Import(expr, selectors), ctx.newImportSymbol(ctx.owner, expr)) |