Skip to content

Pattern matcher #174

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 213 commits into from
Oct 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
2020938
Code to handle overloaded unapply/unapplySeq methods
odersky Aug 3, 2014
168e4f1
Added version settings -migration, -source
odersky Aug 3, 2014
e25232d
Annotation decorators for symbols
odersky Aug 3, 2014
85044e4
Type#foreachPart
odersky Aug 3, 2014
9748c9b
Changed first phase normalization and improvements to TreeTransform
odersky Aug 3, 2014
f87153b
Detect cycles and protected legal ones with LazyRefs
odersky Aug 7, 2014
058729c
LazyRefs break cycles for unpickled types
odersky Aug 8, 2014
19b6a04
Re-enabled checkbounds tests
odersky Aug 8, 2014
9ec3a4f
prepareStats should span all statement transforms
odersky Aug 9, 2014
978a714
Initial version of RefChecks
odersky Aug 9, 2014
80ee8b1
Made Phase a trait
odersky Aug 9, 2014
bb1972b
Fixed fully qualified name of migration annotation
odersky Aug 9, 2014
9024f25
ParamAccessors are assumed to have definition
odersky Aug 9, 2014
57c6c85
Disentangle phases from treetransforms
odersky Aug 9, 2014
96cd350
Module vals are lazy
odersky Aug 9, 2014
80b866f
In refined printer, show only source modifier flags.
odersky Aug 9, 2014
bbf777a
Narrow assertion for Scope#enter
odersky Aug 9, 2014
c2cdd3a
More targeted eta-lifting
odersky Aug 10, 2014
f606a47
Add Product{1,2} supertrait to case classes
odersky Aug 10, 2014
d388e94
Fix Object's scope after ersure
odersky Aug 11, 2014
b89c4af
Add CaseAccessor flag for case accessors
odersky Aug 11, 2014
c7f817f
Added some more methods as infix tree operations:
odersky Aug 11, 2014
98d2583
New methods in Definitions
odersky Aug 11, 2014
ab63413
Sperate matchingDecl and mathingMember.
odersky Aug 11, 2014
ce53589
Add SyntheticMethods miniphase
odersky Aug 11, 2014
974f706
Avoid printing expanded names
odersky Aug 11, 2014
a3cc938
Use _1 intstead of get for accessing unary case class parameters
odersky Aug 11, 2014
81745e2
Fix a problem due to different type inference
odersky Aug 12, 2014
843f976
Two fixes in desugar
odersky Aug 12, 2014
472d711
Add matchesLoosely
odersky Aug 12, 2014
ab8ee53
mergeDenot should prefer concerete over deferred.
odersky Aug 12, 2014
deaa0d8
Package denotations are never transformed
odersky Aug 13, 2014
ece7656
Erasure should copy denotations only if they are changed.
odersky Aug 13, 2014
3558e07
Change access boundary of protected[this]
odersky Aug 13, 2014
34f73de
Fix and enable RefChecks
odersky Aug 13, 2014
a878d19
Changes to tree copying
odersky Jul 6, 2014
891aeba
Switched to new cpy scheme.
odersky Aug 13, 2014
0b41954
Restrict treee copiers with default arguments to trees with more than…
odersky Aug 13, 2014
3ce9d15
Drop commented out code.
odersky Aug 13, 2014
01f2475
Make typed tree copiers selectively retype nodes.
odersky Aug 15, 2014
9326a00
Delete propagateType and RetypingTreeMap
odersky Aug 15, 2014
53ab5f0
Add hook for phase when a TreeTransform is run.
odersky Aug 15, 2014
c54cd3e
Extend retyping to more copy methods.
odersky Aug 15, 2014
7d414eb
Roll Uncurry into Erasure
odersky Aug 16, 2014
90aef30
Moved -Ycheck after Splitter
odersky Aug 14, 2014
f91f030
Disabling adapt in TreeChecker
odersky Aug 17, 2014
58d4706
Split Nullarify functionality to ElimByName, Erasure
odersky Aug 17, 2014
1e29d8a
Moved -Ycheck to last phase before erasure
odersky Aug 17, 2014
f2d27cf
Add #ids for This trees and ClassDefs
odersky Aug 18, 2014
c71643b
Three fixes to substSym
odersky Aug 18, 2014
49cc900
Fix to isAnonymousClass
odersky Aug 18, 2014
71044c8
Add pathTo method for Positioned.
odersky Aug 18, 2014
aae71e7
Make local dummy a non-member type.
odersky Aug 18, 2014
0f6a277
Fixing handling of self in DeepTypeMap#mapClassInfo
odersky Aug 18, 2014
ea616bf
Extend owner checking in TreeChecker
odersky Aug 18, 2014
2cdc79d
Fixed re-tpying of Return nodes.
odersky Aug 18, 2014
91b9180
Fixes to TreeTypeMap
odersky Aug 18, 2014
b53a03f
Make ElimByName change owners of by-name parameters
odersky Aug 18, 2014
f366f86
Refactored TreeTypeMap
odersky Aug 18, 2014
3afdefd
Rename in Phase: name -> phaseName
odersky Aug 18, 2014
f0519c9
Changed phase dependencies from names to classes.
odersky Aug 18, 2014
5b941d2
Fixed class doc comment for ElimByName
odersky Aug 19, 2014
65aa105
Make-not private
odersky Aug 19, 2014
b10c590
Fix signature of by-name parameters.
odersky Aug 20, 2014
ab0105c
Comments about phase orderings and shadowed references.
odersky Aug 20, 2014
1f2619b
renaming: core.transform.Erasure -> core.TypeErasure
odersky Aug 20, 2014
3b7cba4
Make type creators work for erased types.
odersky Aug 24, 2014
3d92b75
Add TypedSplice case to untpd.TreeAccumulator
odersky Aug 24, 2014
412fc2c
Move foreachSubTreeOf of to tpd.
odersky Aug 24, 2014
bdefca9
Fix context for super calls
odersky Aug 24, 2014
70abd73
Account for package objects when constructing types of idents.
odersky Aug 24, 2014
aa7a039
Check that idents don't assume magic.
odersky Aug 24, 2014
85d963d
Clean up printing of flags and params
odersky Aug 24, 2014
d46066b
Fixes to erasure
odersky Aug 24, 2014
9883d54
Override symbolOfType in ReTyper.
odersky Aug 24, 2014
bd8ff17
Fixing refined printing under -uniqid
odersky Aug 24, 2014
b56a743
Special context for self constructor args
odersky Aug 24, 2014
15c4fec
ref(<type>) -> TypeTree
odersky Aug 25, 2014
b41732c
New minipahse: AttachOuter
odersky Aug 25, 2014
eadfa6a
Fix to bringforward.
odersky Aug 25, 2014
254665e
Fix to baseClasses.
odersky Aug 25, 2014
97d89af
Fixes to erasure
odersky Aug 25, 2014
08c6eac
thisType of a module class is a term ref to the source module.
odersky Aug 26, 2014
292ce68
Rebinding ThisTypes
odersky Aug 27, 2014
bfb328f
Make ThisTypes take TypeRefs instead of ClassSymbols
odersky Aug 27, 2014
7663191
Fixes in TypeTestsCast
odersky Aug 28, 2014
e195a2e
Fix in underlyingClassRef
odersky Aug 28, 2014
215f73f
Disable enclding in retyping.
odersky Aug 28, 2014
cdaa3a0
Enabling primitive operations in ReTyper
odersky Aug 28, 2014
11ffd9e
Avoid writing ExprTypes in result types of DefDefs
odersky Aug 28, 2014
f7d3f3b
Better error diadnostics in TreeChecker.
odersky Aug 28, 2014
aae91ed
Fixes to erasure to make -Ycheck:all work.
odersky Aug 28, 2014
3ea2fe9
Added todo comment
odersky Aug 29, 2014
8b9bdfe
Avoid cyclic reference errors in ShowScala
odersky Aug 29, 2014
9a49def
Shorten "if denotation is current the symbol" to "currentSymbol".
odersky Aug 29, 2014
c8d13a8
Disabling two tests which failed.
odersky Aug 29, 2014
cc687b4
Function and multi-array type methods get implicit contexts.
odersky Aug 30, 2014
5362969
Eliminate Ident/Select types in FirstTransform
odersky Aug 30, 2014
4041c5d
Ensure that after erasure all types are erased.
odersky Aug 30, 2014
5e7c262
Moving an assertion from erasure to TreeChecker.
odersky Aug 30, 2014
6e47e2b
Generalize equivalentThisTypes
odersky Aug 31, 2014
e7e1cdc
Avoid reloading NonMemberSyms.
odersky Aug 31, 2014
2bfff5e
Fix to elidable prefix.
odersky Aug 31, 2014
8f321f2
Types of This trees are promoted during retyping.
odersky Aug 31, 2014
47b1d73
New phase: outerAccessors
odersky Aug 31, 2014
ec1d274
Add outer parameters in constructor calls.
odersky Aug 31, 2014
d85f2dd
Added OuterAccessor flag.
odersky Sep 1, 2014
dc958b7
Ensure in FirstTransform that all This references are explicit.
odersky Sep 1, 2014
2788547
Allow more leniency in time travel.
odersky Sep 1, 2014
2558c49
Completed outer paths.
odersky Sep 1, 2014
2251026
Add inSuperCall mode and flag.
odersky Sep 4, 2014
431288d
Move crash diagnostics from TreeChecker to ReTyper.
odersky Sep 4, 2014
652a7e5
Enclosing class skips classes from inSuperCall definitions
odersky Sep 4, 2014
dc02760
Partially reverting of 08c6eaca
odersky Sep 5, 2014
b33f604
Fix a bug in unpickler
odersky Sep 4, 2014
795796d
CyclicError messages now go to printer
odersky Sep 4, 2014
c0b69bb
Harden construction of i"..." strings
odersky Sep 5, 2014
a661bed
Bring back blockescapes test...
odersky Sep 6, 2014
44bdec1
Rename OuterAccessors to ExplicitOuter
odersky Sep 6, 2014
e104093
Better tests and more fixes for ExplicitOuter
odersky Sep 6, 2014
b58b906
Generalize phase postcondition checking.
odersky Sep 6, 2014
c3078b1
Make foreach/exsists into tree infix methods
odersky Sep 6, 2014
b129332
Move explicit outer after pattern matching
odersky Sep 6, 2014
5cc99d4
Fixes to TreeChecker
odersky Sep 10, 2014
81b27b1
Keep SuperTypes around after erasure.
odersky Sep 10, 2014
47f0b45
Fix class decls in TypeTypeMap
odersky Sep 10, 2014
52db988
Make isVolatile a SymUtil method.
odersky Sep 10, 2014
094dc75
Keep inherited names through erasure
odersky Sep 10, 2014
b2e0e7b
tpd.TreeOps#select creates non member syms after erasure.
odersky Sep 10, 2014
377109a
Erasure should keep prefixes in TermRefs
odersky Sep 12, 2014
7af0b4b
Phase name change of explicitOuter.
odersky Sep 10, 2014
97828b3
Handle return in tailcalls.
odersky Sep 11, 2014
edbe9ed
Skip label methods in enclosing method
odersky Sep 12, 2014
f05dafe
Better failure diagnostic in TreeTransform
odersky Sep 12, 2014
bb5b049
Fix handling of Array#clone in Erasure
odersky Sep 12, 2014
2317764
New phase: CapturedVars
odersky Sep 12, 2014
5634dcc
Better TreeTypeMaps
odersky Sep 13, 2014
b22dc6d
Revert of b2e0e7b4 "tpd.TreeOps#select creates non member syms after …
odersky Sep 13, 2014
f0dfea4
Changes from discussion in #171
DarkDimius Sep 9, 2014
73324fa
Allow converting junit test to scalameter benchmark
DarkDimius Jul 23, 2014
d78c9d3
Definitions used by pattern matcher
DarkDimius Sep 5, 2014
0ceaff7
initValue helper method
DarkDimius Sep 9, 2014
fb8df8c
Making all case classes implement Product. Requires adding Product0
DarkDimius Sep 9, 2014
1287f2d
Unapply doc update
DarkDimius Sep 9, 2014
7a74d71
More complicated patterns.
DarkDimius Sep 9, 2014
56a0a90
Definitions used by patmat
DarkDimius Sep 9, 2014
fa5212f
Common functionality to be shared between patmat and typer
DarkDimius Sep 9, 2014
4c62011
CommonCodegen for patMat
DarkDimius Sep 9, 2014
d626611
Optimized codegen for patmat
DarkDimius Sep 9, 2014
28ca226
TreeMakers for patmat
DarkDimius Sep 9, 2014
837a1e9
add Substitution to patmat.
DarkDimius Sep 9, 2014
f03bae9
Match translator for patmat
DarkDimius Sep 9, 2014
e5aafda
Pattern expanders for patmat
DarkDimius Sep 9, 2014
738f5ef
Helper methods for patmat
DarkDimius Sep 9, 2014
e54dd1a
Adapting patmat for dotty
DarkDimius Sep 9, 2014
07b757b
more of adapting patmat for dotty
DarkDimius Sep 9, 2014
ef16bfe
More fixes, added _id for internal tracking of failures
DarkDimius Sep 9, 2014
00dbbe6
Most of tests succeed now.
DarkDimius Sep 9, 2014
278d6cb
Everything except unapplySeq doesn't explode.
DarkDimius Sep 9, 2014
899554f
Fixed unapplySeq. Patmat passes all test suite but typer itself break…
DarkDimius Sep 9, 2014
8f6ce34
Remaining definitions for patmat.
DarkDimius Sep 9, 2014
80d8634
Remove dead code and add todo about outer tests not being generated
DarkDimius Sep 9, 2014
c2402d2
After merge fixes
DarkDimius Sep 9, 2014
0c551f0
More convinient appliedToNone
DarkDimius Sep 12, 2014
b12c2d8
Extract ExplicitOuter functionality to be used by patmat
DarkDimius Sep 12, 2014
ab6766c
Several fixes to patmat.
DarkDimius Sep 12, 2014
f75432f
Allow skipping Label's in owner chains
DarkDimius Sep 17, 2014
d6d7c25
More complicated tests for patmat
DarkDimius Sep 17, 2014
09a7718
Fixing periods for explicitOuter
DarkDimius Sep 17, 2014
0a515fc
All pat-mat specific tests succeed now.
DarkDimius Sep 17, 2014
857cd48
Disabling patmat tests failing due to typer.
DarkDimius Sep 23, 2014
8bd1431
Renamed parameters in Typer&Applictaions.
DarkDimius Sep 23, 2014
9b576c2
Fix problem in unapply typing.
odersky Sep 21, 2014
2b52e9c
@odersky have a look.
DarkDimius Sep 23, 2014
58ae0d0
Fix errorneus equality between TermRef and WithFixedSym
DarkDimius Sep 23, 2014
e2a130a
Made TypeVars uncahable keys
odersky Sep 23, 2014
23064fc
Patmat now succeeds tests.
DarkDimius Sep 23, 2014
112d081
More accurate or postcondition conchecking in TreeChecker
odersky Sep 21, 2014
42b8c1d
TypeTestsCasts now handles casts to constant types.
DarkDimius Sep 24, 2014
f50c3f0
Incorporating TypeTestsCasts into Erasure
DarkDimius Sep 24, 2014
1675814
Fix #167
odersky Aug 27, 2014
543ff7f
Make changeOwner more robust regarding non-standard owner chains
odersky Sep 25, 2014
eb2e265
Make rejection of deep subtype call stack optional
odersky Sep 25, 2014
d936dec
Make productArity a synthetic method which can be overridden
odersky Sep 25, 2014
cc79257
Make SubstOnlyTreeMaker maintain type-safety.
DarkDimius Sep 26, 2014
d592368
More better handling of typeTests in patmat.
DarkDimius Sep 26, 2014
992ea66
Bring back test removed between merges.
DarkDimius Sep 26, 2014
19fb9ad
Porting lazy vals to a new scheme.
DarkDimius Sep 26, 2014
02c98aa
Setters are not case accessors
odersky Sep 26, 2014
a159f71
Fixing owner releated error in lazy vals.
DarkDimius Sep 26, 2014
730c3d3
Enabling lazy vals.
DarkDimius Sep 26, 2014
5fe0335
Enable all tests
DarkDimius Sep 26, 2014
2f63059
Fixed assertion to enfornce idempotency of substitutions
odersky Sep 27, 2014
0a9c61c
Fixed needs outer test
odersky Sep 29, 2014
7b407e5
Make LazyVals an IdentityDenotTransformer
DarkDimius Sep 29, 2014
df28f8a
Move check for casting a primitive to a non-primitive type from erasu…
DarkDimius Sep 29, 2014
5f04610
Remove outdated tests.
DarkDimius Sep 29, 2014
d68c106
Enable outer tests in pattern matcher.
DarkDimius Sep 29, 2014
e1064ac
Make Extension methods a miniphase
DarkDimius Sep 29, 2014
5133dfc
Join megaphases. Saves 80 out of 200 seconds for dotc.tests
DarkDimius Sep 29, 2014
cb18aa3
Allow extensions methods to play well with tailrec.
DarkDimius Sep 29, 2014
5f87089
Document why patternMatcher needs to be after tailrec.
DarkDimius Sep 29, 2014
7121ff3
Fix test suite to go deep in subdirectories.
DarkDimius Sep 29, 2014
cedf12b
Cleanup tests.
DarkDimius Sep 29, 2014
7b845a5
Fix SymDenotation.isPrimaryConstructor
DarkDimius Oct 3, 2014
b8de0ad
Seems to be a bug ping @odesrky
DarkDimius Oct 3, 2014
a77e25c
Cleanup patmat.
DarkDimius Oct 3, 2014
0670fc3
Make widening ops more systematic & complete
odersky Oct 9, 2014
be1965c
Use more efficient type comparisons
DarkDimius Oct 11, 2014
e330cc3
Follow standard naming pattern in LazyVals
DarkDimius Oct 11, 2014
42ad90f
prevPhase should indicate previous phase in explicitOuter
DarkDimius Oct 11, 2014
2e6b343
make appliedToNone fail for exprType, use appliedIfMethod instead
DarkDimius Oct 11, 2014
3211985
Cleanup patmat based on feedback
DarkDimius Oct 11, 2014
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
61 changes: 61 additions & 0 deletions bench/src/test/scala/TestsAsBenchmarks.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package dotty.tools.benchmarks

import java.lang.annotation.Annotation
import java.lang.reflect.Method

import org.junit.runner.Request
import org.junit.runner.notification.RunNotifier
import org.scalameter.PerformanceTest.OnlineRegressionReport
import org.scalameter.api._
import org.scalameter.reporting.RegressionReporter.Tester

import scala.collection.mutable.ListBuffer


abstract class TestsToBenchmarkConverter
(targetClass: Class[_],
filterAnnot: Class[_ <: java.lang.annotation.Annotation] = classOf[org.junit.Test].asInstanceOf[Class[_ <: java.lang.annotation.Annotation]])
extends OnlineRegressionReport {

// accept all the results, do not fail
override def tester: Tester = new Tester.Accepter

override def executor: Executor = LocalExecutor(warmer, aggregator, measurer)
val testNames = getMethodsAnnotatedWith(targetClass, filterAnnot).map(_.getName).sorted


val tests = testNames.map{name =>
val runner = Request.method(targetClass, name).getRunner
(name, Gen.single("test")(name).map(Request.method(targetClass, _).getRunner))}.toMap
//Gen.enumeration("test")(testNames:_*)

performance of targetClass.getSimpleName config (Context(reports.resultDir -> "./tmp")) in {
for (test <- testNames)
measure.method(test) in {
using(tests(test)) curve test in {
r =>
val dummy = new RunNotifier()
r.run(dummy)
}
}
}

def getMethodsAnnotatedWith(clazz: Class[_], annotation: Class[_ <: java.lang.annotation.Annotation]): List[Method] = {
val methods = ListBuffer[Method]()
var klass: Class[_] = clazz
while (klass ne classOf[AnyRef]) {
val allMethods = klass.getDeclaredMethods
import scala.collection.JavaConversions._
for (method <- allMethods) {
if (annotation == null || method.isAnnotationPresent(annotation)) {
val annotInstance: Annotation = method.getAnnotation(annotation)
methods.add(method)
}
}
klass = klass.getSuperclass
}
methods.toList
}
}

object dotcTests extends TestsToBenchmarkConverter(classOf[dotc.tests])
52 changes: 49 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import sbt.Keys._
import sbt._
import Keys._
import Process._

object DottyBuild extends Build {

val TRAVIS_BUILD = "dotty.travis.build"

val agentOptions = List(
// "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005",
// "-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"
)

Expand Down Expand Up @@ -74,4 +73,51 @@ object DottyBuild extends Build {
)

lazy val dotty = Project(id = "dotty", base = file("."), settings = defaults)

lazy val benchmarkSettings = Defaults.defaultSettings ++ Seq(

// to get Scala 2.11
resolvers += Resolver.sonatypeRepo("releases"),

baseDirectory in (Test,run) := (baseDirectory in dotty).value,


libraryDependencies ++= Seq("com.storm-enroute" %% "scalameter" % "0.6" % Test,
"com.novocode" % "junit-interface" % "0.11-RC1"),
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework"),

// scalac options
scalacOptions in Global ++= Seq("-feature", "-deprecation", "-language:_"),

javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),

fork in Test := true,
parallelExecution in Test := false,

// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
javaOptions <++= (dependencyClasspath in Runtime, packageBin in Compile) map { (attList, bin) =>
// put the Scala {library, reflect, compiler} in the classpath
val path = for {
file <- attList.map(_.data)
path = file.getAbsolutePath
prefix = if(path.endsWith(".jar")) "p" else "a"
} yield "-Xbootclasspath/"+ prefix +":" + path
// dotty itself needs to be in the bootclasspath
val fullpath = ("-Xbootclasspath/a:" + bin) :: path.toList
// System.err.println("BOOTPATH: " + fullpath)

val travis_build = // propagate if this is a travis build
if (sys.props.isDefinedAt(TRAVIS_BUILD))
List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}")
else
List()
val res = agentOptions ::: travis_build ::: fullpath
println("Running with javaOptions: " +res)
res
}
)


lazy val benchmarks = Project(id = "dotty-bench", settings = benchmarkSettings,
base = file("bench")) dependsOn(dotty % "compile->test")
}
51 changes: 40 additions & 11 deletions src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Contexts._
import Periods._
import Symbols._
import Scopes._
import typer.{FrontEnd, Typer, Mode, ImportInfo}
import typer.{FrontEnd, Typer, Mode, ImportInfo, RefChecks}
import reporting.ConsoleReporter
import dotty.tools.dotc.core.Phases.Phase
import dotty.tools.dotc.transform._
Expand All @@ -16,25 +16,54 @@ import dotty.tools.dotc.core.Denotations.SingleDenotation

class Compiler {

/** Meta-ordering constraint:
*
* DenotTransformers that change the signature of their denotation's info must go
* after erasure. The reason is that denotations are permanently referred to by
* TermRefs which contain a signature. If the signature of a symbol would change,
* all refs to it would become outdated - they could not be dereferenced in the
* new phase.
*
* As an example, addGetters would change a field
*
* val x: T
*
* to a method
*
* def x: T
*
* but this would affect the signature of `x` (goes from NotAMethod to a method
* signature). So we can't do this before erasure.
*
* After erasure, signature changing denot-transformers are OK because erasure
* will make sure that only term refs with fixed SymDenotations survive beyond it. This
* is possible because:
*
* - splitter has run, so every ident or select refers to a unique symbol
* - after erasure, asSeenFrom is the identity, so every reference has a
* plain SymDenotation, as opposed to a UniqueRefDenotation.
*/
def phases: List[List[Phase]] =
List(
List(new FrontEnd),
List(new Companions),
List(new FirstTransform,
new SyntheticMethods),
List(new SuperAccessors),
// pickling and refchecks goes here
List(new ElimRepeated, new ElimLocals),
List(new ExtensionMethods),
List(new TailRec),
// pickling goes here
List(new RefChecks,
new ElimRepeated,
new ElimLocals,
new ExtensionMethods,
new TailRec),
List(new PatternMatcher,
new LazyValTranformContext().transformer,
new ExplicitOuter,
new LazyValsTransform,
new Splitter),
List(new Nullarify,
new TypeTestsCasts,
List(new ElimByName,
new InterceptedMethods,
new Literalize),
List(new Erasure),
List(new UncurryTreeTransform
/* , new Constructors */)
List(new CapturedVars)
)

var runId = 1
Expand Down
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/ElimLocals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import DenotTransformers.SymTransformer
import Phases.Phase
import Contexts.Context
import SymDenotations.SymDenotation
import TreeTransforms.TreeTransform
import TreeTransforms.MiniPhaseTransform
import Flags.Local

/** Widens all private[this] and protected[this] qualifiers to just private/protected */
class ElimLocals extends TreeTransform with SymTransformer { thisTransformer =>
override def name = "elimlocals"
class ElimLocals extends MiniPhaseTransform with SymTransformer { thisTransformer =>
override def phaseName = "elimLocals"

def transformSym(ref: SymDenotation)(implicit ctx: Context) =
dropLocal(ref)
Expand Down
15 changes: 15 additions & 0 deletions src/dotty/tools/dotc/Flatten.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dotty.tools.dotc
package transform

import core._
import DenotTransformers.SymTransformer
import Phases.Phase
import Contexts.Context
import SymDenotations.SymDenotation
import TreeTransforms.MiniPhaseTransform

class Flatten extends MiniPhaseTransform with SymTransformer { thisTransformer =>
override def phaseName = "flatten"

def transformSym(ref: SymDenotation)(implicit ctx: Context) = ???
}
17 changes: 12 additions & 5 deletions src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class Run(comp: Compiler)(implicit ctx: Context) {
compileSources(sources)
}

/** TODO: There's a fundamental design problem here: We assmble phases using `squash`
* when we first build the compiler. But we modify them with -Yskip, -Ystop
* on each run. That modification needs to either trasnform the tree structure,
* or we need to assmeble phases on each run, and take -Yskip, -Ystop into
* account. I think the latter would be preferable.
*/
def compileSources(sources: List[SourceFile]) = Stats.monitorHeartBeat {
if (sources forall (_.exists)) {
units = sources map (new CompilationUnit(_))
Expand All @@ -36,18 +42,19 @@ class Run(comp: Compiler)(implicit ctx: Context) {
ctx.settings.YstopAfter.value.containsPhase(phase.prev)
val phasesToRun = ctx.allPhases.init
.takeWhile(!stoppedBefore(_))
.filterNot(ctx.settings.Yskip.value.containsPhase(_))
for (phase <- phasesToRun) {
.filterNot(ctx.settings.Yskip.value.containsPhase(_)) // TODO: skip only subphase
for (phase <- phasesToRun)
if (!ctx.reporter.hasErrors) {
phase.runOn(units)
def foreachUnit(op: Context => Unit)(implicit ctx: Context): Unit =
for (unit <- units) op(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
if (ctx.settings.Xprint.value.containsPhase(phase))
foreachUnit(printTree)
if (ctx.settings.Ycheck.value.containsPhase(phase) && !ctx.reporter.hasErrors)
foreachUnit(TreeChecker.check)
if (ctx.settings.Ycheck.value.containsPhase(phase) && !ctx.reporter.hasErrors) {
assert(phase.isCheckable, s"phase $phase is not checkable")
foreachUnit(TreeChecker.check(phasesToRun, _))
}
}
}
}
}

Expand Down
Loading