1383 - warn on unknown type
This bit me in the last commit for the first time. Layer 010vm.cc is starting to look weird. It has references to stuff that gets implemented much later, like containers and exclusive containers. Its helpers are getting an increasing amount of logic. And it has no tests. I'm still inclined to think it's useful to have major data structures in one place, even if they aren't used for a bit. But those helpers should perhaps move out somehow or get some tests in the same layer.
This commit is contained in:
parent
03da1e329d
commit
b142a76202
5
010vm.cc
5
010vm.cc
|
@ -183,7 +183,10 @@ reagent::reagent(string s) :value(0), initialized(false) {
|
|||
// structures for the first row of properties
|
||||
name = properties.at(0).first;
|
||||
for (index_t i = 0; i < properties.at(0).second.size(); ++i) {
|
||||
types.push_back(Type_number[properties.at(0).second.at(i)]);
|
||||
string type = properties.at(0).second.at(i);
|
||||
if (Type_number.find(type) == Type_number.end())
|
||||
raise << "unknown type: " << type << '\n';
|
||||
types.push_back(Type_number[type]);
|
||||
}
|
||||
if (name == "_" && types.empty()) {
|
||||
types.push_back(0);
|
||||
|
|
|
@ -239,3 +239,11 @@ recipe main [
|
|||
_ <- copy 0:literal
|
||||
]
|
||||
+run: instruction main/0
|
||||
|
||||
:(scenario run_warns_on_unknown_types)
|
||||
% Hide_warnings = true;
|
||||
recipe main [
|
||||
# integer is not a type
|
||||
1:integer <- copy 0:literal
|
||||
]
|
||||
+warn: unknown type: integer
|
||||
|
|
|
@ -123,6 +123,10 @@ Next_routine_id = 1;
|
|||
id = Next_routine_id;
|
||||
Next_routine_id++;
|
||||
|
||||
//: it needs a new type: 'recipe'
|
||||
:(before "End Mu Types Initialization")
|
||||
Type_number["recipe"] = 0;
|
||||
|
||||
//: routines save the routine that spawned them
|
||||
:(before "End routine Fields")
|
||||
// todo: really should be routine_id, but that's less efficient.
|
||||
|
|
|
@ -10,6 +10,9 @@ recipe main [
|
|||
]
|
||||
-mem: storing 0 in location 1
|
||||
|
||||
:(before "End Mu Types Initialization")
|
||||
Type_number["label"] = 0;
|
||||
|
||||
:(after "int main")
|
||||
Transform.push_back(transform_labels);
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ recipe interpolate [
|
|||
{
|
||||
# while i < template.length
|
||||
tem-done?:boolean <- greater-or-equal i:number, tem-len:number
|
||||
break-if tem-done?:boolean, 2:blocks
|
||||
break-if tem-done?:boolean, +done:label
|
||||
# while template[i] != '_'
|
||||
in:character <- index template:address:array:character/deref, i:number
|
||||
underscore?:boolean <- equal in:character, 95:literal # '_'
|
||||
|
@ -437,6 +437,7 @@ recipe interpolate [
|
|||
i:number <- add i:number, 1:literal
|
||||
loop # interpolate next arg
|
||||
}
|
||||
+done
|
||||
# done with holes; copy rest of template directly into result
|
||||
{
|
||||
# while i < template.length
|
||||
|
|
Loading…
Reference in New Issue
Block a user