Class: CodeTools::AST::Module

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

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

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

Constructor Details

#initialize(line, name, body) ⇒ Module

Returns a new instance of Module.



961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
# File 'lib/rubinius/code/ast/definitions.rb', line 961

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.



959
960
961
# File 'lib/rubinius/code/ast/definitions.rb', line 959

def body
  @body
end

#nameObject

Returns the value of attribute name.



959
960
961
# File 'lib/rubinius/code/ast/definitions.rb', line 959

def name
  @name
end

Instance Method Details

#bytecode(g) ⇒ Object



980
981
982
983
# File 'lib/rubinius/code/ast/definitions.rb', line 980

def bytecode(g)
  @name.bytecode(g)
  @body.bytecode(g)
end

#to_sexpObject



985
986
987
# File 'lib/rubinius/code/ast/definitions.rb', line 985

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