diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-10 21:35:42 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-10 21:43:45 -0800 |
commit | 76755b2836b0dadd88f82635f661f9d9df77604d (patch) | |
tree | f4f4429510c739fd1f9e51edd10e03c27107acba /html/075scenario_console.cc.html | |
parent | 080e9cb73fa55cdc862f1dd7593df56e0a6302b8 (diff) | |
download | mu-76755b2836b0dadd88f82635f661f9d9df77604d.tar.gz |
2423 - describe shape-shifting in html docs
Diffstat (limited to 'html/075scenario_console.cc.html')
-rw-r--r-- | html/075scenario_console.cc.html | 105 |
1 files changed, 57 insertions, 48 deletions
diff --git a/html/075scenario_console.cc.html b/html/075scenario_console.cc.html index c578c2a8..6ef48e09 100644 --- a/html/075scenario_console.cc.html +++ b/html/075scenario_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<span class="Delimiter">,</span> <span class="Constant">2</span>:boolean<span class="Special"> <- </span>read-key console:address - <span class="Constant">3</span>:character<span class="Delimiter">,</span> console:address<span class="Delimiter">,</span> <span class="Constant">4</span>:boolean<span class="Special"> <- </span>read-key console:address - <span class="Constant">5</span>:character<span class="Delimiter">,</span> console:address<span class="Delimiter">,</span> <span class="Constant">6</span>:boolean<span class="Special"> <- </span>read-key console:address - <span class="Constant">7</span>:character<span class="Delimiter">,</span> console:address<span class="Delimiter">,</span> <span class="Constant">8</span>:boolean<span class="Delimiter">,</span> <span class="Constant">9</span>:boolean<span class="Special"> <- </span>read-key console:address + <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"> <- </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"> <- </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"> <- </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"> <- </span>read-key console:address:console ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># 'a'</span> @@ -70,47 +70,50 @@ Name[r][<span class="Constant">"console"</span>] = CONSOLE<span class= <span class="Delimiter">:(before "End is_special_name Cases")</span> if <span class="Delimiter">(</span>s == <span class="Constant">"console"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span class="Comment">//: Unlike assume-keyboard, assume-console is easiest to implement as just a</span> -<span class="Comment">//: primitive recipe.</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> ASSUME_CONSOLE<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -Recipe_ordinal[<span class="Constant">"assume-console"</span>] = ASSUME_CONSOLE<span class="Delimiter">;</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"assume-console"</span><span class="Delimiter">,</span> ASSUME_CONSOLE<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +case ASSUME_CONSOLE: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case ASSUME_CONSOLE: <span class="Delimiter">{</span> <span class="Comment">// create a temporary recipe just for parsing; it won't contain valid instructions</span> istringstream in<span class="Delimiter">(</span><span class="Constant">"["</span> + current_instruction<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="Constant">"]"</span><span class="Delimiter">);</span> - recipe r = slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + recipe r<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</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> ensure_space<span class="Delimiter">(</span>size<span class="Delimiter">);</span> long long int event_data_address = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> - Memory[event_data_address] = num_events<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">-></span>alloc<span class="Delimiter">;</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < 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& 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">"left-click"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc] = <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> - Memory[Current_routine<span class="Delimiter">-></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>] = TB_KEY_MOUSE_LEFT<span class="Delimiter">;</span> - Memory[Current_routine<span class="Delimiter">-></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>] = 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> - Memory[Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'column' in 'mouse-event'</span><span class="Comment">*/</span><span class="Constant">2</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">1</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></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">-></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">-></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> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'column' in 'mouse-event'</span><span class="Comment">*/</span><span class="Constant">2</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">1</span><span class="Delimiter">).</span>name<span class="Delimiter">));</span> Current_routine<span class="Delimiter">-></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">"press"</span><span class="Delimiter">)</span> <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> - Memory[Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>] = to_integer<span class="Delimiter">(</span>key<span class="Delimiter">);</span> - else if <span class="Delimiter">(</span>Key<span class="Delimiter">.</span>find<span class="Delimiter">(</span>key<span class="Delimiter">)</span> != Key<span class="Delimiter">.</span>end<span class="Delimiter">())</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>] = Key[key]<span class="Delimiter">;</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span><span class="Delimiter">,</span> to_integer<span class="Delimiter">(</span>key<span class="Delimiter">));</span> + else if <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Key<span class="Delimiter">,</span> key<span class="Delimiter">))</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span><span class="Delimiter">,</span> Key[key]<span class="Delimiter">);</span> else - raise << <span class="Constant">"assume-console: can't press "</span> << key << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> - if <span class="Delimiter">(</span>Memory[Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>] < <span class="Constant">256</span><span class="Delimiter">)</span> + raise_error << <span class="Constant">"assume-console: can't press "</span> << key << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span><span class="Delimiter">)</span> < <span class="Constant">256</span><span class="Delimiter">)</span> <span class="Comment">// these keys are in ascii</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc] = <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> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></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> else <span class="Delimiter">{</span> <span class="Comment">// distinguish from unicode</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc] = <span class="Comment">/*</span><span class="Comment">tag for 'keycode' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">tag for 'keycode' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> Current_routine<span class="Delimiter">-></span>alloc += size_of_event<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -123,22 +126,23 @@ case ASSUME_CONSOLE: <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 < num_keyboard_events<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc] = <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> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></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 < SIZE<span class="Delimiter">(</span>contents<span class="Delimiter">));</span> tb_utf8_char_to_unicode<span class="Delimiter">(</span>&curr_character<span class="Delimiter">,</span> &raw_contents[curr]<span class="Delimiter">);</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc+<span class="Comment">/*</span><span class="Comment">skip exclusive container tag</span><span class="Comment">*/</span><span class="Constant">1</span>] = curr_character<span class="Delimiter">;</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></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">-></span>alloc += size_of_event<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> assert<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>alloc == event_data_address+size<span class="Delimiter">);</span> - <span class="Comment">// wrap the array of events in an event object</span> - ensure_space<span class="Delimiter">(</span>size_of_events<span class="Delimiter">());</span> - Memory[CONSOLE] = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> - Current_routine<span class="Delimiter">-></span>alloc += size_of_events<span class="Delimiter">();</span> - Memory[Memory[CONSOLE]+<span class="Comment">/*</span><span class="Comment">offset of 'data' in container 'events'</span><span class="Comment">*/</span><span class="Constant">1</span>] = event_data_address<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">-></span>alloc<span class="Delimiter">);</span> + Current_routine<span class="Delimiter">-></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> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -212,15 +216,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"> <- </span>read-event console:address - <span class="Constant">5</span>:event<span class="Special"> <- </span>read-event console:address - <span class="Constant">9</span>:event<span class="Special"> <- </span>read-event console:address + <span class="Constant">1</span>:event<span class="Special"> <- </span>read-event console:address:console + <span class="Constant">5</span>:event<span class="Special"> <- </span>read-event console:address:console + <span class="Constant">9</span>:event<span class="Special"> <- </span>read-event console:address:console <span class="Comment"># mouse click</span> - <span class="Constant">13</span>:event<span class="Special"> <- </span>read-event console:address + <span class="Constant">13</span>:event<span class="Special"> <- </span>read-event console:address:console <span class="Comment"># non-character keycode</span> - <span class="Constant">17</span>:event<span class="Special"> <- </span>read-event console:address + <span class="Constant">17</span>:event<span class="Special"> <- </span>read-event console:address:console <span class="Comment"># final keyboard event</span> - <span class="Constant">21</span>:event<span class="Special"> <- </span>read-event console:address + <span class="Constant">21</span>:event<span class="Special"> <- </span>read-event console:address:console ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># 'text'</span> @@ -256,21 +260,26 @@ scenario events-in-scenario [ <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> REPLACE_IN_CONSOLE<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -Recipe_ordinal[<span class="Constant">"replace-in-console"</span>] = REPLACE_IN_CONSOLE<span class="Delimiter">;</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"replace-in-console"</span><span class="Delimiter">,</span> REPLACE_IN_CONSOLE<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +case REPLACE_IN_CONSOLE: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case REPLACE_IN_CONSOLE: <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span> - if <span class="Delimiter">(</span>!Memory[CONSOLE]<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << <span class="Constant">"console not initialized</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>!get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise_error << <span class="Constant">"console not initialized</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - long long int console_data = Memory[Memory[CONSOLE]+<span class="Constant">1</span>]<span class="Delimiter">;</span> - long long int size = Memory[console_data]<span class="Delimiter">;</span> <span class="Comment">// array size</span> + long long int console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span> + long long int console_data = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Constant">1</span><span class="Delimiter">);</span> + long long int size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_data<span class="Delimiter">);</span> <span class="Comment">// array size</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">,</span> curr = console_data+<span class="Constant">1</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">,</span> curr+=size_of_event<span class="Delimiter">())</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>Memory[curr] != <span class="Comment">/*</span><span class="Comment">text</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>Memory[curr+<span class="Constant">1</span>] != ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">)</span> != <span class="Comment">/*</span><span class="Comment">text</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr+<span class="Constant">1</span><span class="Delimiter">)</span> != ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>long long int n = <span class="Constant">0</span><span class="Delimiter">;</span> n < size_of_event<span class="Delimiter">();</span> ++n<span class="Delimiter">)</span> - Memory[curr+n] = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span>n<span class="Delimiter">);</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr+n<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span>n<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -292,20 +301,20 @@ long long int size_of_event<span class="Delimiter">()</span> <span class="Delimi <span class="Comment">// memoize result if already computed</span> static long long int result = <span class="Constant">0</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> - vector<type_ordinal> type<span class="Delimiter">;</span> - type<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Type_ordinal[<span class="Constant">"event"</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">"event"</span><span class="Delimiter">));</span> result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">);</span> + delete type<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -long long int size_of_events<span class="Delimiter">()</span> <span class="Delimiter">{</span> +long long int size_of_console<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Comment">// memoize result if already computed</span> static long long int result = <span class="Constant">0</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> - vector<type_ordinal> type<span class="Delimiter">;</span> - assert<span class="Delimiter">(</span>Type_ordinal[<span class="Constant">"console"</span>]<span class="Delimiter">);</span> - type<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Type_ordinal[<span class="Constant">"console"</span>]<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"console"</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">"console"</span><span class="Delimiter">));</span> result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">);</span> + delete type<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> </pre> |