Skip to content

Commit

Permalink
Print Function instead
Browse files Browse the repository at this point in the history
  • Loading branch information
stonechoe committed Sep 23, 2024
1 parent 4c8b721 commit 5f73d7a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/scala/esmeta/peval/PartialEvaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import esmeta.interpreter.*
import esmeta.ir.{Func => IRFunc, *}
import esmeta.es.*
import esmeta.parser.{ESParser, ESValueParser}
import esmeta.peval.pstate.*
import esmeta.state.*
import esmeta.ty.*
import esmeta.util.BaseUtils.{error => _, *}
Expand Down Expand Up @@ -158,10 +157,25 @@ class PartialEvaluator(
newInst

/** final state */
def run(inst: Inst, pst: PState): (Inst, PState) = timeout(
def run(func: IRFunc, pst: PState): (Inst, PState) = timeout(
{
val inst = func.body
val result @ (newBody, newPst) = peval(inst, pst)
logging("final", newBody)

if (log) then
val writer = getPrintWriter(s"$PEVAL_LOG_DIR/result.ir")
writer.print(
IRFunc(
func.main,
func.kind,
s"${func.name}PEvaled",
func.params,
func.retTy,
newBody,
func.algo,
),
);
writer.flush();
result
},
timeLimit,
Expand Down Expand Up @@ -230,6 +244,8 @@ class PartialEvaluator(

/** cache to get syntax-directed operation (SDO) */
private val getSdo = cached[(Ast, String), Option[(Ast, Func)]](_.getSdo(_))

val renamer = Renamer()
}

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

0 comments on commit 5f73d7a

Please sign in to comment.