From db1f56c8449d2ea3d158753fe37bac5a750a2566 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 29 Nov 2015 14:18:52 -0800 Subject: 2611 --- html/010vm.cc.html | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'html/010vm.cc.html') diff --git a/html/010vm.cc.html b/html/010vm.cc.html index f476aa61..976edf51 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -94,6 +94,7 @@ struct reagent { reagent(string s); reagent(); ~reagent(); + void clear(); reagent(const reagent& old); reagent& operator=(const reagent& old); void set_value(double v) { value = v; initialized = true; } @@ -270,7 +271,7 @@ reagent::reagent(string s istringstream in(s); in >> std::noskipws; // properties - while (!in.eof()) { + while (has_data(in)) { istringstream row(slurp_until(in, '/')); row >> std::noskipws; string key = slurp_until(row, ':'); @@ -295,7 +296,7 @@ reagent::reagent(string s string_tree* parse_property_list(istream& in) { skip_whitespace(in); - if (in.eof()) return NULL; + if (!has_data(in)) return NULL; string_tree* result = new string_tree(slurp_until(in, ':')); result->right = parse_property_list(in); return result; @@ -353,9 +354,18 @@ reagent& reagent::operator=(const reagent& } reagent::~reagent() { - for (long long int i = 0; i < SIZE(properties); ++i) - if (properties.at(i).second) delete properties.at(i).second; + clear(); +} + +void reagent::clear() { + for (long long int i = 0; i < SIZE(properties); ++i) { + if (properties.at(i).second) { + delete properties.at(i).second; + properties.at(i).second = NULL; + } + } delete type; + type = NULL; } type_tree::~type_tree() { delete left; @@ -510,31 +520,6 @@ string_tree* property(const reagent& rreturn NULL; } -bool deeply_equal(const string_tree* a, const string_tree* b) { - if (!a) return !b; - if (!b) return !a; - return a->value == b->value - && deeply_equal(a->left, b->left) - && deeply_equal(a->right, b->right); -} - -:(before "End Globals") -set<string> Literal_type_names; -:(before "End One-time Setup") -Literal_type_names.insert("literal"); -Literal_type_names.insert("number"); -Literal_type_names.insert("character"); -:(code) -bool deeply_equal_types(const string_tree* a, const string_tree* b) { - if (!a) return !b; - if (!b) return !a; - if (Literal_type_names.find(a->value) != Literal_type_names.end()) - return Literal_type_names.find(b->value) != Literal_type_names.end(); - return a->value == b->value - && deeply_equal_types(a->left, b->left) - && deeply_equal_types(a->right, b->right); -} - void dump_memory() { for (map<long long int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) { cout << p->first << ": " << no_scientific(p->second) << '\n'; @@ -573,7 +558,7 @@ void dump(const string_tree* x} void skip_whitespace(istream& in) { - while (!in.eof() && isspace(in.peek()) && in.peek() != '\n') { + while (in && isspace(in.peek()) && in.peek() != '\n') { in.get(); } } -- cgit 1.4.1-2-gfad0