Class: CodeTools::AST::SClassScope

Inherits:
ClosedScope show all
Defined in:
lib/rubinius/code/ast/definitions.rb

Instance Attribute Summary

Attributes inherited from ClosedScope

#body

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from ClosedScope

#assign_local_reference, #attach_and_call, #module?, #nest_scope, #new_local, #new_nested_local, #search_local, #to_sexp

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, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, body) ⇒ SClassScope

Returns a new instance of SClassScope.



1095
1096
1097
1098
1099
# File 'lib/rubinius/code/ast/definitions.rb', line 1095

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

Instance Method Details

#bytecode(g) ⇒ Object



1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
# File 'lib/rubinius/code/ast/definitions.rb', line 1101

def bytecode(g)
  pos(g)

  g.push_type
  g.swap
  g.send :object_singleton_class, 1

  if @body
    # if @body just returns self, don't bother with it.
    if @body.kind_of? Block
      ary = @body.array
      return if ary.size == 1 and ary[0].kind_of? Self
    end

    # Ok, emit it.
    attach_and_call g, :__metaclass_init__, true, true
  else
    g.pop
    g.push_nil
  end
end