Skip to content

Commit 0ad9da6

Browse files
committed
Replace symbols.Symbol with Id
1 parent 87d48b5 commit 0ad9da6

File tree

1 file changed

+16
-17
lines changed
  • effekt/shared/src/main/scala/effekt/core

1 file changed

+16
-17
lines changed

effekt/shared/src/main/scala/effekt/core/Mono.scala

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,37 @@ object Mono extends Phase[CoreTransformed, CoreTransformed] {
3939
// so we can generate the required monomorphic functions
4040

4141
enum PolyType {
42-
case Base(val tpe: symbols.Symbol)
43-
case Var(val sym: symbols.Symbol)
42+
case Base(val tpe: Id)
43+
case Var(val sym: Id)
4444

45-
def toSymbol: symbols.Symbol = this match {
45+
def toSymbol: Id = this match {
4646
case Base(tpe) => tpe
4747
case Var(sym) => sym
4848
}
4949
}
5050

51-
type PolyConstraints = Map[symbols.Symbol, Set[PolyType]]
52-
type PolyConstraintEntry = (symbols.Symbol, Set[PolyType])
51+
type PolyConstraints = Map[Id, Set[PolyType]]
52+
type PolyConstraintEntry = (Id, Set[PolyType])
5353

5454
def solveConstraints(constraints: PolyConstraints): PolyConstraints =
5555
var solved: PolyConstraints = Map()
5656

57-
def solveConstraint(sym: symbols.Symbol, types: Set[PolyType]): Set[PolyType] =
57+
def solveConstraint(sym: Id, types: Set[PolyType]): Set[PolyType] =
5858
var polyTypes: Set[PolyType] = Set()
59-
types.foreach(t => {
60-
t match {
61-
case PolyType.Var(symbol) => polyTypes ++= solved.getOrElse(symbol, solveConstraint(symbol, constraints.getOrElse(symbol, Set())))
62-
case base => polyTypes += base
63-
}
64-
})
59+
types.foreach {
60+
case PolyType.Var(symbol) => polyTypes ++= solved.getOrElse(symbol, solveConstraint(symbol, constraints.getOrElse(symbol, Set())))
61+
case base => polyTypes += base
62+
}
6563
solved += (sym -> polyTypes)
6664
polyTypes
6765

6866
constraints.foreach(solveConstraint)
6967

7068
solved
7169

72-
def appendConstraint(map: PolyConstraints, sym: symbols.Symbol, tpe: ValueType): PolyConstraintEntry =
70+
def appendConstraint(map: PolyConstraints, sym: Id, tpe: ValueType): PolyConstraintEntry =
7371
val currentFlow = map.getOrElse(sym, Set())
72+
println("Append: " + tpe + ", " + sym)
7473
tpe match {
7574
// Ignore self cycling types A -> A
7675
case ValueType.Data(name, targs) if name != sym => (sym -> (currentFlow + PolyType.Base(name)))
@@ -122,15 +121,15 @@ def findConstraints(definitions: List[Toplevel]): PolyConstraints =
122121
case _ =>
123122
}
124123
case _ =>
125-
case _ =>
124+
case _ =>
126125
}
127126
typeFlow
128127

129128
def hasCycle(constraints: PolyConstraints): Boolean =
130-
var visited: Set[symbols.Symbol] = Set()
131-
var recStack: Set[symbols.Symbol] = Set()
129+
var visited: Set[Id] = Set()
130+
var recStack: Set[Id] = Set()
132131

133-
def hasCycleHelper(vertex: symbols.Symbol): Boolean =
132+
def hasCycleHelper(vertex: Id): Boolean =
134133
if (recStack.contains(vertex)) return true
135134
if (visited.contains(vertex)) return false
136135

0 commit comments

Comments
 (0)