Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Oron Port committed Apr 9, 2020
1 parent b6f0749 commit 3ef31f1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/scala/singleton/ops/impl/GeneralMacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ trait GeneralMacros {
}
def apply(t : Any) : CalcLit = CalcLit(Primitive.fromLiteral(t), t)
}
case class CalcNLit(primitive : Primitive, tree : Tree) extends CalcVal {
case class CalcNLit(primitive : Primitive, tree : Tree, tpe : Type) extends CalcVal {
val literal = None
val tpe = primitive.tpe
}
object CalcNLit {
def apply(primitive: Primitive, tree: Tree): CalcNLit = new CalcNLit(primitive, tree, primitive.tpe)
}

sealed trait CalcType extends Calc
Expand Down Expand Up @@ -766,8 +768,8 @@ trait GeneralMacros {
val typedTree = c.typecheck(numValueTree)
TypeCalc(typedTree.tpe) match {
case t : CalcLit => t
case t : CalcType.UB => CalcNLit(t, numValueTree)
case t : CalcType => CalcNLit(t, numValueTree)
case t : CalcType.UB => CalcNLit(t, numValueTree, typedTree.tpe)
case t : CalcNLit => CalcNLit(t, numValueTree)
case _ => extractionFailed(typedTree.tpe)
}
}
Expand All @@ -777,6 +779,7 @@ trait GeneralMacros {
TypeCalc(typedTree.tpe) match {
case t : CalcLit => t
case t : CalcType => CalcNLit(t, q"$tfTree.getValue")
case t : CalcNLit => CalcNLit(t, q"$tfTree.getValue")
case t =>
// println(t)
extractionFailed(typedTree.tpe)
Expand Down Expand Up @@ -1036,15 +1039,15 @@ trait GeneralMacros {
abort(msg, Some(cArg.tpe.typeSymbol.asType))
}
//directly using the java lib `require` resulted in compiler crash, so we use wrapped require instead
case CalcNLit(Primitive.String, msg) => cArg match {
case CalcNLit(Primitive.String, msg, _) => cArg match {
case CalcUnknown(t, _) if t.typeSymbol == symbolOf[Warn] =>
CalcNLit(Primitive.Boolean, q"""{println(${buildWarningMsg(msg)}); false}""")
case _ =>
CalcNLit(Primitive.Boolean, q"{_root_.singleton.ops.impl._require(false, $msg); false}")
}
case _ => unsupported()
}
case CalcNLit(Primitive.Boolean, cond) => b match {
case CalcNLit(Primitive.Boolean, cond, _) => b match {
//directly using the java lib `require` resulted in compiler crash, so we use wrapped require instead
case CalcVal(msg : String, msgt) => cArg match {
case CalcUnknown(t, _) if t == symbolOf[Warn] =>
Expand Down

0 comments on commit 3ef31f1

Please sign in to comment.