Skip to content

Commit

Permalink
add: small version of view
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdghks committed Oct 8, 2024
1 parent 90a18e5 commit d85eba3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .completion
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _esmeta_completions() {
test262testOpt="-test262-test:target -test262-test:features -test262-test:progress -test262-test:coverage -test262-test:timeout -test262-test:with-yet -test262-test:log -test262-test:concurrent -test262-test:verbose"
injectOpt="-inject:body -inject:defs -inject:out -inject:log"
mutateOpt="-mutate:out -mutate:mutator -mutate:untilValid"
fuzzOpt="-fuzz:log -fuzz:log-interval -fuzz:out -fuzz:debug -fuzz:timeout -fuzz:trial -fuzz:duration -fuzz:seed -fuzz:cp -fuzz:k-fs -fuzz:init -fuzz:dumpDetail"
fuzzOpt="-fuzz:log -fuzz:log-interval -fuzz:out -fuzz:debug -fuzz:timeout -fuzz:trial -fuzz:duration -fuzz:seed -fuzz:cp -fuzz:k-fs -fuzz:init -fuzz:dump-detail"
coverageinvestigateOpt="-coverage-investigate:out"
analyzeOpt="-analyze:repl"
# completion for commands
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/esmeta/es/util/Coverage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ object Coverage {
kFs: Int,
cp: Boolean,
timeLimit: Option[Int],
dumpDetail: Int = 2,
)

def fromLogSimpl(baseDir: String, cfg: CFG): Coverage =
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/esmeta/es/util/CoverageSmall.scala
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ object CoverageSmall {
kFs: Int,
cp: Boolean,
timeLimit: Option[Int],
dumpDetail: Int = 1,
)

def fromLogSimpl(baseDir: String, cfg: CFG): Coverage =
Expand Down
32 changes: 32 additions & 0 deletions src/main/scala/esmeta/es/util/JsonProtocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.circe.*, io.circe.syntax.*, io.circe.generic.semiauto.*

class JsonProtocol(cfg: CFG) extends StateJsonProtocol(cfg) {
import Coverage.*
import CoverageSmall.{ViewSmall, NodeViewSmall, CondViewSmall}

// branch or reference to EReturnIfAbrupt with boolean values
given condDecoder: Decoder[Cond] = deriveDecoder
Expand Down Expand Up @@ -68,4 +69,35 @@ class JsonProtocol(cfg: CFG) extends StateJsonProtocol(cfg) {
// coverage constructor
given coverageConstructorDecoder: Decoder[CoverageConstructor] = deriveDecoder
given coverageConstructorEncoder: Encoder[CoverageConstructor] = deriveEncoder

// syntax-sensitive views with small information
// given viewSmallDecoder: Decoder[ViewSmall] = optionDecoder
given viewSmallEncoder: Encoder[ViewSmall] =
Encoder.instance {
case None => Json.Null
case Some((enclosing, feature, path)) =>
Json.obj(
"enclosing" -> Json.fromValues(
enclosing.map(f => f.func.id.asJson),
),
"feature" -> feature.func.id.asJson,
"path" -> path.map(_.toString).asJson, // to be changed
)
}
given viewSmallDecoder: Decoder[ViewSmall] = deriveDecoder

// given nodeViewSmallDecoder: Decoder[NodeViewSmall] = deriveDecoder
given nodeViewSmallEncoder: Encoder[NodeViewSmall] =
Encoder.instance(nv =>
Json.obj(
"node" -> Json.obj(
"inst" -> nv.node.id.asJson,
"func" -> cfg.funcOf(nv.node).id.asJson,
),
"view" -> viewSmallEncoder(nv.view),
),
)

given condViewSmallDecoder: Decoder[CondViewSmall] = deriveDecoder
given condViewSmallEncoder: Encoder[CondViewSmall] = deriveEncoder
}
2 changes: 1 addition & 1 deletion src/main/scala/esmeta/phase/MinifyFuzz.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ case object MinifyFuzz extends Phase[CFG, Coverage] {
"explicitly use the given init pool",
),
(
"dumpDetail",
"dump-detail",
NumOption((c, k) =>
if (k < 0 || k > 2)
error("invalid dump detail level: please set 0 to 2")
Expand Down

0 comments on commit d85eba3

Please sign in to comment.