Class: SyntaxTree::YARV::VM::Stack
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::VM::Stack
- Defined in:
- lib/syntax_tree/yarv/vm.rb
Overview
This represents the global VM stack. It effectively is an array, but wraps mutating functions with instrumentation.
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #[] ⇒ Object
- #[]= ⇒ Object
- #concat ⇒ Object
-
#initialize(events) ⇒ Stack
constructor
A new instance of Stack.
- #last ⇒ Object
- #length ⇒ Object
- #pop ⇒ Object
- #push ⇒ Object
- #slice! ⇒ Object
Constructor Details
#initialize(events) ⇒ Stack
Returns a new instance of Stack.
167 168 169 170 |
# File 'lib/syntax_tree/yarv/vm.rb', line 167 def initialize(events) @events = events @values = [] end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
165 166 167 |
# File 'lib/syntax_tree/yarv/vm.rb', line 165 def events @events end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
165 166 167 |
# File 'lib/syntax_tree/yarv/vm.rb', line 165 def values @values end |
Instance Method Details
#[] ⇒ Object
196 197 198 |
# File 'lib/syntax_tree/yarv/vm.rb', line 196 def [](...) values.[](...) end |
#[]= ⇒ Object
200 201 202 |
# File 'lib/syntax_tree/yarv/vm.rb', line 200 def []=(...) values.[]=(...).tap { events.publish_stack_change(self) } end |
#concat ⇒ Object
172 173 174 |
# File 'lib/syntax_tree/yarv/vm.rb', line 172 def concat(...) values.concat(...).tap { events.publish_stack_change(self) } end |
#last ⇒ Object
176 177 178 |
# File 'lib/syntax_tree/yarv/vm.rb', line 176 def last values.last end |
#length ⇒ Object
180 181 182 |
# File 'lib/syntax_tree/yarv/vm.rb', line 180 def length values.length end |
#pop ⇒ Object
188 189 190 |
# File 'lib/syntax_tree/yarv/vm.rb', line 188 def pop(...) values.pop(...).tap { events.publish_stack_change(self) } end |
#push ⇒ Object
184 185 186 |
# File 'lib/syntax_tree/yarv/vm.rb', line 184 def push(...) values.push(...).tap { events.publish_stack_change(self) } end |
#slice! ⇒ Object
192 193 194 |
# File 'lib/syntax_tree/yarv/vm.rb', line 192 def slice!(...) values.slice!(...).tap { events.publish_stack_change(self) } end |