Anonymous avatar Anonymous committed c438a5e

support stack-characters (though no interface defined yet)

Comments (0)

Files changed (1)

src/builtins/say.pir

     .param string char
     $P0 = new 'Hash'
     $P0['name']  = char
-    $P0['value'] = 0
+    $P1 = new 'ResizableIntegerArray'
+    push $P1, 0
+    $P0['value'] = $P1
     $P0['onstage'] = 0
     set_global char, $P0
 
 
 .sub 'assign'
     .param int val
-    $P0 = 'find_other'() 
-    $P0['value'] = val
+    .local pmc char
+    char = 'find_other'() 
+    'valset'(char,val)
 .end
 
 .sub 'find_other_name'
 .sub 'valueof'
     .param string char
     get_global $P0, char
-    $P1 = $P0['value']
-    .return ($P1)
+    $P2 = 'valget'($P0)
+    .return ($P2)
+
 .end
 
 .sub 'enter'
 
 .sub 'open_heart'
     $P0 = 'find_other'()
-    $I1 = $P0['value']
+    $I1 = 'valget'($P0)
     print $I1
 .end
 
+.sub 'valget'
+    .param pmc char
+    $P1 = char['value']
+    $I0 = $P1
+    $I0 -= 1
+    $I2 = $P1[$I0]
+    .return ($I2)
+.end
+
+.sub 'valset'
+    .param pmc char
+    .param int val
+    $P1 = char['value']
+    $I0 = $P1
+    $I0 -= 1
+    $P1[$I0] = val
+.end
+
+
 .sub 'listen_heart'
     $P0 = 'find_other'()
     $P1 = getstdin
     readline $S1, $P1
     $I1 = $S1
-    $P0['value']=$I1
+    'valset'($P0, $I1)
 .end
 
 .sub 'speak_mind'
     $P0 = 'find_other'()
-    $I1 = $P0['value']
+    $I1 = 'valget'($P0)
     $S1 = chr $I1
     print $S1
 .end
     $P1 = getstdin
     readline $S1, $P1
     $I1 = ord $S1
-    $P0['value']=$I1
+    'valset'($P0,$I1)
 .end
 
 # Local Variables:
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.