about summary refs log tree commit diff stats
path: root/html/085scenario_console.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-26 23:47:23 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-26 23:47:23 -0800
commitd009e158803956c76adbf8f58a62884c3e7affb3 (patch)
treeb88198e28d15cd1fc064f5300365a190decc4c50 /html/085scenario_console.cc.html
parent2da43c9462c7b7c1bb78d2f2826b3b97b4874973 (diff)
downloadmu-d009e158803956c76adbf8f58a62884c3e7affb3.tar.gz
2605
Diffstat (limited to 'html/085scenario_console.cc.html')
-rw-r--r--html/085scenario_console.cc.html38
1 files changed, 23 insertions, 15 deletions
diff --git a/html/085scenario_console.cc.html b/html/085scenario_console.cc.html
index 061712fa..24311448 100644
--- a/html/085scenario_console.cc.html
+++ b/html/085scenario_console.cc.html
@@ -43,10 +43,10 @@ scenario keyboard-in-scenario [
     type [abc]
   ]
   run [
-    <span class="Constant">1</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">2</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:console
-    <span class="Constant">3</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">4</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:console
-    <span class="Constant">5</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">6</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:console
-    <span class="Constant">7</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">8</span>:boolean<span class="Delimiter">,</span> <span class="Constant">9</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:console
+    <span class="Constant">1</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">2</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:shared:console
+    <span class="Constant">3</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">4</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:shared:console
+    <span class="Constant">5</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">6</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:shared:console
+    <span class="Constant">7</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">8</span>:boolean<span class="Delimiter">,</span> <span class="Constant">9</span>:boolean<span class="Special"> &lt;- </span>read-key console:address:shared:console
   ]
   memory-should-contain [
     <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
@@ -86,14 +86,16 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span>
   slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">,</span> r<span class="Delimiter">);</span>
   long long int num_events = count_events<span class="Delimiter">(</span>r<span class="Delimiter">);</span>
   <span class="Comment">// initialize the events like in new-fake-console</span>
-  long long int size = num_events*size_of_event<span class="Delimiter">()</span> + <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
+  long long int size = <span class="Comment">/*</span><span class="Comment">space for refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span> + num_events*size_of_event<span class="Delimiter">();</span>
   ensure_space<span class="Delimiter">(</span>size<span class="Delimiter">);</span>
   long long int event_data_address = Current_routine<span class="Delimiter">-&gt;</span>alloc<span class="Delimiter">;</span>
-  put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> event_data_address<span class="Delimiter">,</span> num_events<span class="Delimiter">);</span>
-  ++Current_routine<span class="Delimiter">-&gt;</span>alloc<span class="Delimiter">;</span>
+  <span class="Comment">// store length</span>
+  put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> num_events<span class="Delimiter">);</span>
+  Current_routine<span class="Delimiter">-&gt;</span>alloc += <span class="Comment">/*</span><span class="Comment">skip refcount and length</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span>
   for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
     const instruction&amp; curr = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
     if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;left-click&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing 'left-click' event starting at &quot;</span> &lt;&lt; Current_routine<span class="Delimiter">-&gt;</span>alloc &lt;&lt; end<span class="Delimiter">();</span>
       put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">tag for 'touch-event' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">);</span>
       put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc+<span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'type' in 'mouse-event'</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">,</span> TB_KEY_MOUSE_LEFT<span class="Delimiter">);</span>
       put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc+<span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'row' in 'mouse-event'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> to_integer<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">));</span>
@@ -101,6 +103,7 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span>
       Current_routine<span class="Delimiter">-&gt;</span>alloc += size_of_event<span class="Delimiter">();</span>
     <span class="Delimiter">}</span>
     else if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;press&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing 'press' event starting at &quot;</span> &lt;&lt; Current_routine<span class="Delimiter">-&gt;</span>alloc &lt;&lt; end<span class="Delimiter">();</span>
       string key = curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span>
       if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>key<span class="Delimiter">))</span>
         put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc+<span class="Constant">1</span><span class="Delimiter">,</span> to_integer<span class="Delimiter">(</span>key<span class="Delimiter">));</span>
@@ -121,15 +124,18 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span>
     else <span class="Delimiter">{</span>
       <span class="Comment">// keyboard input</span>
       assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;type&quot;</span><span class="Delimiter">);</span>
+      trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing 'type' event starting at &quot;</span> &lt;&lt; Current_routine<span class="Delimiter">-&gt;</span>alloc &lt;&lt; end<span class="Delimiter">();</span>
       const string&amp; contents = curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span>
       const char* raw_contents = contents<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span>
       long long int num_keyboard_events = unicode_length<span class="Delimiter">(</span>contents<span class="Delimiter">);</span>
       long long int curr = <span class="Constant">0</span><span class="Delimiter">;</span>
       for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; num_keyboard_events<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+        trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing 'text' tag at &quot;</span> &lt;&lt; Current_routine<span class="Delimiter">-&gt;</span>alloc &lt;&lt; end<span class="Delimiter">();</span>
         put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">tag for 'text' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span>
         uint32_t curr_character<span class="Delimiter">;</span>
         assert<span class="Delimiter">(</span>curr &lt; SIZE<span class="Delimiter">(</span>contents<span class="Delimiter">));</span>
         tb_utf8_char_to_unicode<span class="Delimiter">(</span>&amp;curr_character<span class="Delimiter">,</span> &amp;raw_contents[curr]<span class="Delimiter">);</span>
+        trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing character &quot;</span> &lt;&lt; curr_character &lt;&lt; <span class="Constant">&quot; at &quot;</span> &lt;&lt; Current_routine<span class="Delimiter">-&gt;</span>alloc+<span class="Constant">1</span> &lt;&lt; end<span class="Delimiter">();</span>
         put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc+<span class="Comment">/*</span><span class="Comment">skip exclusive container tag</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> curr_character<span class="Delimiter">);</span>
         curr += tb_utf8_char_length<span class="Delimiter">(</span>raw_contents[curr]<span class="Delimiter">);</span>
         Current_routine<span class="Delimiter">-&gt;</span>alloc += size_of_event<span class="Delimiter">();</span>
@@ -140,9 +146,11 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span>
   <span class="Comment">// wrap the array of events in a console object</span>
   ensure_space<span class="Delimiter">(</span>size_of_console<span class="Delimiter">());</span>
   put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-&gt;</span>alloc<span class="Delimiter">);</span>
+  trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing console in &quot;</span> &lt;&lt; Current_routine<span class="Delimiter">-&gt;</span>alloc &lt;&lt; end<span class="Delimiter">();</span>
   Current_routine<span class="Delimiter">-&gt;</span>alloc += size_of_console<span class="Delimiter">();</span>
   long long int console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span>
-  put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Comment">/*</span><span class="Comment">offset of 'data' in container 'events'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> event_data_address<span class="Delimiter">);</span>
+  trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing console data in &quot;</span> &lt;&lt; console_address+<span class="Constant">2</span> &lt;&lt; end<span class="Delimiter">();</span>
+  put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'data' in container 'events'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> event_data_address<span class="Delimiter">);</span>
   <span class="Identifier">break</span><span class="Delimiter">;</span>
 <span class="Delimiter">}</span>
 
@@ -216,15 +224,15 @@ scenario events-in-scenario [
   ]
   run [
     <span class="Comment"># 3 keyboard events; each event occupies 4 locations</span>
-    <span class="Constant">1</span>:event<span class="Special"> &lt;- </span>read-event console:address:console
-    <span class="Constant">5</span>:event<span class="Special"> &lt;- </span>read-event console:address:console
-    <span class="Constant">9</span>:event<span class="Special"> &lt;- </span>read-event console:address:console
+    <span class="Constant">1</span>:event<span class="Special"> &lt;- </span>read-event console:address:shared:console
+    <span class="Constant">5</span>:event<span class="Special"> &lt;- </span>read-event console:address:shared:console
+    <span class="Constant">9</span>:event<span class="Special"> &lt;- </span>read-event console:address:shared:console
     <span class="Comment"># mouse click</span>
-    <span class="Constant">13</span>:event<span class="Special"> &lt;- </span>read-event console:address:console
+    <span class="Constant">13</span>:event<span class="Special"> &lt;- </span>read-event console:address:shared:console
     <span class="Comment"># non-character keycode</span>
-    <span class="Constant">17</span>:event<span class="Special"> &lt;- </span>read-event console:address:console
+    <span class="Constant">17</span>:event<span class="Special"> &lt;- </span>read-event console:address:shared:console
     <span class="Comment"># final keyboard event</span>
-    <span class="Constant">21</span>:event<span class="Special"> &lt;- </span>read-event console:address:console
+    <span class="Constant">21</span>:event<span class="Special"> &lt;- </span>read-event console:address:shared:console
   ]
   memory-should-contain [
     <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># 'text'</span>
@@ -313,7 +321,7 @@ long long int size_of_console<span class="Delimiter">()</span> <span class="Deli
   if <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span>
   assert<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;console&quot;</span><span class="Delimiter">));</span>
   type_tree* type = new type_tree<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;console&quot;</span><span class="Delimiter">));</span>
-  result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">);</span>
+  result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
   delete type<span class="Delimiter">;</span>
   <span class="Identifier">return</span> result<span class="Delimiter">;</span>
 <span class="Delimiter">}</span>