Class: Opal::Nodes::AndNode
- Defined in:
- opal/lib/opal/nodes/logic.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from BinaryOp
Methods inherited from Base
#add_gvar, #add_ivar, #add_local, #add_temp, #children, children, #class_variable_owner, #closest_module_node, #comments, #compile, #compile_to_fragments, #error, #expr, #expr?, #expr_or_nil, #fragment, handle, handlers, #has_rescue_else?, #helper, #in_ensure, #in_ensure?, #in_while?, #initialize, #process, #push, #recv, #recv?, #s, #scope, #stmt, #stmt?, truthy_optimize?, #unshift, #while_loop, #with_temp, #wrap
Methods included from Helpers
#conditional_send, #current_indent, #empty_line, #indent, #js_falsy, #js_truthy, #js_truthy_optimize, #line, #mid_to_jsid, #property, #valid_name?
Constructor Details
This class inherits a constructor from Opal::Nodes::Base
Instance Method Details
#compile_if ⇒ Object
175 176 177 178 179 180 181 182 183 184 |
# File 'opal/lib/opal/nodes/logic.rb', line 175 def compile_if helper :truthy condition = js_truthy_optimize(lhs) || expr(lhs) line "if ($truthy(", condition, ")) {" indent { line expr(rhs) } line "} else {" indent { line expr(lhs) } line "}" end |
#compile_ternary ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'opal/lib/opal/nodes/logic.rb', line 158 def compile_ternary truthy_opt = nil with_temp do |tmp| if truthy_opt = js_truthy_optimize(lhs) push "((#{tmp} = ", truthy_opt push ") ? " push expr(rhs) push " : ", expr(lhs), ")" else helper :truthy push "($truthy(#{tmp} = ", expr(lhs), ") ? ", expr(rhs), " : #{tmp})" end end end |