Class: Opal::Rewriters::Arguments
- Inherits:
 - 
      Object
      
        
- Object
 - Opal::Rewriters::Arguments
 
 
- Defined in:
 - opal/lib/opal/rewriters/arguments.rb
 
Instance Attribute Summary collapse
- 
  
    
      #args  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute args.
 - 
  
    
      #blockarg  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute blockarg.
 - 
  
    
      #kwargs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute kwargs.
 - 
  
    
      #kwoptargs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute kwoptargs.
 - 
  
    
      #kwrestarg  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute kwrestarg.
 - 
  
    
      #optargs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute optargs.
 - 
  
    
      #postargs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute postargs.
 - 
  
    
      #restarg  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute restarg.
 - 
  
    
      #shadowargs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute shadowargs.
 
Instance Method Summary collapse
- #can_inline_kwargs? ⇒ Boolean
 - #has_any_kwargs? ⇒ Boolean
 - #has_post_args? ⇒ Boolean
 - 
  
    
      #initialize(args)  ⇒ Arguments 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Arguments.
 
Constructor Details
#initialize(args) ⇒ Arguments
Returns a new instance of Arguments
      10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 10 def initialize(args) @args = [] @optargs = [] @restarg = nil @postargs = [] @kwargs = [] @kwoptargs = [] @kwrestarg = nil @shadowargs = [] @blockarg = nil args.each do |arg| case arg.type when :arg, :mlhs (@restarg || @optargs.any? ? @postargs : @args) << arg when :optarg @optargs << arg when :restarg @restarg = arg when :kwarg @kwargs << arg when :kwoptarg @kwoptargs << arg when :kwrestarg @kwrestarg = arg when :shadowarg @shadowargs << arg when :blockarg @blockarg = arg else raise "Unsupported arg type #{arg.type}" end end end  | 
  
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def args @args end  | 
  
#blockarg ⇒ Object (readonly)
Returns the value of attribute blockarg
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def blockarg @blockarg end  | 
  
#kwargs ⇒ Object (readonly)
Returns the value of attribute kwargs
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def kwargs @kwargs end  | 
  
#kwoptargs ⇒ Object (readonly)
Returns the value of attribute kwoptargs
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def kwoptargs @kwoptargs end  | 
  
#kwrestarg ⇒ Object (readonly)
Returns the value of attribute kwrestarg
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def kwrestarg @kwrestarg end  | 
  
#optargs ⇒ Object (readonly)
Returns the value of attribute optargs
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def optargs @optargs end  | 
  
#postargs ⇒ Object (readonly)
Returns the value of attribute postargs
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def postargs @postargs end  | 
  
#restarg ⇒ Object (readonly)
Returns the value of attribute restarg
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def restarg @restarg end  | 
  
#shadowargs ⇒ Object (readonly)
Returns the value of attribute shadowargs
      6 7 8  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 6 def shadowargs @shadowargs end  | 
  
Instance Method Details
#can_inline_kwargs? ⇒ Boolean
      53 54 55  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 53 def can_inline_kwargs? @optargs.empty? && @restarg.nil? && @postargs.empty? end  | 
  
#has_any_kwargs? ⇒ Boolean
      49 50 51  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 49 def has_any_kwargs? @kwargs.any? || @kwoptargs.any? || !@kwrestarg.nil? end  | 
  
#has_post_args? ⇒ Boolean
      45 46 47  | 
    
      # File 'opal/lib/opal/rewriters/arguments.rb', line 45 def has_post_args? !@restarg.nil? || @postargs.any? || (has_any_kwargs? && !can_inline_kwargs?) end  |