1. John Rizzo
  2. pynie


pynie / Objects / typeobject.pir

.sub '' :anon :init
    # setup type Class
    $P0 = newclass [ 'type' ]
    addattribute $P0, '_class'

    # XXX there should be a type object wrapping the type class

.namespace [ 'type' ]

.sub 'make_type_object'
    .param pmc _class

    .local pmc init_args
    init_args = new 'Hash'
    init_args['_class'] = _class

    $P1 = new [ 'type' ], init_args

    .return ($P1)

.sub 'wrap_class'
    .param string name
    .param pmc _class
    .local pmc make_type_object
    make_type_object = get_global 'make_type_object'
    $P0 = make_type_object(_class)
    set_hll_global name, $P0

.sub 'invoke' :vtable
    .param pmc args :slurpy
    .param pmc kwargs :named :slurpy

    $P0 = getattribute self, '_class'
    # XXX $P1 should be an instance of self
    $P1 = new $P0

    $I0 = can $P1, '__init__'
    unless $I0 goto done
    $P1.'__init__'(args :flat, kwargs :flat)

    .return ($P1)

.sub 'get_string' :vtable
    $P0 = getattribute self, '_class'
    $S0 = $P0.'name'()

    $S1 = "<class '"
    $S1 .= $S0
    $S1 .= "'>"

    .return ($S1)

.namespace []