Skip to content

Experimental Streams using quotes #4317

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 28 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
83cef51
Fix #4591: Unpickle type quotes with TreeReader.readTpt
nicolasstucki May 28, 2018
8c97458
Begin porting strymonas
biboudis Mar 23, 2018
f75c214
Restructuring
biboudis Apr 6, 2018
be16938
Enable fold
biboudis Apr 9, 2018
ff68092
Implement fold
biboudis Apr 10, 2018
99071e0
Implement map
biboudis Apr 11, 2018
58e1726
Implement flatMap
biboudis Apr 11, 2018
83f8ed2
Implement filter
biboudis Apr 11, 2018
7bfbb06
Comment out implementation of take
biboudis Apr 11, 2018
ad06ab0
Implement take
biboudis Apr 13, 2018
a2e4c49
Move to custom args for run-with-compiler
biboudis Apr 13, 2018
0328028
Implement zip (for linear streams)
biboudis Apr 17, 2018
9748f0d
Implement zip (linear/nested)
biboudis Apr 17, 2018
6dfbe9d
Implement zip (nested/linear)
biboudis Apr 17, 2018
bdfdb75
Refactor and add comments
biboudis Apr 18, 2018
d565b1b
WIP implemention of reifying nested streams for zip
biboudis Apr 19, 2018
01058cc
Add Type annotations
biboudis Apr 24, 2018
395bd6d
Progress in makeLinear
biboudis Apr 24, 2018
4027fa2
Fix types for zip
biboudis Apr 25, 2018
d38fc83
Compile OK
biboudis Apr 26, 2018
0d02cea
Rebase and adjust type signatures
biboudis Apr 27, 2018
070c8a2
Fix Types
biboudis Apr 27, 2018
e2e9484
Implement zip (nested/nested)
biboudis Apr 29, 2018
ad2f6c8
Add comments
biboudis May 1, 2018
48ad346
Bug fix and more comments
biboudis May 2, 2018
e949a8a
Fix nested zip bug
biboudis May 3, 2018
1d8b789
Add note about the port
biboudis May 3, 2018
3c46da8
Update comment to reflect curr changing
biboudis May 28, 2018
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
27 changes: 16 additions & 11 deletions compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ object PickledQuotes {
/** Unpickle the tree contained in the TastyExpr */
private def unpickleExpr(expr: TastyExpr[_])(implicit ctx: Context): Tree = {
val tastyBytes = TastyString.unpickle(expr.tasty)
unpickle(tastyBytes, expr.args)
unpickle(tastyBytes, expr.args, isType = false)
}

/** Unpickle the tree contained in the TastyType */
private def unpickleType(ttpe: TastyType[_])(implicit ctx: Context): Tree = {
val tastyBytes = TastyString.unpickle(ttpe.tasty)
unpickle(tastyBytes, ttpe.args)
unpickle(tastyBytes, ttpe.args, isType = true)
}

// TASTY picklingtests/pos/quoteTest.scala
Expand All @@ -85,28 +85,33 @@ object PickledQuotes {
treePkl.compactify()
pickler.addrOfTree = treePkl.buf.addrOfTree
pickler.addrOfSym = treePkl.addrOfSym
// if (tree.pos.exists)
// new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil)

// other pickle sections go here.
if (pickling ne noPrinter)
println(i"**** pickling quote of \n${tree.show}")

val pickled = pickler.assembleParts()

if (pickling ne noPrinter) {
println(i"**** pickled quote of \n${tree.show}")
if (pickling ne noPrinter)
new TastyPrinter(pickled).printContents()
}

pickled
}

/** Unpickle TASTY bytes into it's tree */
private def unpickle(bytes: Array[Byte], splices: Seq[Any])(implicit ctx: Context): Tree = {
private def unpickle(bytes: Array[Byte], splices: Seq[Any], isType: Boolean)(implicit ctx: Context): Tree = {
val unpickler = new TastyUnpickler(bytes, splices)
val tree = unpickler.unpickleExpr()
if (pickling ne noPrinter) {
println(i"**** unpickled quote for \n${tree.show}")
println(i"**** unpickling quote from TASTY")
new TastyPrinter(bytes).printContents()
}

val tree =
if (isType) unpickler.unpickleTypeTree()
else unpickler.unpickleExpr()

if (pickling ne noPrinter)
println(i"**** unpickle quote ${tree.show}")

tree
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class DottyUnpickler(bytes: Array[Byte]) extends ClassfileParser.Embedded with t
def unpickleExpr()(implicit ctx: Context): Tree =
treeUnpickler.unpickleExpr()

def unpickleTypeTree()(implicit ctx: Context): Tree =
treeUnpickler.unpickleTypeTree()

protected def treeSectionUnpickler(posUnpicklerOpt: Option[PositionUnpickler]): TreeSectionUnpickler = {
new TreeSectionUnpickler(posUnpicklerOpt)
}
Expand Down
7 changes: 7 additions & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class TreeUnpickler(reader: TastyReader,
rdr.readTerm()
}

def unpickleTypeTree()(implicit ctx: Context): Tree = {
this.roots = Set(ctx.owner)
val rdr = new TreeReader(reader).fork
ownerTree = new OwnerTree(NoAddr, 0, rdr.fork, reader.endAddr)
rdr.readTpt()
}

/** The unpickled trees */
def unpickle()(implicit ctx: Context): List[Tree] = {
assert(roots != null, "unpickle without previous enterTopLevel")
Expand Down
3 changes: 2 additions & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ class CompilationTests extends ParallelTesting {
implicit val testGroup: TestGroup = TestGroup("runAll")
compileFilesInDir("tests/run", defaultOptions) +
compileFilesInDir("tests/run-no-optimise", defaultOptions) +
compileFilesInDir("tests/run-with-compiler", defaultRunWithCompilerOptions)
compileFilesInDir("tests/run-with-compiler", defaultRunWithCompilerOptions) +
compileFile("tests/run-with-compiler-custom-args/staged-streams_1.scala", defaultRunWithCompilerOptions without "-Yno-deep-subtypes")
}.checkRuns()

// Generic java signatures tests ---------------------------------------------
Expand Down
19 changes: 19 additions & 0 deletions tests/run-with-compiler-custom-args/staged-streams_1.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
6

12

36

2

3

7

12

15

15

72
Loading