@@ -8,7 +8,8 @@ import scala.collection.mutable.Map as MutMap
8
8
import scala .collection .mutable .Set as MutSet
9
9
import scala .collection .mutable .ArrayBuffer as ArrayBuffer
10
10
import mlscript .codegen .CodeGenError
11
- import mlscript .compiler .mono .MonomorphError
11
+
12
+ class CompilerError (error : String ) extends Error (error)
12
13
13
14
class ClassLifter (logDebugMsg : Boolean = false ) {
14
15
type ClassName = String
@@ -249,7 +250,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
249
250
val nE = liftTerm(expr)
250
251
val nR = liftTerm(rhs)
251
252
(IfThen (nE._1, nR._1), nE._2 ++ nR._2)
252
- case _ => throw MonomorphError (s " Unknown IfBody: ${body}" )
253
+ case _ => throw CompilerError (s " Unknown IfBody: ${body}" )
253
254
}
254
255
255
256
private def liftTuple (tup : Tup )(using ctx : LocalContext , cache : ClassCache , globFuncs : Map [Var , (Var , LocalContext )], outer : Option [ClassInfoCache ]): (Tup , LocalContext ) = {
@@ -399,7 +400,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
399
400
case Sel (receiver, fieldName) =>
400
401
val nRec = liftTerm(receiver)
401
402
(Sel (nRec._1, fieldName), nRec._2)
402
- case Splc (fields) => throw MonomorphError (s " Unimplemented liftTerm: ${target}" )
403
+ case Splc (fields) => throw CompilerError (s " Unimplemented liftTerm: ${target}" )
403
404
case Subs (arr, idx) =>
404
405
val (ltrm, lctx) = liftTerm(arr)
405
406
val (rtrm, rctx) = liftTerm(idx)
@@ -412,7 +413,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
412
413
val ret = liftTerm(lhs)
413
414
val nTs = targs.map(liftType).unzip
414
415
(TyApp (ret._1, nTs._1), nTs._2.fold(ret._2)(_ ++ _))
415
- case With (trm, fields) => throw MonomorphError (s " Unimplemented liftTerm: ${target}" )
416
+ case With (trm, fields) => throw CompilerError (s " Unimplemented liftTerm: ${target}" )
416
417
case New (Some ((t : TypeName , prm : Tup )), TypingUnit (Nil )) =>
417
418
val ret = liftConstr(t, prm)
418
419
(New (Some ((ret._1, ret._2)), TypingUnit (Nil )), ret._3)
@@ -432,7 +433,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
432
433
val nSta = New (Some ((nTpNm, Tup (Nil ))), TypingUnit (Nil ))
433
434
val ret = liftEntities(List (anoCls, nSta))
434
435
(Blk (ret._1), ret._2)
435
- case New (head, body) => throw MonomorphError (s " Unimplemented liftTerm: ${target}" )
436
+ case New (head, body) => throw CompilerError (s " Unimplemented liftTerm: ${target}" )
436
437
case Blk (stmts) =>
437
438
val ret = liftEntities(stmts)
438
439
(Blk (ret._1), ret._2)
@@ -447,7 +448,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
447
448
val (bod2, ctx) = liftTerm(bod)
448
449
val (sts2, ctx2) = liftEntities(sts)
449
450
(Where (bod2, sts2), ctx2)
450
- case _ : Eqn | _ : Super | _ : Rft | _ : While | _ : Quoted | _ : Unquoted | _ : Ann => throw MonomorphError (s " Unimplemented liftTerm: ${target}" ) // TODO
451
+ case _ : Eqn | _ : Super | _ : Rft | _ : While | _ : Quoted | _ : Unquoted | _ : Ann => throw CompilerError (s " Unimplemented liftTerm: ${target}" ) // TODO
451
452
case patmat : AdtMatchWith => lastWords(s " Cannot liftTermNew ${patmat}" )
452
453
}
453
454
@@ -484,7 +485,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
484
485
((v, Fld (flags, tmp._1)), tmp._2)
485
486
}.unzip
486
487
(Rcd (ret._1), ret._2.fold(emptyCtx)(_ ++ _))
487
- case _ => throw MonomorphError (s " Unimplemented liftTermAsType: ${target}" )
488
+ case _ => throw CompilerError (s " Unimplemented liftTermAsType: ${target}" )
488
489
}
489
490
490
491
private def liftTypeName (target : TypeName )(using ctx : LocalContext , cache : ClassCache , globFuncs : Map [Var , (Var , LocalContext )], outer : Option [ClassInfoCache ]): (TypeName , LocalContext ) = {
@@ -578,7 +579,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
578
579
val (body2, ctx) = liftType(body)
579
580
PolyType (targs, body2) -> ctx
580
581
case Top | Bot | _ : Literal | _ : TypeTag | _ : TypeVar => target.asInstanceOf [Type ] -> emptyCtx
581
- case _ : Selection => throw MonomorphError (s " Unimplemented liftType: ${target}" ) // TODO
582
+ case _ : Selection => throw CompilerError (s " Unimplemented liftType: ${target}" ) // TODO
582
583
}
583
584
584
585
@@ -602,7 +603,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
602
603
}.unzip
603
604
(func.copy(rhs = Right (PolyType (nTargs._1, nBody._1)))(func.declareLoc, func.virtualLoc, func.mutLoc, func.signature, func.outer, func.genField, func.annotations),
604
605
nTargs._2.fold(nBody._2)(_ ++ _))
605
- case _ => throw MonomorphError (s " Unimplemented liftMemberFunc: ${func}" ) // TODO
606
+ case _ => throw CompilerError (s " Unimplemented liftMemberFunc: ${func}" ) // TODO
606
607
}
607
608
}
608
609
@@ -629,7 +630,7 @@ class ClassLifter(logDebugMsg: Boolean = false) {
629
630
case (tn, ctx) => (L (tn), ctx)
630
631
case R (tv) => R (tv) -> emptyCtx}).unzip
631
632
NuFunDef (rec, globFuncs.get(nm).get._1, N , nTpVs, Right (PolyType (nTargs._1, nBody._1)))(N , N , N , N , N , true , Nil )
632
- case _ => throw MonomorphError (s " Unimplemented liftGlobalFunc: ${func}" )
633
+ case _ => throw CompilerError (s " Unimplemented liftGlobalFunc: ${func}" )
633
634
})
634
635
}
635
636
0 commit comments