Anonymous avatar Anonymous committed 7634b13

Fix dictionaries so they appear as the 'dict' type, and so they
stringify correctly.

Comments (0)

Files changed (3)

   'src/classes/pynietype.pir',
   'src/classes/pynielist.pir',
   'src/classes/pyniestr.pir',
+  'src/classes/pyniedict.pir',
   ]
 
 CLEANUPS = GEN_SOURCES + [

src/builtins/lists.pir

     .local pmc iterator
     .local pmc key, value
 
-    result = new 'Hash'
+    result = new [ 'dict' ]
 
     if null args goto done
     iterator = iter args

src/classes/pyniedict.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
+
+
+# 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.