Class: Rubinius::ToolSet.current::TS::AST::Class

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/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, superclass, body) ⇒ Class

Returns a new instance of Class.



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'lib/rubinius/ast/definitions.rb', line 688

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

  @superclass = superclass ? superclass : NilLiteral.new(line)

  case name
  when Symbol
    @name = ClassName.new line, name, @superclass
  when ToplevelConstant
    @name = ToplevelClassName.new line, name, @superclass
  else
    @name = ScopedClassName.new line, name, @superclass
  end

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



686
687
688
# File 'lib/rubinius/ast/definitions.rb', line 686

def body
  @body
end

#nameObject

Returns the value of attribute name.



686
687
688
# File 'lib/rubinius/ast/definitions.rb', line 686

def name
  @name
end

#superclassObject

Returns the value of attribute superclass.



686
687
688
# File 'lib/rubinius/ast/definitions.rb', line 686

def superclass
  @superclass
end

Instance Method Details

#bytecode(g) ⇒ Object



709
710
711
712
# File 'lib/rubinius/ast/definitions.rb', line 709

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

#to_sexpObject



714
715
716
717
# File 'lib/rubinius/ast/definitions.rb', line 714

def to_sexp
  superclass = @superclass.kind_of?(NilLiteral) ? nil : @superclass.to_sexp
  [:class, @name.to_sexp, superclass, @body.to_sexp]
end