diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-04-11 15:11:46 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-05-06 15:21:20 +0200 |
commit | afb21953f75beda26a14b447e2caa0a2cb21904a (patch) | |
tree | 5b04a5f882a005591bdba8a3e1ad8678700314ea /src | |
parent | bf9ae99e77f179e9f5ad3c2074edbb5aab0fe9f1 (diff) | |
download | dotty-afb21953f75beda26a14b447e2caa0a2cb21904a.tar.gz dotty-afb21953f75beda26a14b447e2caa0a2cb21904a.tar.bz2 dotty-afb21953f75beda26a14b447e2caa0a2cb21904a.zip |
Constructors stub
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/Constructors.scala | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index 457238da4..5f2f4f7b0 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -21,6 +21,7 @@ class Compiler { List( List(new FrontEnd), List(new LazyValsCreateCompanionObjects, + /* new Constructors, */ new TailRec), //force separataion between lazyVals and LVCreateCO List(new PatternMatcher, new LazyValTranformContext().transformer, diff --git a/src/dotty/tools/dotc/transform/Constructors.scala b/src/dotty/tools/dotc/transform/Constructors.scala new file mode 100644 index 000000000..bc9d6ea61 --- /dev/null +++ b/src/dotty/tools/dotc/transform/Constructors.scala @@ -0,0 +1,27 @@ +package dotty.tools.dotc.transform + +import TreeTransforms._ +import dotty.tools.dotc.ast.tpd._ +import dotty.tools.dotc.core.Contexts.Context +import dotty.tools.dotc.core.StdNames._ + +/** This transform moves initializers from body to constructor. + * Right now it's a dummy. + * Awaiting for real implemetation + */ +class Constructors extends TreeTransform { + + override def name: String = "constructors" + override def transformDefDef(tree: DefDef)(implicit ctx: Context, info: TransformerInfo): Tree = { + if(tree.symbol.isClassConstructor) { + val claz = tree.symbol.enclosingClass.asClass + val zuper = claz.info.parents.head.typeSymbol + cpy.DefDef(tree, tree.mods, tree.name, tree.tparams, tree.vparamss, tree.tpt, rhs = { + val parentCall = Apply(Select(Super(This(claz), tpnme.EMPTY, true), zuper.primaryConstructor), Nil) + if(tree.rhs.isEmpty) parentCall + else Block(List(parentCall), tree.rhs) + + }) + } else tree + } +}
\ No newline at end of file |