Skip to content

Commit

Permalink
Made some types lazy fixing utwente-fmt#1195 partly
Browse files Browse the repository at this point in the history
  • Loading branch information
sakehl committed May 9, 2024
1 parent e438c7b commit c7992e2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/col/vct/col/ast/expr/op/BinExprImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ trait BinExprImpl[G] { this: BinExpr[G] =>
def getIntType: IntType[G] = if(isCIntOp) TCInt() else TInt()


def getNumericType: Type[G] = {
lazy val getNumericType: Type[G] = {
if (isCIntOp) TCInt[G]() else
if(isIntOp) TInt[G]() else
getFloatMax[G](left.t, right.t) getOrElse (
Expand Down
2 changes: 1 addition & 1 deletion src/col/vct/col/ast/expr/op/cmp/ComparisonImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import vct.col.typerules.Types

trait ComparisonImpl[G] { this: Comparison[G] =>
override def t: Type[G] = TBool()
def comparisonType: Type[G] = Types.leastCommonSuperType(left.t, right.t)
lazy val comparisonType: Type[G] = Types.leastCommonSuperType(left.t, right.t)
}
2 changes: 1 addition & 1 deletion src/col/vct/col/ast/expr/op/cmp/MapCmpImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ trait MapCmpImpl[G] { this: MapCmp[G] =>
def leftT: TMap[G] = left.t.asMap.get
def rightT: TMap[G] = right.t.asMap.get

def commonMapType: TMap[G] = TMap(leftT.key, Types.leastCommonSuperType(leftT.value, rightT.value))
lazy val commonMapType: TMap[G] = TMap(leftT.key, Types.leastCommonSuperType(leftT.value, rightT.value))
}
5 changes: 1 addition & 4 deletions src/col/vct/col/ast/expr/op/num/NumericBinExprImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ import vct.col.ast.{NumericBinExpr, TInt, TRational, Type}
import vct.col.typerules.CoercionUtils

trait NumericBinExprImpl[G] { this: NumericBinExpr[G] =>

override def t: Type[G] = {
getNumericType
}
lazy val t: Type[G] = getNumericType
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ trait SilverUntypedNonemptyLiteralMapImpl[G] extends SilverUntypedNonemptyLitera
def mapKeys: Seq[Expr[G]] = values.map(_._1)
def mapValues: Seq[Expr[G]] = values.map(_._2)

def keyType: Type[G] = Types.leastCommonSuperType(mapKeys.map(_.t))
def valueType: Type[G] = Types.leastCommonSuperType(mapValues.map(_.t))
lazy val keyType: Type[G] = Types.leastCommonSuperType(mapKeys.map(_.t))
lazy val valueType: Type[G] = Types.leastCommonSuperType(mapValues.map(_.t))

override def t: TMap[G] = TMap(keyType, valueType)

Expand Down
2 changes: 1 addition & 1 deletion src/col/vct/col/ast/lang/smt/SmtlibPowImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import vct.col.ast.ops.SmtlibPowOps
trait SmtlibPowImpl[G] extends SmtlibPowOps[G] { this: SmtlibPow[G] =>
override def precedence: Int = Precedence.PVL_POW

override def t: Type[G] = getNumericType
override lazy val t: Type[G] = getNumericType
override def layout(implicit ctx: Ctx): Doc = rassoc(left, "^", right)
}

0 comments on commit c7992e2

Please sign in to comment.