2718 - stop crashing on unknown space
I'm going to stop wasting precious first-line characters on 'bugfix:'. It's going to be all bugfixes for a while I think.
This commit is contained in:
parent
947f06fb55
commit
1e38eee5db
18
042name.cc
18
042name.cc
|
@ -51,7 +51,14 @@ void transform_names(const recipe_ordinal r) {
|
|||
if (!already_transformed(inst.ingredients.at(in), names)) {
|
||||
raise << maybe(caller.name) << "use before set: " << inst.ingredients.at(in).name << '\n' << end();
|
||||
}
|
||||
inst.ingredients.at(in).set_value(lookup_name(inst.ingredients.at(in), r));
|
||||
long long int v = lookup_name(inst.ingredients.at(in), r);
|
||||
if (v >= 0) {
|
||||
inst.ingredients.at(in).set_value(v);
|
||||
}
|
||||
else {
|
||||
raise << maybe(caller.name) << "can't find a place to store " << inst.ingredients.at(in).name << '\n' << end();
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (long long int out = 0; out < SIZE(inst.products); ++out) {
|
||||
if (is_disqualified(inst.products.at(out), inst, caller.name)) continue;
|
||||
|
@ -63,7 +70,14 @@ void transform_names(const recipe_ordinal r) {
|
|||
names[inst.products.at(out).name] = curr_idx;
|
||||
curr_idx += size_of(inst.products.at(out));
|
||||
}
|
||||
inst.products.at(out).set_value(lookup_name(inst.products.at(out), r));
|
||||
long long int v = lookup_name(inst.products.at(out), r);
|
||||
if (v >= 0) {
|
||||
inst.products.at(out).set_value(v);
|
||||
}
|
||||
else {
|
||||
raise << maybe(caller.name) << "can't find a place to store " << inst.products.at(out).name << '\n' << end();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (names_used && numeric_locations_used)
|
||||
|
|
|
@ -69,6 +69,7 @@ long long int space_base(const reagent& x) {
|
|||
}
|
||||
|
||||
long long int address(long long int offset, long long int base) {
|
||||
assert(offset >= 0);
|
||||
if (base == 0) return offset; // raw
|
||||
long long int size = get_or_insert(Memory, base);
|
||||
if (offset >= size) {
|
||||
|
|
|
@ -101,6 +101,7 @@ long long int lookup_name(const reagent& x, const recipe_ordinal default_recipe)
|
|||
long long int n = to_integer(p->value);
|
||||
assert(n >= 0);
|
||||
recipe_ordinal surrounding_recipe = lookup_surrounding_recipe(default_recipe, n);
|
||||
if (surrounding_recipe == -1) return -1;
|
||||
set<recipe_ordinal> done;
|
||||
vector<recipe_ordinal> path;
|
||||
return lookup_name(x, surrounding_recipe, done, path);
|
||||
|
@ -116,7 +117,7 @@ long long int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_o
|
|||
raise << path.at(i-1) << " requires computing names of " << path.at(i) << '\n' << end();
|
||||
}
|
||||
raise << path.at(SIZE(path)-1) << " requires computing names of " << r << "..ad infinitum\n" << end();
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
done.insert(r);
|
||||
path.push_back(r);
|
||||
|
@ -129,7 +130,7 @@ recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, long long int n
|
|||
if (n == 0) return r;
|
||||
if (!contains_key(Surrounding_space, r)) {
|
||||
raise << "don't know surrounding recipe of " << get(Recipe, r).name << '\n' << end();
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
assert(contains_key(Surrounding_space, r));
|
||||
return lookup_surrounding_recipe(get(Surrounding_space, r), n-1);
|
||||
|
@ -148,3 +149,12 @@ bool already_transformed(const reagent& r, const map<string, long long int>& nam
|
|||
}
|
||||
return contains_key(names, r.name);
|
||||
}
|
||||
|
||||
:(scenario missing_surrounding_space)
|
||||
% Hide_errors = true;
|
||||
recipe f [
|
||||
local-scope
|
||||
x:number/space:1 <- copy 34
|
||||
]
|
||||
+error: don't know surrounding recipe of f
|
||||
+error: f: can't find a place to store x
|
||||
|
|
Loading…
Reference in New Issue