-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
modules/core/src/main/scala/make/internal/DebugStateMacro.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package make.internal | ||
|
||
import scala.reflect.macros.whitebox | ||
import scala.collection.mutable | ||
|
||
abstract class DebugStateMacro(val c: whitebox.Context) { | ||
import c.universe._ | ||
|
||
val debugState = MacroState.getOrElseUpdate[DebugSt](c.universe, new DebugSt) | ||
|
||
sealed trait ResolveSt | ||
object ResolveSt { | ||
case object InProgress extends ResolveSt | ||
case class Resolved(tree: Tree) extends ResolveSt | ||
} | ||
|
||
class DebugSt( | ||
var debug: Boolean = false, | ||
val stack: mutable.ListBuffer[Type] = mutable.ListBuffer.empty, | ||
val resolveCache: mutable.HashMap[Type, ResolveSt] = mutable.HashMap.empty, | ||
val reverseTraces: mutable.HashMap[Type, List[Type]] = | ||
mutable.HashMap.empty | ||
) { | ||
|
||
def registerFailedReason(targetTpe: Type, prev: Type): Unit = { | ||
val curr = reverseTraces.getOrElse(prev, List.empty) | ||
val next = targetTpe :: curr | ||
reverseTraces.update(prev, next) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.