about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-16 13:17:36 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-16 13:17:36 -0700
commitb142a7620246d57b461e5863b9d1092a917a2fc3 (patch)
tree20f32bb5b9061073bd1a8d265a4b50731e5e009b
parent03da1e329d86cf9ce23338112aee124905825fe1 (diff)
downloadmu-b142a7620246d57b461e5863b9d1092a917a2fc3.tar.gz
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.
-rw-r--r--010vm.cc5
-rw-r--r--020run.cc8
-rw-r--r--038scheduler.cc4
-rw-r--r--047jump_label.cc3
-rw-r--r--060string.mu3
5 files changed, 21 insertions, 2 deletions
diff --git a/010vm.cc b/010vm.cc
index 9b1641bd..c5e13543 100644
--- a/010vm.cc
+++ b/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);
diff --git a/020run.cc b/020run.cc
index b93b7c98..32981fa6 100644
--- a/020run.cc
+++ b/020run.cc
@@ -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
diff --git a/038scheduler.cc b/038scheduler.cc
index 3d425d50..101d1960 100644
--- a/038scheduler.cc
+++ b/038scheduler.cc
@@ -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.
diff --git a/047jump_label.cc b/047jump_label.cc
index dd65c432..3158233b 100644
--- a/047jump_label.cc
+++ b/047jump_label.cc
@@ -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);
 
diff --git a/060string.mu b/060string.mu
index d6921c8a..55dc0840 100644
--- a/060string.mu
+++ b/060string.mu
@@ -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