From eaeb955212eb3b133fd98d98457f17bfea8891d1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 6 Aug 2015 19:15:57 -0700 Subject: 1949 --- html/031address.cc.html | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'html/031address.cc.html') diff --git a/html/031address.cc.html b/html/031address.cc.html index 06c08de7..47f238c8 100644 --- a/html/031address.cc.html +++ b/html/031address.cc.html @@ -13,16 +13,17 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceAbsent { color: #c00000; } .traceContains { color: #008000; } +.traceAbsent { color: #c00000; } .Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.SalientComment { color: #00ffff; } +.CommentedCode { color: #6c6c6c; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } .Identifier { color: #804000; } -.CommentedCode { color: #6c6c6c; } +.SalientComment { color: #00ffff; } --> @@ -60,7 +61,7 @@ recipe main [ :(before "long long int base = x.value" following "void write_memory(reagent x, vector<double> data)") x = canonize(x); -if (x.value == 0) { +if (x.value == 0) { raise << "can't write to location 0 in '" << current_instruction().to_string() << "'\n" << end(); return; } @@ -77,25 +78,25 @@ recipe main [ :(code) reagent canonize(reagent x) { - if (is_literal(x)) return x; + if (is_literal(x)) return x; //? cout << "canonize\n"; //? 1 reagent r = x; //? cout << x.to_string() << " => " << r.to_string() << '\n'; //? 1 - while (has_property(r, "lookup")) + while (has_property(r, "lookup")) r = lookup_memory(r); return r; } reagent lookup_memory(reagent x) { //? cout << "lookup_memory: " << x.to_string() << "\n"; //? 2 - static const type_ordinal ADDRESS = Type_ordinal["address"]; + static const type_ordinal ADDRESS = Type_ordinal["address"]; reagent result; - if (x.types.at(0) != ADDRESS) { + if (x.types.at(0) != ADDRESS) { raise << current_recipe_name() << ": tried to /lookup " << x.original_string << " but it isn't an address\n" << end(); return result; } // compute value - if (x.value == 0) { + if (x.value == 0) { raise << current_recipe_name() << ": tried to /lookup 0\n" << end(); return result; } @@ -106,14 +107,14 @@ reagent lookup_memory(reagent x(++x.types.begin(), x.types.end(), inserter(result.types, result.types.begin())); // drop-one 'lookup' - long long int i = 0; - long long int len = SIZE(x.properties); - for (i = 0; i < len; ++i) { - if (x.properties.at(i).first == "lookup") break; + long long int i = 0; + long long int len = SIZE(x.properties); + for (i = 0; i < len; ++i) { + if (x.properties.at(i).first == "lookup") break; result.properties.push_back(x.properties.at(i)); } ++i; // skip first lookup - for (; i < len; ++i) { + for (; i < len; ++i) { result.properties.push_back(x.properties.at(i)); } return result; @@ -166,11 +167,11 @@ recipe main [ :(before "End Parsing reagent") { - while (!name.empty() && name.at(0) == '*') { + while (!name.empty() && name.at(0) == '*') { name.erase(0, 1); properties.push_back(pair<string, vector<string> >("lookup", vector<string>())); } - if (name.empty()) + if (name.empty()) raise << "illegal name " << original_string << '\n' << end(); } @@ -181,7 +182,7 @@ _DUMP, :(before "End Primitive Recipe Numbers") Recipe_ordinal["$dump"] = _DUMP; :(before "End Primitive Recipe Implementations") -case _DUMP: { +case _DUMP: { reagent after_canonize = canonize(current_instruction().ingredients.at(0)); cerr << current_recipe_name() << ": " << current_instruction().ingredients.at(0).name << ' ' << current_instruction().ingredients.at(0).value << " => " << after_canonize.value << " => " << Memory[after_canonize.value] << '\n'; break; @@ -190,18 +191,18 @@ case _DUMP: { //: grab an address, and then dump its value at intervals //: useful for tracking down memory corruption (writing to an out-of-bounds address) :(before "End Globals") -long long int foo = -1; +long long int foo = -1; :(before "End Primitive Recipe Declarations") _FOO, :(before "End Primitive Recipe Numbers") Recipe_ordinal["$foo"] = _FOO; :(before "End Primitive Recipe Implementations") -case _FOO: { - if (current_instruction().ingredients.empty()) { - if (foo != -1) cerr << foo << ": " << Memory[foo] << '\n'; - else cerr << '\n'; +case _FOO: { + if (current_instruction().ingredients.empty()) { + if (foo != -1) cerr << foo << ": " << Memory[foo] << '\n'; + else cerr << '\n'; } - else { + else { foo = canonize(current_instruction().ingredients.at(0)).value; } break; -- cgit 1.4.1-2-gfad0