Class: Opal::Nodes::BackRefNode
- Inherits:
-
GlobalVariableNode
- Object
- Base
- GlobalVariableNode
- Opal::Nodes::BackRefNode
- Defined in:
- opal/lib/opal/nodes/variables.rb
Overview
back_ref can be: $` $' $& $+ (currently unsupported)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #compile ⇒ Object
- #handle_global_match ⇒ Object
- #handle_post_match ⇒ Object
- #handle_pre_match ⇒ Object
Methods inherited from GlobalVariableNode
Methods inherited from Base
#add_gvar, #add_ivar, #add_local, #add_temp, #children, children, #class_variable_owner, #class_variable_owner_nesting_level, #comments, #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 ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'opal/lib/opal/nodes/variables.rb', line 121 def compile helper :gvars case var_name when '&' handle_global_match when "'" handle_post_match when '`' handle_pre_match when '+' super else raise NotImplementedError end end |
#handle_global_match ⇒ Object
138 139 140 141 142 |
# File 'opal/lib/opal/nodes/variables.rb', line 138 def handle_global_match with_temp do |tmp| push "((#{tmp} = $gvars['~']) === nil ? nil : #{tmp}['$[]'](0))" end end |
#handle_post_match ⇒ Object
150 151 152 153 154 |
# File 'opal/lib/opal/nodes/variables.rb', line 150 def handle_post_match with_temp do |tmp| push "((#{tmp} = $gvars['~']) === nil ? nil : #{tmp}.$post_match())" end end |
#handle_pre_match ⇒ Object
144 145 146 147 148 |
# File 'opal/lib/opal/nodes/variables.rb', line 144 def handle_pre_match with_temp do |tmp| push "((#{tmp} = $gvars['~']) === nil ? nil : #{tmp}.$pre_match())" end end |