Module: Minjs::ECMA262::UnaryOperation
- Included in:
- ExpBitwiseNot, ExpDelete, ExpLogicalNot, ExpNegative, ExpPositive, ExpPostDec, ExpPostInc, ExpPreDec, ExpPreInc, ExpTypeof, ExpVoid
- Defined in:
- lib/minjs/ecma262/expression.rb
Overview
Module of typically unary operation expression.
Typically unary operation expression has one values(val) and operation symbol.
Instance Attribute Summary collapse
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#add_paren ⇒ Object
add parenthesis if need.
-
#deep_dup ⇒ Object
duplicate object.
-
#remove_paren ⇒ Object
remove parenthesis if possible.
-
#replace(from, to) ⇒ Object
Replaces children object.
-
#side_effect? ⇒ Boolean
Returns this element has side effect or not.
-
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
-
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
Instance Attribute Details
#val ⇒ Object (readonly)
Returns the value of attribute val.
132 133 134 |
# File 'lib/minjs/ecma262/expression.rb', line 132 def val @val end |
Instance Method Details
#==(obj) ⇒ Object
compare object
152 153 154 |
# File 'lib/minjs/ecma262/expression.rb', line 152 def ==(obj) self.class == obj.class and self.val == obj.val end |
#add_paren ⇒ Object
add parenthesis if need
143 144 145 146 147 148 149 |
# File 'lib/minjs/ecma262/expression.rb', line 143 def add_paren if @val.priority > self.priority @val = ExpParen.new(@val) end self end |
#deep_dup ⇒ Object
duplicate object
158 159 160 |
# File 'lib/minjs/ecma262/expression.rb', line 158 def deep_dup self.class.new(@val.deep_dup) end |
#remove_paren ⇒ Object
remove parenthesis if possible
135 136 137 138 139 140 |
# File 'lib/minjs/ecma262/expression.rb', line 135 def remove_paren if @val.kind_of? ExpParen and @val.val.priority <= self.priority @val = @val.val end self end |
#replace(from, to) ⇒ Object
Replaces children object.
164 165 166 167 168 |
# File 'lib/minjs/ecma262/expression.rb', line 164 def replace(from, to) if @val .eql? from @val = to end end |
#side_effect? ⇒ Boolean
Returns this element has side effect or not.
185 186 187 |
# File 'lib/minjs/ecma262/expression.rb', line 185 def side_effect? @val.side_effect? end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
179 180 181 |
# File 'lib/minjs/ecma262/expression.rb', line 179 def to_js( = {}) concat , sym, @val end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
172 173 174 175 |
# File 'lib/minjs/ecma262/expression.rb', line 172 def traverse(parent, &block) @val.traverse(self, &block) yield parent, self end |