Class: Minjs::ECMA262::StWith
- Defined in:
- lib/minjs/ecma262/statement.rb
Overview
Base class of ECMA262 WithStatement element.
Instance Attribute Summary collapse
-
#exp ⇒ Object
readonly
Returns the value of attribute exp.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
-
#var_env ⇒ Object
readonly
Returns the value of attribute var_env.
Attributes inherited from Base
Instance Method Summary collapse
-
#==(obj) ⇒ Object
compare object.
-
#add_paren ⇒ Object
add parenthesis if need.
-
#deep_dup ⇒ Object
duplicate object.
-
#initialize(var_env, exp, statement) ⇒ StWith
constructor
A new instance of StWith.
-
#remove_paren ⇒ Object
remove parenthesis if possible.
-
#replace(from, to) ⇒ Object
Replaces children object.
-
#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.
Methods inherited from Statement
#empty?, #priority, #to_exp?, #to_return?
Methods inherited from Base
Constructor Details
#initialize(var_env, exp, statement) ⇒ StWith
Returns a new instance of StWith.
1158 1159 1160 1161 1162 |
# File 'lib/minjs/ecma262/statement.rb', line 1158 def initialize(var_env, exp, statement) @var_env = var_env @exp = exp @statement = statement end |
Instance Attribute Details
#exp ⇒ Object (readonly)
Returns the value of attribute exp.
1156 1157 1158 |
# File 'lib/minjs/ecma262/statement.rb', line 1156 def exp @exp end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
1156 1157 1158 |
# File 'lib/minjs/ecma262/statement.rb', line 1156 def statement @statement end |
#var_env ⇒ Object (readonly)
Returns the value of attribute var_env.
1156 1157 1158 |
# File 'lib/minjs/ecma262/statement.rb', line 1156 def var_env @var_env end |
Instance Method Details
#==(obj) ⇒ Object
compare object
1188 1189 1190 1191 1192 |
# File 'lib/minjs/ecma262/statement.rb', line 1188 def ==(obj) self.class == obj.class and @exp == obj.exp and @statement == obj.statement end |
#add_paren ⇒ Object
add parenthesis if need
1209 1210 1211 |
# File 'lib/minjs/ecma262/statement.rb', line 1209 def add_paren self end |
#deep_dup ⇒ Object
duplicate object
1166 1167 1168 |
# File 'lib/minjs/ecma262/statement.rb', line 1166 def deep_dup self.class.new(@var_env, @exp.deep_dup, @statement.deep_dup) end |
#remove_paren ⇒ Object
remove parenthesis if possible
1201 1202 1203 1204 1205 1206 |
# File 'lib/minjs/ecma262/statement.rb', line 1201 def remove_paren if @exp.kind_of? ExpParen @exp = @exp.val end self end |
#replace(from, to) ⇒ Object
Replaces children object.
1172 1173 1174 1175 1176 1177 1178 |
# File 'lib/minjs/ecma262/statement.rb', line 1172 def replace(from, to) if @exp .eql? from @exp = to elsif @statement = to @statement = to end end |
#to_js(options = {}) ⇒ Object
Returns a ECMAScript string containg the representation of element.
1196 1197 1198 |
# File 'lib/minjs/ecma262/statement.rb', line 1196 def to_js( = {}) concat , :with, "(", @exp, ")", @statement end |
#traverse(parent) {|parent, _self| ... } ⇒ Object
Traverses this children and itself with given block.
1181 1182 1183 1184 1185 |
# File 'lib/minjs/ecma262/statement.rb', line 1181 def traverse(parent, &block) @exp.traverse(self, &block) @statement.traverse(self, &block) yield parent, self end |