diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-14 16:04:45 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-14 16:04:45 -0700 |
commit | 65361948ca7975553757a0e0df4ac7352413044c (patch) | |
tree | 22063c089f67cb0d82623f2edc2c16b7e4389d41 /html/010vm.cc.html | |
parent | 64586540eccbc0880341782d329b419ab9d002de (diff) | |
download | mu-65361948ca7975553757a0e0df4ac7352413044c.tar.gz |
1376 - update github docs
Diffstat (limited to 'html/010vm.cc.html')
-rw-r--r-- | html/010vm.cc.html | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/html/010vm.cc.html b/html/010vm.cc.html index 08e5ec83..77ed750f 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 010vm.cc</title> +<title>~/Desktop/s/mu/010vm.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -90,14 +90,14 @@ struct property <span class="Delimiter">{</span> <span class="Delimiter">:(before "End Globals")</span> <span class="Comment">// Locations refer to a common 'memory'. Each location can store a number.</span> -map<index_t<span class="Delimiter">,</span> long long int> Memory<span class="Delimiter">;</span> +map<index_t<span class="Delimiter">,</span> double> Memory<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> Memory<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">:(after "Types")</span> <span class="Comment">// Mu types encode how the numbers stored in different parts of memory are</span> <span class="Comment">// interpreted. A location tagged as a 'character' type will interpret the</span> -<span class="Comment">// number 97 as the letter 'a', while a different location of type 'integer'</span> +<span class="Comment">// number 97 as the letter 'a', while a different location of type 'number'</span> <span class="Comment">// would not.</span> <span class="Comment">//</span> <span class="Comment">// Unlike most computers today, mu stores types in a single big table, shared</span> @@ -114,9 +114,9 @@ void setup_types<span class="Delimiter">()</span> <span class="Delimiter">{</spa Type_number[<span class="Constant">"literal"</span>] = <span class="Constant">0</span><span class="Delimiter">;</span> Next_type_number = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// Mu Types Initialization</span> - type_number integer = Type_number[<span class="Constant">"integer"</span>] = Next_type_number++<span class="Delimiter">;</span> - Type_number[<span class="Constant">"location"</span>] = Type_number[<span class="Constant">"integer"</span>]<span class="Delimiter">;</span> <span class="Comment">// wildcard type: either a pointer or a scalar</span> - Type[integer]<span class="Delimiter">.</span>name = <span class="Constant">"integer"</span><span class="Delimiter">;</span> + type_number number = Type_number[<span class="Constant">"number"</span>] = Next_type_number++<span class="Delimiter">;</span> + Type_number[<span class="Constant">"location"</span>] = Type_number[<span class="Constant">"number"</span>]<span class="Delimiter">;</span> <span class="Comment">// wildcard type: either a pointer or a scalar</span> + Type[number]<span class="Delimiter">.</span>name = <span class="Constant">"number"</span><span class="Delimiter">;</span> type_number address = Type_number[<span class="Constant">"address"</span>] = Next_type_number++<span class="Delimiter">;</span> Type[address]<span class="Delimiter">.</span>name = <span class="Constant">"address"</span><span class="Delimiter">;</span> type_number boolean = Type_number[<span class="Constant">"boolean"</span>] = Next_type_number++<span class="Delimiter">;</span> @@ -124,7 +124,7 @@ void setup_types<span class="Delimiter">()</span> <span class="Delimiter">{</spa type_number character = Type_number[<span class="Constant">"character"</span>] = Next_type_number++<span class="Delimiter">;</span> Type[character]<span class="Delimiter">.</span>name = <span class="Constant">"character"</span><span class="Delimiter">;</span> <span class="Comment">// Array types are a special modifier to any other type. For example,</span> - <span class="Comment">// array:integer or array:address:boolean.</span> + <span class="Comment">// array:number or array:address:boolean.</span> type_number array = Type_number[<span class="Constant">"array"</span>] = Next_type_number++<span class="Delimiter">;</span> Type[array]<span class="Delimiter">.</span>name = <span class="Constant">"array"</span><span class="Delimiter">;</span> <span class="Comment">// End Mu Types Initialization</span> @@ -214,13 +214,13 @@ reagent::reagent<span class="Delimiter">(</span>string s<span class="Delimiter"> properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> vector<string> ><span class="Delimiter">(</span>name<span class="Delimiter">,</span> values<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Comment">// structures for the first row of properties</span> - name = properties[<span class="Constant">0</span>]<span class="Delimiter">.</span>first<span class="Delimiter">;</span> - for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < properties[<span class="Constant">0</span>]<span class="Delimiter">.</span>second<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - types<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Type_number[properties[<span class="Constant">0</span>]<span class="Delimiter">.</span>second[i]]<span class="Delimiter">);</span> + name = properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>first<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + types<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Type_number[properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span>]<span class="Delimiter">);</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>name == <span class="Constant">"_"</span> && types<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> types<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - properties[<span class="Constant">0</span>]<span class="Delimiter">.</span>second<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"dummy"</span><span class="Delimiter">);</span> + properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"dummy"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> reagent::reagent<span class="Delimiter">()</span> :value<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> initialized<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -233,16 +233,16 @@ string reagent::to_string<span class="Delimiter">()</span> const <span class="De ostringstream out<span class="Delimiter">;</span> out << <span class="Constant">"{name: </span><span class="cSpecial">\"</span><span class="Constant">"</span> << name << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">, value: "</span> << value << <span class="Constant">", type: "</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < types<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - out << types[i]<span class="Delimiter">;</span> + out << types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> if <span class="Delimiter">(</span>i < types<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> out << <span class="Constant">"-"</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!properties<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> out << <span class="Constant">", properties: ["</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < properties<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - out << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span> << properties[i]<span class="Delimiter">.</span>first << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: "</span><span class="Delimiter">;</span> - for <span class="Delimiter">(</span>index_t j = <span class="Constant">0</span><span class="Delimiter">;</span> j < properties[i]<span class="Delimiter">.</span>second<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> - out << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span> << properties[i]<span class="Delimiter">.</span>second[j] << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>j < properties[i]<span class="Delimiter">.</span>second<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> out << <span class="Constant">":"</span><span class="Delimiter">;</span> + out << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span> << properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: "</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index_t j = <span class="Constant">0</span><span class="Delimiter">;</span> j < properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + out << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span> << properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>j < properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> out << <span class="Constant">":"</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>i < properties<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> else out << <span class="Constant">"]"</span><span class="Delimiter">;</span> @@ -257,13 +257,13 @@ string instruction::to_string<span class="Delimiter">()</span> const <span class ostringstream out<span class="Delimiter">;</span> for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < products<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> - out << products[i]<span class="Delimiter">.</span>to_string<span class="Delimiter">();</span> + out << products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>to_string<span class="Delimiter">();</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> out << name << <span class="Constant">'/'</span> << operation << <span class="Constant">' '</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < ingredients<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> - out << ingredients[i]<span class="Delimiter">.</span>to_string<span class="Delimiter">();</span> + out << ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>to_string<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -282,8 +282,7 @@ string slurp_until<span class="Delimiter">(</span>istream& in<span class="De <span class="Delimiter">}</span> void dump_memory<span class="Delimiter">()</span> <span class="Delimiter">{</span> - map<int<span class="Delimiter">,</span> int> ordered<span class="Delimiter">(</span>Memory<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> Memory<span class="Delimiter">.</span>end<span class="Delimiter">());</span> - for <span class="Delimiter">(</span>map<int<span class="Delimiter">,</span> int>::iterator p = ordered<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != ordered<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>map<index_t<span class="Delimiter">,</span> double>::iterator p = Memory<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Memory<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> cout << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> |