diff --git a/src/main/scala/esmeta/analyzer/bta/AbsRet.scala b/src/main/scala/esmeta/analyzer/bta/AbsRet.scala new file mode 100644 index 0000000000..94162545ec --- /dev/null +++ b/src/main/scala/esmeta/analyzer/bta/AbsRet.scala @@ -0,0 +1,23 @@ +package esmeta.analyzer.bta + +import esmeta.util.Appender.* + +/** abstract return values */ +trait AbsRetDecl { self: BindingTimeAnalyzer => + case class AbsRet(value: AbsValue) extends AbsRetLike { + + /** has imprecise elements */ + def hasImprec: Boolean = ??? + } + object AbsRet extends DomainLike[AbsRet] { + + /** top element */ + def Top: AbsRet = ??? + + /** bottom element */ + def Bot: AbsRet = ??? + + /** appender */ + given rule: Rule[AbsRet] = ??? + } +} diff --git a/src/main/scala/esmeta/analyzer/bta/AbsState.scala b/src/main/scala/esmeta/analyzer/bta/AbsState.scala new file mode 100644 index 0000000000..05a0de4932 --- /dev/null +++ b/src/main/scala/esmeta/analyzer/bta/AbsState.scala @@ -0,0 +1,28 @@ +package esmeta.analyzer.bta + +import esmeta.ir.* +import esmeta.util.Appender.* + +/** abstract states */ +trait AbsStateDecl { self: BindingTimeAnalyzer => + case class AbsState( + map: Map[Local, BindingTime], + ) extends AbsStateLike { + + /** has imprecise elements */ + def hasImprec: Boolean = ??? + } + object AbsState extends DomainLike[AbsState] { + + /** top element */ + def Top: AbsState = ??? + + /** bottom element */ + def Bot: AbsState = ??? + + /** appender */ + given rule: Rule[AbsState] = ??? + } + + enum BindingTime { case Static, Dynamic } +} diff --git a/src/main/scala/esmeta/analyzer/bta/AbsTransfer.scala b/src/main/scala/esmeta/analyzer/bta/AbsTransfer.scala new file mode 100644 index 0000000000..a0524c5bef --- /dev/null +++ b/src/main/scala/esmeta/analyzer/bta/AbsTransfer.scala @@ -0,0 +1,65 @@ +package esmeta.analyzer.bta + +import esmeta.cfg.{util => _, *} +import esmeta.ir.{Func => _, util => _, *} +import esmeta.state.* +import esmeta.ty.* +import esmeta.util.* +import esmeta.util.BaseUtils.* +import scala.annotation.tailrec +import esmeta.es.builtin.JOB_QUEUE + +trait AbsTransferDecl { analyzer: BindingTimeAnalyzer => + + /** abstract transfer function */ + class AbsTransfer extends AbsTransferLike { + + /** loading monads */ + import monad.* + + /** transfer function for node points */ + def apply(np: NodePoint[_]): Unit = ??? + + /** transfer function for return points */ + def apply(rp: ReturnPoint): Unit = ??? + + /** transfer function for normal instructions */ + def transfer( + inst: NormalInst, + )(using np: NodePoint[_]): Updater = ??? + + /** transfer function for expressions */ + def transfer( + expr: Expr, + )(using np: NodePoint[Node]): Result[AbsValue] = ??? + + /** transfer function for unary operators */ + def transfer( + st: AbsState, + unary: EUnary, + operand: AbsValue, + )(using np: NodePoint[Node]): AbsValue = ??? + + /** transfer function for binary operators */ + def transfer( + st: AbsState, + binary: EBinary, + left: AbsValue, + right: AbsValue, + )(using np: NodePoint[Node]): AbsValue = ??? + + /** transfer for variadic operators */ + def transfer( + st: AbsState, + vop: VOp, + vs: List[AbsValue], + )(using np: NodePoint[Node]): AbsValue = ??? + + /** transfer for mathematical operators */ + def transfer( + st: AbsState, + mop: MOp, + vs: List[AbsValue], + )(using np: NodePoint[Node]): AbsValue = ??? + } +} diff --git a/src/main/scala/esmeta/analyzer/bta/AbsValue.scala b/src/main/scala/esmeta/analyzer/bta/AbsValue.scala new file mode 100644 index 0000000000..da45e99cd0 --- /dev/null +++ b/src/main/scala/esmeta/analyzer/bta/AbsValue.scala @@ -0,0 +1,26 @@ +package esmeta.analyzer.bta + +import esmeta.util.Appender.* + +/** abstract values */ +trait AbsValueDecl { self: BindingTimeAnalyzer => + case class AbsValue() extends AbsValueLike { + + /** has imprecise elements */ + def hasImprec: Boolean = ??? + + /** get string of abstract value with an abstract state */ + def getString(state: AbsState): String = ??? + } + object AbsValue extends DomainLike[AbsValue] { + + /** top element */ + def Top: AbsValue = ??? + + /** bottom element */ + def Bot: AbsValue = ??? + + /** appender */ + given rule: Rule[AbsValue] = ??? + } +} diff --git a/src/main/scala/esmeta/analyzer/bta/BindingTimeAnalyzer.scala b/src/main/scala/esmeta/analyzer/bta/BindingTimeAnalyzer.scala new file mode 100644 index 0000000000..9db8c2d267 --- /dev/null +++ b/src/main/scala/esmeta/analyzer/bta/BindingTimeAnalyzer.scala @@ -0,0 +1,46 @@ +package esmeta.analyzer.bta + +import esmeta.{ANALYZE_LOG_DIR, LINE_SEP} +import esmeta.analyzer.* +import esmeta.cfg.* +import esmeta.es.* +import esmeta.ir.{Func => _, *, given} +import esmeta.util.* +import esmeta.util.Appender.* +import esmeta.util.BaseUtils.* +import esmeta.util.SystemUtils.* + +/** specification type analyzer for ECMA-262 */ +class BindingTimeAnalyzer( + val cfg: CFG, +) extends Analyzer + with AbsValueDecl + with AbsStateDecl + with AbsRetDecl + with ViewDecl { + + /** worklist of control points */ + val worklist: Worklist[ControlPoint] = ??? + + /** abstract transfer function */ + type AbsTransfer <: AbsTransferLike + val transfer: AbsTransfer = ??? + + /** check reachability of node points */ + def reachable(np: NodePoint[Node]): Boolean = ??? + + /** check reachability of return points */ + def reachable(rp: ReturnPoint): Boolean = ??? + + /** get string for result of control points */ + def getString( + cp: ControlPoint, + color: Option[String] = None, + detail: Boolean = false, + ): String = ??? + + val log: Boolean = ??? + + /** logging the current analysis result */ + def logging: Unit = ??? +} diff --git a/src/main/scala/esmeta/analyzer/bta/View.scala b/src/main/scala/esmeta/analyzer/bta/View.scala new file mode 100644 index 0000000000..9b553f035a --- /dev/null +++ b/src/main/scala/esmeta/analyzer/bta/View.scala @@ -0,0 +1,25 @@ +package esmeta.analyzer.bta + +import esmeta.ty.* +import esmeta.ty.util.{Stringifier => TyStringifier} +import esmeta.util.Appender.* + +/** view abstraction */ +trait ViewDecl { self: BindingTimeAnalyzer => + + /** view abstraction for analysis sensitivities */ + case class View() extends ViewLike { + + /** empty check */ + def isEmpty: Boolean = ??? + } + + /** appender */ + def viewRule(detail: Boolean): Rule[View] = (app, view) => ??? + + /** empty view */ + val emptyView: View = View() + + /** get entry views of loops */ + def getEntryView(view: View): View = view +}