Class: Rubinius::AST::Module

Inherits:
Node
  • Object
show all
Defined in:
lib/compiler/ast/definitions.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, node_name, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk

Constructor Details

#initialize(line, name, body) ⇒ Module

Returns a new instance of Module.



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/compiler/ast/definitions.rb', line 524

def initialize(line, name, body)
  @line = line

  case name
  when Symbol
    @name = ModuleName.new line, name
  when ToplevelConstant
    @name = ToplevelModuleName.new line, name
  else
    @name = ScopedModuleName.new line, name
  end

  if body
    @body = ModuleScope.new line, @name, body
  else
    @body = EmptyBody.new line
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



522
523
524
# File 'lib/compiler/ast/definitions.rb', line 522

def body
  @body
end

#nameObject

Returns the value of attribute name.



522
523
524
# File 'lib/compiler/ast/definitions.rb', line 522

def name
  @name
end

Instance Method Details

#to_sexpObject



543
544
545
# File 'lib/compiler/ast/definitions.rb', line 543

def to_sexp
  [:module, @name.to_sexp, @body.to_sexp]
end