Commits

gabriele renzi  committed c438a5e

support stack-characters (though no interface defined yet)

  • Participants
  • Parent commits ab04d01

Comments (0)

Files changed (1)

File 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: