pynie / Objects / dictobject.pir

.sub '' :anon :init :load
    $P0 = subclass 'Hash', [ 'dict' ]

#    $P1 = get_global [ 'type' ], 'wrap_class'
#    $P1('dict', $P0)

#    $P2 = get_class 'Hash'
#    $P1 = getinterp
#    $P1.'hll_map'($P2, $P0)
.end

.namespace [ 'dict' ]

.sub 'get_string' :vtable
    .local pmc iterator
    .local string result

    iterator = iter self

    result = '{'
    unless iterator goto done

    # first element separately, to handle commas properly
    $S0 = shift iterator
    $P0 = self[$S0]
    $S1 = 'repr'($S0)
    result .= $S1
    result .= ': '
    $S1 = 'repr'($P0)
    result .= $S1

loop:
    unless iterator goto done
    result .= ', '

    $S0 = shift iterator
    $P0 = self[$S0]
    $S1 = 'repr'($S0)
    result .= $S1
    result .= ':'
    $S1 = 'repr'($P0)
    result .= $S1
    goto loop

done:
    result .= '}'
    .return (result)
.end

.sub 'keys' :method
    .local pmc ret, iterator

    ret = new 'list'
    
    iterator = iter self
loop:
    unless iterator goto done
    $S0 = shift iterator
    push ret, $S0
    goto loop

done:
    .return (ret)
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.