-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
122 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
package esmeta.constructor | ||
// package esmeta.constructor | ||
|
||
import esmeta.cfg.* | ||
import esmeta.error.ESMetaError | ||
import esmeta.state.* | ||
import esmeta.web.Debugger | ||
// import esmeta.cfg.* | ||
// import esmeta.error.ESMetaError | ||
// import esmeta.state.* | ||
// import esmeta.web.Debugger | ||
|
||
import scala.collection.mutable.Map as MMap | ||
// import scala.collection.mutable.Map as MMap | ||
|
||
class Constructor( | ||
st: State, | ||
targetNodeId: Int, | ||
targetFeature: Int, | ||
targetCallPath: String, | ||
nodeToProgId: MMap[Int, MMap[Int, MMap[String, (Int, Int)]]], | ||
) extends Debugger(st) { | ||
private var flag = true | ||
private inline def cfg = st.cfg | ||
// class Constructor( | ||
// st: State, | ||
// targetNodeId: Int, | ||
// targetFeature: Int, | ||
// targetCallPath: String, | ||
// nodeToProgId: MMap[Int, MMap[Int, MMap[String, (Int, Int)]]], | ||
// ) extends Debugger(st) { | ||
// private var flag = true | ||
// private inline def cfg = st.cfg | ||
|
||
override def eval(node: Node): Unit = | ||
if ( | ||
flag && node.id == targetNodeId && generateCallpathString( | ||
st.context.callPath.toString, | ||
) == targetCallPath | ||
) { | ||
flag = false | ||
val (script, cnt) = | ||
nodeToProgId | ||
.getOrElse( | ||
targetNodeId, | ||
throw new ESMetaError( | ||
s"[Constructor] no corresponding nodeId $targetNodeId for nodeToProgId", | ||
), | ||
) | ||
.getOrElse( | ||
targetFeature, | ||
throw new ESMetaError( | ||
s"[Constructor] no corresponding feature $targetFeature", | ||
), | ||
) | ||
.getOrElse( | ||
targetCallPath, | ||
throw new ESMetaError( | ||
s"[Constructor] no corresponding callpath $targetCallPath", | ||
), | ||
) | ||
// override def eval(node: Node): Unit = | ||
// if ( | ||
// flag && node.id == targetNodeId && generateCallpathString( | ||
// st.context.callPath.toString, | ||
// ) == targetCallPath | ||
// ) { | ||
// flag = false | ||
// val (script, cnt) = | ||
// nodeToProgId | ||
// .getOrElse( | ||
// targetNodeId, | ||
// throw new ESMetaError( | ||
// s"[Constructor] no corresponding nodeId $targetNodeId for nodeToProgId", | ||
// ), | ||
// ) | ||
// .getOrElse( | ||
// targetFeature, | ||
// throw new ESMetaError( | ||
// s"[Constructor] no corresponding feature $targetFeature", | ||
// ), | ||
// ) | ||
// .getOrElse( | ||
// targetCallPath, | ||
// throw new ESMetaError( | ||
// s"[Constructor] no corresponding callpath $targetCallPath", | ||
// ), | ||
// ) | ||
|
||
nodeToProgId(targetNodeId)(targetFeature) -= targetCallPath | ||
nodeToProgId(targetNodeId)( | ||
targetFeature, | ||
) += targetCallPath -> (script, getIter - 1) | ||
} | ||
super.eval(node) | ||
// nodeToProgId(targetNodeId)(targetFeature) -= targetCallPath | ||
// nodeToProgId(targetNodeId)( | ||
// targetFeature, | ||
// ) += targetCallPath -> (script, getIter - 1) | ||
// } | ||
// super.eval(node) | ||
|
||
private def generateCallpathString(rawPath: String): String = | ||
val nodeIdList = "\\d+".r | ||
.findAllIn(rawPath) | ||
.toList | ||
.map { nodeIdStr => | ||
nodeIdStr.toIntOption.getOrElse( | ||
throw new IllegalArgumentException( | ||
s"Invalid integer value: $nodeIdStr", | ||
), | ||
) | ||
} | ||
// private def generateCallpathString(rawPath: String): String = | ||
// val nodeIdList = "\\d+".r | ||
// .findAllIn(rawPath) | ||
// .toList | ||
// .map { nodeIdStr => | ||
// nodeIdStr.toIntOption.getOrElse( | ||
// throw new IllegalArgumentException( | ||
// s"Invalid integer value: $nodeIdStr", | ||
// ), | ||
// ) | ||
// } | ||
|
||
// val funcIdList: List[Int] = nodeIdList.flatMap { nodeId => | ||
// cfg.nodeMap.get(nodeId).flatMap { node => | ||
// cfg.funcOf.get(node).map(_.id) | ||
// } | ||
// } | ||
// // val funcIdList: List[Int] = nodeIdList.flatMap { nodeId => | ||
// // cfg.nodeMap.get(nodeId).flatMap { node => | ||
// // cfg.funcOf.get(node).map(_.id) | ||
// // } | ||
// // } | ||
|
||
val path = | ||
if nodeIdList.isEmpty then "" else nodeIdList.mkString("<") | ||
path | ||
// val path = | ||
// if nodeIdList.isEmpty then "" else nodeIdList.mkString("<") | ||
// path | ||
|
||
} | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters