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

Inherits:
ClosedScope show all
Defined in:
lib/rubinius/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.



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

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

Instance Method Details

#bytecode(g) ⇒ Object



964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
# File 'lib/rubinius/ast/definitions.rb', line 964

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