diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-16 21:24:21 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-16 21:24:21 -0700 |
commit | 0f125d5ff163fafbf5531ce9f54f1021f0277b10 (patch) | |
tree | d4164b01d145a319fbd6fdb8ae9b58ea1042a607 | |
parent | c3779a7849804756c22912f8cfb6178863d82fb9 (diff) | |
download | mu-0f125d5ff163fafbf5531ce9f54f1021f0277b10.tar.gz |
1387
-rw-r--r-- | 002test.cc | 6 | ||||
-rw-r--r-- | 012transform.cc | 4 | ||||
-rw-r--r-- | 037call_reply.cc | 2 | ||||
-rw-r--r-- | 041name.cc | 6 | ||||
-rw-r--r-- | 044space_surround.cc | 2 | ||||
-rw-r--r-- | 045closure_name.cc | 2 | ||||
-rw-r--r-- | 047jump_label.cc | 2 | ||||
-rw-r--r-- | 050scenario.cc | 6 |
8 files changed, 15 insertions, 15 deletions
diff --git a/002test.cc b/002test.cc index fa6c50a2..12c68df9 100644 --- a/002test.cc +++ b/002test.cc @@ -80,11 +80,11 @@ void run_test(index_t i) { if (Passed) cerr << "."; } -bool is_number(const string& s) { - return s.find_first_not_of("0123456789-.") == string::npos; +bool is_integer(const string& s) { + return s.find_first_not_of("0123456789-") == string::npos; } -long long int to_number(string n) { +long long int to_integer(string n) { char* end = NULL; long long int result = strtoll(n.c_str(), &end, /*any base*/0); assert(*end == '\0'); diff --git a/012transform.cc b/012transform.cc index 7b2b58e8..c7d9b313 100644 --- a/012transform.cc +++ b/012transform.cc @@ -47,6 +47,6 @@ void parse_int_reagents() { void populate_value(reagent& r) { if (r.initialized) return; - if (!is_number(r.name)) return; - r.set_value(to_number(r.name)); + if (!is_integer(r.name)) return; + r.set_value(to_integer(r.name)); } diff --git a/037call_reply.cc b/037call_reply.cc index e22f243b..4eaea444 100644 --- a/037call_reply.cc +++ b/037call_reply.cc @@ -33,7 +33,7 @@ case REPLY: { if (has_property(reply_inst.ingredients.at(i), "same-as-ingredient")) { vector<string> tmp = property(reply_inst.ingredients.at(i), "same-as-ingredient"); assert(tmp.size() == 1); - long long int ingredient_index = to_number(tmp.at(0)); + long long int ingredient_index = to_integer(tmp.at(0)); if (caller_instruction.products.at(i).value != caller_instruction.ingredients.at(ingredient_index).value) raise << "'same-as-ingredient' result " << caller_instruction.products.at(i).value << " must be location " << caller_instruction.ingredients.at(ingredient_index).value << '\n'; } diff --git a/041name.cc b/041name.cc index 422a79ef..4e381f31 100644 --- a/041name.cc +++ b/041name.cc @@ -70,7 +70,7 @@ bool disqualified(/*mutable*/ reagent& x) { assert(!x.types.empty()); if (is_raw(x)) return true; if (isa_literal(x)) return true; - if (is_number(x.name)) return true; + if (is_integer(x.name)) return true; if (x.name == "default-space") x.initialized = true; if (x.initialized) return true; @@ -107,14 +107,14 @@ bool is_numeric_location(const reagent& x) { if (isa_literal(x)) return false; if (is_raw(x)) return false; if (x.name == "0") return false; // used for chaining lexical scopes - return is_number(x.name); + return is_integer(x.name); } bool is_named_location(const reagent& x) { if (isa_literal(x)) return false; if (is_raw(x)) return false; if (is_special_name(x.name)) return false; - return !is_number(x.name); + return !is_integer(x.name); } bool is_raw(const reagent& r) { diff --git a/044space_surround.cc b/044space_surround.cc index b2c04213..445be78c 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -45,7 +45,7 @@ index_t space_index(const reagent& x) { for (index_t i = 0; i < x.properties.size(); ++i) { if (x.properties.at(i).first == "space") { assert(x.properties.at(i).second.size() == 1); - return to_number(x.properties.at(i).second.at(0)); + return to_integer(x.properties.at(i).second.at(0)); } } return 0; diff --git a/045closure_name.cc b/045closure_name.cc index 2c2f464c..5af737d0 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -84,7 +84,7 @@ index_t lookup_name(const reagent& x, const recipe_number default_recipe) { } vector<string> p = property(x, "space"); if (p.size() != 1) raise << "/space property should have exactly one (non-negative integer) value\n"; - int n = to_number(p.at(0)); + long long int n = to_integer(p.at(0)); assert(n >= 0); recipe_number surrounding_recipe = lookup_surrounding_recipe(default_recipe, n); set<recipe_number> done; diff --git a/047jump_label.cc b/047jump_label.cc index 3158233b..81a9d123 100644 --- a/047jump_label.cc +++ b/047jump_label.cc @@ -51,7 +51,7 @@ void replace_offset(reagent& x, /*const*/ map<string, index_t>& offset, const in //? cerr << "BBB " << x.to_string() << '\n'; //? 1 assert(!x.initialized); //? cerr << "CCC " << x.to_string() << '\n'; //? 1 - if (is_number(x.name)) return; // non-labels will be handled like other number operands + if (is_integer(x.name)) return; // non-labels will be handled like other number operands //? cerr << "DDD " << x.to_string() << '\n'; //? 1 if (offset.find(x.name) == offset.end()) raise << "can't find label " << x.name << " in routine " << Recipe[r].name << '\n'; diff --git a/050scenario.cc b/050scenario.cc index 15981b06..b43aea57 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -207,11 +207,11 @@ void check_memory(const string& s) { skip_whitespace_and_comments(in); if (in.eof()) break; string lhs = next_word(in); - if (!is_number(lhs)) { + if (!is_integer(lhs)) { check_type(lhs, in); continue; } - int address = to_number(lhs); + int address = to_integer(lhs); skip_whitespace_and_comments(in); string _assign; in >> _assign; assert(_assign == "<-"); skip_whitespace_and_comments(in); @@ -234,7 +234,7 @@ void check_memory(const string& s) { void check_type(const string& lhs, istream& in) { reagent x(lhs); if (x.properties.at(0).second.at(0) == "string") { - x.set_value(to_number(x.name)); + x.set_value(to_integer(x.name)); skip_whitespace_and_comments(in); string _assign = next_word(in); assert(_assign == "<-"); |