case class State(locals: IndexedSeq[Expression], stack: List[Expression] = List(), cond: Expression = Literal.TrueLiteral, expr: Option[Expression] = None) extends Product with Serializable
State is used as the main representation of block state, as we walk the bytecode.
Given a set of instructions, we will use State variables to track what happens to the stack.
The final State generated is later used to simplify expressions.
Example 1: { return 0 }
This is in java byte code: iconst 0 ireturn
iconst 0 => pushes 0 to stack ireturn => pops and returns
Example 2: { return 2 + 2 + 1 }
1) State(locals, empty stack, no condition, expr?) // expr ==it is no expression
iconst 2 NOTE: 2 is literal here so is 1 2) State(locals, 2::Nil, no condition, expr is still empty)
iconst 2 3) State(locals, 2::2::Nil, no condiiton...)
iadd (pop 2 and 2 + push 4 into stack) 4) State(locals, Add(2, 2)::Nil, no condition, expr is still empoty)
iconst 1 5) State(locals, 1::Add(2,2)::Nil, ..)
iadd (pop 1 and 4 + push 5 into sack) 6) Add(1, Add(2,2)) :: Nil
ireturn (pop 5 from stack) 7) return Add...
State == Add stack == lhs/rhs
- Alphabetic
- By Inheritance
- State
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
- val cond: Expression
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val expr: Option[Expression]
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val locals: IndexedSeq[Expression]
- def merge(that: Option[State]): State
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def remap(oldExp: Expression, newExp: Expression): State
- val stack: List[Expression]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- State → AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )