Class: Opal::Nodes::IterArityCheckNode
- Inherits:
-
ArityCheckNode
- Object
- Base
- ArityCheckNode
- Opal::Nodes::IterArityCheckNode
- Defined in:
- opal/lib/opal/nodes/args/arity_check.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from ArityCheckNode
#all_args, #arity, #arity_checks, #has_only_optional_kwargs?, #has_required_kwargs?, #initialize, #kwargs, #negative_arity, #positive_arity
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::ArityCheckNode
Instance Method Details
#compile ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'opal/lib/opal/nodes/args/arity_check.rb', line 121 def compile scope.arity = arity return unless compiler.arity_check? unless arity_checks.empty? parent_scope = scope until parent_scope.def? || parent_scope.class_scope? || parent_scope.top? parent_scope = parent_scope.parent end context = if parent_scope.top? "'<main>'" elsif parent_scope.def? "'#{parent_scope.mid}'" elsif parent_scope.class? "'<class:#{parent_scope.name}>'" elsif parent_scope.module? "'<module:#{parent_scope.name}>'" end identity = scope.identity line "if (#{identity}.$$is_lambda || #{identity}.$$define_meth) {" line ' var $arity = arguments.length;' line " if (#{arity_checks.join(' || ')}) { Opal.block_ac($arity, #{arity}, #{context}); }" line '}' end end |