Skip to content

Commit

Permalink
Reenabled some printing support.
Browse files Browse the repository at this point in the history
  • Loading branch information
robby-phd committed Mar 4, 2025
1 parent 51def9d commit e4255f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jvm/src/test/scala/org/sireum/anvil/AnvilTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AnvilTest extends SireumRcSpec {
val dir: Os.Path = Os.path(implicitly[sourcecode.File].value).up.up.up.up.up.up.up / "result"

def textResources: scala.collection.SortedMap[scala.Vector[Predef.String], Predef.String] = {
val m = $internal.RC.text(Vector("example")) { (p, _) => !p.last.endsWith("print.sc") }
val m = $internal.RC.text(Vector("example")) { (p, _) => p.last.endsWith(".sc") }
m
}

Expand Down
14 changes: 9 additions & 5 deletions shared/src/main/scala/org/sireum/anvil/Anvil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,11 @@ import Anvil._
}
if (config.shouldPrint) {
globals = globals :+ AST.IR.Global(displayType, displayName, mainOpt.get.pos)
/*for (id <- printTypeMap.keys) {
for (id <- printTypeMap.keys) {
val info = th.nameMap.get(printerName :+ id).get.asInstanceOf[Info.Method]
val p = toBasic(irt.translateMethod(F, None(), info.owner, info.ast))
procedures = procedures :+ p
}*/
}
}
for (vs <- tsr.objectVars.entries) {
val (owner, ids) = vs
Expand Down Expand Up @@ -1060,7 +1060,7 @@ import Anvil._
r = transformPrint(fresh, r)
r = transformApplyConstructResult(fresh, r)
r = transformEmptyBlock(r)
r = transformReduceTemp(r)
//r = transformReduceTemp(r)
r = transformReduceExp(r)
r = transformTempCompress(r)
r = transformSplitTemp(fresh, r)
Expand Down Expand Up @@ -2019,10 +2019,14 @@ import Anvil._
}

@memoize def classSizeFieldOffsets(t: AST.Typed.Name): (Z, HashSMap[String, (AST.Typed, Z)]) = {
val info = th.typeMap.get(t.ids).get.asInstanceOf[TypeInfo.Adt]
val sm = TypeChecker.buildTypeSubstMap(t.ids, None(), info.ast.typeParams, t.args, message.Reporter.create).get
var r = HashSMap.empty[String, (AST.Typed, Z)] + typeFieldId ~> (typeShaType, 0)
var offset: Z = typeShaSize
if (t == AST.Typed.string) {
r = r + "size" ~> (AST.Typed.z, offset)
return (offset + typeByteSize(AST.Typed.z), r)
}
val info = th.typeMap.get(t.ids).get.asInstanceOf[TypeInfo.Adt]
val sm = TypeChecker.buildTypeSubstMap(t.ids, None(), info.ast.typeParams, t.args, message.Reporter.create).get
for (v <- info.vars.values) {
val ft = v.typedOpt.get.subst(sm)
r = r + v.ast.id.value ~> (ft, offset)
Expand Down

0 comments on commit e4255f5

Please sign in to comment.