pynie / src / classes / pyniestr.pir

.sub '' :anon :init :load
    $P0 = subclass 'String', [ 'str' ]

    $P1 = get_global [ 'type' ], 'wrap_class'
    $P1('str', $P0)
    $P2 = get_class 'String'
    $P1 = getinterp
    $P1.'hll_map'($P2, $P0)

.namespace [ 'str' ]

=item str([object])

Return a string containing a nicely printable representation of an object.
For strings, this returns the string itself. The difference with
repr(object) is that str(object) does not always attempt to return
a string that is acceptable to eval(); its goal is to return a
printable string. If no argument is given, returns the empty string, ''.


.sub '__init__' :method
    .param pmc obj :optional
    .param int has_obj :opt_flag
    unless has_obj goto done
    $S0 = obj
    self = $S0

.sub '__repr__' :method
    .local string result
    result = "'"
    # XXX escaping
    $S0 = self
    result .= $S0
    result .= "'"
    .return (result)

.sub 'split' :method
    .param pmc sep          :optional :named('sep')
    .param int has_sep      :opt_flag
    .param int maxsplit     :optional :named('maxsplit')
    .param int has_maxsplit :opt_flag

    unless has_sep goto not_yet
    if has_maxsplit goto not_yet

    $S0 = sep
    $S1 = self
    $P0 = split $S0, $S1
    # convert from ResizableStringArray to Pynie list
    .tailcall 'listmaker'($P0 :flat)

    $P0 = new 'Exception'
    $P0 = 'NotImplementedError'         # XXX
    raise ($P0)

.sub 'join' :method
    .param pmc seq
    $S0 = self
    $S1 = join $S0, seq
    .return ($S1)

.namespace []