diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-15 21:45:26 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:12:28 +0200 |
commit | 53b165e69bb45f424184d02e76c520b67ee0c1d7 (patch) | |
tree | 2b4f6123890b520e69dc14fe297e4a89dd79eb81 /src/dotty/tools/dotc/ast | |
parent | bef012d32127e3d256d0ce31e1a2a27f7277f8d8 (diff) | |
download | dotty-53b165e69bb45f424184d02e76c520b67ee0c1d7.tar.gz dotty-53b165e69bb45f424184d02e76c520b67ee0c1d7.tar.bz2 dotty-53b165e69bb45f424184d02e76c520b67ee0c1d7.zip |
Cleanups
Better comments and refactorings that move some things around
so that less modules depend on Inliner.
Diffstat (limited to 'src/dotty/tools/dotc/ast')
-rw-r--r-- | src/dotty/tools/dotc/ast/TreeTypeMap.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 22 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeTypeMap.scala b/src/dotty/tools/dotc/ast/TreeTypeMap.scala index 80499cceb..cf529dfda 100644 --- a/src/dotty/tools/dotc/ast/TreeTypeMap.scala +++ b/src/dotty/tools/dotc/ast/TreeTypeMap.scala @@ -6,7 +6,6 @@ import core._ import Types._, Contexts._, Constants._, Names._, Flags._ import SymDenotations._, Symbols._, Annotations._, Trees._, Symbols._ import Denotations._, Decorators._ -import config.Printers.inlining import dotty.tools.dotc.transform.SymUtils._ /** A map that applies three functions and a substitution together to a tree and diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 54005808f..8ba7bc54d 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -10,6 +10,7 @@ import util.Positions._, Types._, Contexts._, Constants._, Names._, Flags._ import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Symbols._ import Denotations._, Decorators._, DenotTransformers._ import collection.mutable +import util.{Property, SourceFile, NoSource} import typer.ErrorReporting._ import scala.annotation.tailrec @@ -921,8 +922,25 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { } } - // ensure that constructors are fully applied? - // ensure that normal methods are fully applied? + /** A key to be used in a context property that tracks enclosing inlined calls */ + private val InlinedCalls = new Property.Key[List[Tree]] + /** A context derived form `ctx` that records `call` as innermost enclosing + * call for which the inlined version is currently processed. + */ + def inlineContext(call: Tree)(implicit ctx: Context): Context = + ctx.fresh.setProperty(InlinedCalls, call :: enclosingInlineds) + + /** All enclosing calls that are currently inlined, from innermost to outermost */ + def enclosingInlineds(implicit ctx: Context): List[Tree] = + ctx.property(InlinedCalls).getOrElse(Nil) + + /** The source file where the symbol of the `@inline` method referred to by `call` + * is defined + */ + def sourceFile(call: Tree)(implicit ctx: Context) = { + val file = call.symbol.sourceFile + if (file != null && file.exists) new SourceFile(file) else NoSource + } } |