Skip to content

TailRec phase and tests for it. #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ object DottyBuild extends Build {

val TRAVIS_BUILD = "dotty.travis.build"

val agentOptions = List(
// "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005",
// "-agentpath:/home/dark/opt/yjp-2013-build-13072/bin/linux-x86-64/libyjpagent.so"
)


val defaults = Defaults.defaultSettings ++ Seq(
// set sources to src/, tests to test/ and resources to resources/
scalaSource in Compile := baseDirectory.value / "src",
Expand Down Expand Up @@ -51,12 +57,12 @@ object DottyBuild extends Build {
// System.err.println("BOOTPATH: " + fullpath)

val travis_build = // propagate if this is a travis build
if (sys.props.isDefinedAt(TRAVIS_BUILD))
if (sys.props.isDefinedAt(TRAVIS_BUILD))
List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}")
else
else
List()

travis_build ::: fullpath
agentOptions ::: travis_build ::: fullpath
}
)

Expand Down
5 changes: 3 additions & 2 deletions src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class Compiler {
def phases: List[List[Phase]] =
List(
List(new FrontEnd),
List(new LazyValsCreateCompanionObjects, new PatternMatcher), //force separataion between lazyVals and LVCreateCO
List(new LazyValTranformContext().transformer, new Splitter, new TypeTestsCasts, new InterceptedMethods),
List(new LazyValsCreateCompanionObjects, new TailRec), //force separataion between lazyVals and LVCreateCO
List(new PatternMatcher, new LazyValTranformContext().transformer,
new Splitter, new TypeTestsCasts, new InterceptedMethods),
List(new Erasure),
List(new UncurryTreeTransform)
)
Expand Down
7 changes: 5 additions & 2 deletions src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
* where the closure's type is the target type of the expression (FunctionN, unless
* otherwise specified).
*/
def Closure(meth: TermSymbol, rhsFn: List[List[Tree]] => Tree, targetType: Type = NoType)(implicit ctx: Context): Block = {
def Closure(meth: TermSymbol, rhsFn: List[List[Tree]] => Tree, targs: List[Tree] = Nil, targetType: Type = NoType)(implicit ctx: Context): Block = {
val targetTpt = if (targetType.exists) TypeTree(targetType) else EmptyTree
val call =
if (targs.isEmpty) Ident(TermRef(NoPrefix, meth))
else TypeApply(Ident(TermRef(NoPrefix, meth)), targs)
Block(
DefDef(meth, rhsFn) :: Nil,
Closure(Nil, Ident(TermRef(NoPrefix, meth)), targetTpt))
Closure(Nil, call, targetTpt))
}

def CaseDef(pat: Tree, guard: Tree, body: Tree)(implicit ctx: Context): CaseDef =
Expand Down
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ class Definitions {

lazy val UnitClass = valueClassSymbol("scala.Unit", BoxedUnitClass, java.lang.Void.TYPE, UnitEnc)
lazy val BooleanClass = valueClassSymbol("scala.Boolean", BoxedBooleanClass, java.lang.Boolean.TYPE, BooleanEnc)
lazy val Boolean_! = BooleanClass.requiredMethod(nme.UNARY_!)
lazy val Boolean_! = BooleanClass.requiredMethod(nme.UNARY_!)
lazy val Boolean_and = BooleanClass.requiredMethod(nme.ZAND)
lazy val Boolean_or = BooleanClass.requiredMethod(nme.ZOR)

lazy val ByteClass = valueClassSymbol("scala.Byte", BoxedByteClass, java.lang.Byte.TYPE, ByteEnc)
lazy val ShortClass = valueClassSymbol("scala.Short", BoxedShortClass, java.lang.Short.TYPE, ShortEnc)
Expand Down Expand Up @@ -236,6 +237,7 @@ class Definitions {
lazy val AnnotationClass = ctx.requiredClass("scala.annotation.Annotation")
lazy val ClassfileAnnotationClass = ctx.requiredClass("scala.annotation.ClassfileAnnotation")
lazy val StaticAnnotationClass = ctx.requiredClass("scala.annotation.StaticAnnotation")
lazy val TailrecAnnotationClass = ctx.requiredClass("scala.annotation.tailrec")

// Annotation classes
lazy val AliasAnnot = ctx.requiredClass("dotty.annotation.internal.Alias")
Expand Down
9 changes: 9 additions & 0 deletions src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@ object Flags {
/** Labeled `private` or `protected[local]` */
final val PrivateOrLocal = Private | Local

/** Either a module or a final class */
final val ModuleOrFinal = ModuleClass | Final

/** Either mutable or lazy */
final val MutableOrLazy = Mutable | Lazy

/** Labeled `private` or `final` */
final val PrivateOrFinal = Private | Final

/** A type parameter with synthesized name */
final val ExpandedTypeParam = allOf(ExpandedName, TypeParam)

Expand Down
6 changes: 6 additions & 0 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ object SymDenotations {
final def enclosingClass(implicit ctx: Context): Symbol =
if (isClass || !exists) symbol else owner.enclosingClass

final def isEffectivelyFinal(implicit ctx: Context): Boolean = {
(this.flags is Flags.PrivateOrFinal) || (!this.owner.isClass) ||
((this.owner.flags is (Flags.ModuleOrFinal)) && (!this.flags.is(Flags.MutableOrLazy))) ||
(this.owner.isAnonymousClass)
}

/** The class containing this denotation which has the given effective name.
*/
final def enclosingClassNamed(name: Name)(implicit ctx: Context): Symbol = {
Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ trait Symbols { this: Context =>
for (name <- names) {
val tparam = newNakedSymbol[TypeName](NoCoord)
tparamBuf += tparam
trefBuf += TypeRef(owner.thisType, name).withSym(tparam, Signature.NotAMethod)
trefBuf += TypeRef.withSymAndName(owner.thisType, tparam, name)
}
val tparams = tparamBuf.toList
val bounds = boundsFn(trefBuf.toList)
Expand Down Expand Up @@ -319,7 +319,7 @@ object Symbols {
type ThisName <: Name

private[this] var _id: Int = nextId
//assert(_id != 12325)
//assert(_id != 5859)

/** The unique id of this symbol */
def id = _id
Expand Down
Loading