Skip to content

Commit

Permalink
feat: added heap inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
d01c2 committed Jan 20, 2025
1 parent 1f0fd16 commit fadc6b5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/scala/esmeta/interpreter/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Interpreter(
if (retTy.isDefined && !retTy.contains(retVal, st)) {
println(s"[ReturnTypeMismatch] ${st.context.func.irFunc.name}")
println(s"- Expected type: ${retTy}")
println(s"- Actual value : ${retVal}")
println(s"- Actual value : ${inspect(retVal, st)}")
}
}
st.context.retVal = Some(ret, retVal)
Expand Down Expand Up @@ -381,7 +381,7 @@ class Interpreter(
if (paramTy.isDefined && !paramTy.contains(arg, st)) {
println(s"[ParamTypeMismatch] ${func.irFunc.name}")
println(s"- Expected type: ${paramTy} (param: ${param.lhs})")
println(s"- Actual value : ${arg}")
println(s"- Actual value : ${inspect(arg, st)}")
}
}
aux(pl, al)
Expand Down Expand Up @@ -475,6 +475,11 @@ class Interpreter(
prevCallPath + call,
)
}

// heap inspector
private def inspect(v: Value, st: State): String = v match
case addr: Addr => st(addr).toString
case value => value.toString
}

/** IR interpreter with a CFG */
Expand Down

0 comments on commit fadc6b5

Please sign in to comment.