Class: Rubinius::AST::Class

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, superclass, body) ⇒ Class

Returns a new instance of Class.



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/compiler/ast/definitions.rb', line 441

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.



439
440
441
# File 'lib/compiler/ast/definitions.rb', line 439

def body
  @body
end

#nameObject

Returns the value of attribute name.



439
440
441
# File 'lib/compiler/ast/definitions.rb', line 439

def name
  @name
end

#superclassObject

Returns the value of attribute superclass.



439
440
441
# File 'lib/compiler/ast/definitions.rb', line 439

def superclass
  @superclass
end

Instance Method Details

#to_sexpObject



462
463
464
465
# File 'lib/compiler/ast/definitions.rb', line 462

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