diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-06 00:19:03 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-06 00:19:03 -0700 |
commit | 672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9 (patch) | |
tree | 5fa3d82e40137b15dec2941a3446e838ce43d3e5 /html/012transform.cc.html | |
parent | 20d1c9057a559ce8db83bbc2787ca91348bcb16f (diff) | |
download | mu-672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9.tar.gz |
1279 - colorized rendering of the source files
Diffstat (limited to 'html/012transform.cc.html')
-rw-r--r-- | html/012transform.cc.html | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/html/012transform.cc.html b/html/012transform.cc.html new file mode 100644 index 00000000..87650650 --- /dev/null +++ b/html/012transform.cc.html @@ -0,0 +1,91 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>~/Desktop/s/mu/012transform.cc.html</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } +body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +* { font-size: 1em; } +.cSpecial { color: #008000; } +.Identifier { color: #008080; } +.Constant { color: #008080; } +.Comment { color: #8080ff; } +.Delimiter { color: #c000c0; } +.CommentedCode { color: #6c6c6c; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: Phase 2: Filter loaded recipes through an extensible list of 'transforms'.</span> +<span class="Comment">//:</span> +<span class="Comment">//: The hope is that this framework of transform tools will provide a</span> +<span class="Comment">//: deconstructed alternative to conventional compilers.</span> + +<span class="Delimiter">:(before "End recipe Fields")</span> +index_t transformed_until<span class="Delimiter">;</span> + recipe<span class="Delimiter">()</span> :transformed_until<span class="Delimiter">(</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{}</span> + +<span class="Delimiter">:(before "End Types")</span> +typedef void <span class="Delimiter">(</span>*transform_fn<span class="Delimiter">)(</span>recipe_number<span class="Delimiter">);</span> + +<span class="Delimiter">:(before "End Globals")</span> +vector<transform_fn> Transform<span class="Delimiter">;</span> + +<span class="Delimiter">:(code)</span> +void transform_all<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cout << "AAA transform_all\n"; //? 1</span> + for <span class="Delimiter">(</span>index_t t = <span class="Constant">0</span><span class="Delimiter">;</span> t < Transform<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>map<recipe_number<span class="Delimiter">,</span> recipe>::iterator p = Recipe<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Recipe<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + recipe& r = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>transformed_until != t-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Delimiter">(</span>*Transform[t]<span class="Delimiter">)(</span><span class="Comment">/*</span><span class="Comment">recipe_number</span><span class="Comment">*/</span>p<span class="Delimiter">-></span>first<span class="Delimiter">);</span> + r<span class="Delimiter">.</span>transformed_until = t<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + parse_int_reagents<span class="Delimiter">();</span> <span class="Comment">// do this after all other transforms have run</span> +<span class="Delimiter">}</span> + +void parse_int_reagents<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cout << "parse_int_reagents\n"; //? 1</span> + for <span class="Delimiter">(</span>map<recipe_number<span class="Delimiter">,</span> recipe>::iterator p = Recipe<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Recipe<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + recipe& r = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index_t index = <span class="Constant">0</span><span class="Delimiter">;</span> index < r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + instruction& inst = r<span class="Delimiter">.</span>steps[index]<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + populate_value<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients[i]<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + populate_value<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products[i]<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> + +void populate_value<span class="Delimiter">(</span>reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>initialized<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + char* end = <span class="Constant">NULL</span><span class="Delimiter">;</span> + int result = strtol<span class="Delimiter">(</span>r<span class="Delimiter">.</span>name<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &end<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">any base</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>*end != <span class="cSpecial">'\0'</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span class="CommentedCode">//? cout << "setting value\n"; //? 1</span> + r<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> |