about summary refs log tree commit diff stats
path: root/047global.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-06 22:15:45 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-06 22:15:45 -0700
commit5f98a10cc78829a03c9fa5a137392e7d5e9030ac (patch)
treeb88536e28f6d507c4b68b337423c0b6a4e28306c /047global.cc
parent75aa3a98e2b9311d65df91523ec754d5a2770456 (diff)
downloadmu-5f98a10cc78829a03c9fa5a137392e7d5e9030ac.tar.gz
2258 - separate warnings from errors
At the lowest level I'm reluctantly starting to see the need for errors
that stop the program in its tracks. Only way to avoid memory corruption
and security issues. But beyond that core I still want to be as lenient
as possible at higher levels of abstraction.
Diffstat (limited to '047global.cc')
-rw-r--r--047global.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/047global.cc b/047global.cc
index 00e8ff15..d0a3d47e 100644
--- a/047global.cc
+++ b/047global.cc
@@ -31,10 +31,15 @@ long long int global_space;
 global_space = 0;
 :(after "void write_memory(reagent x, vector<double> data)")
   if (x.name == "global-space") {
-    if (!scalar(data))
-      raise << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end();
+    if (!scalar(data)
+        || SIZE(x.types) != 3
+        || x.types.at(0) != Type_ordinal["address"]
+        || x.types.at(1) != Type_ordinal["array"]
+        || x.types.at(2) != Type_ordinal["location"]) {
+      raise_error << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end();
+    }
     if (Current_routine->global_space)
-      raise << "routine already has a global-space; you can't over-write your globals" << end();
+      raise_error << "routine already has a global-space; you can't over-write your globals" << end();
     Current_routine->global_space = data.at(0);
     return;
   }
@@ -43,7 +48,7 @@ global_space = 0;
 :(after "long long int space_base(const reagent& x)")
   if (is_global(x)) {
     if (!Current_routine->global_space)
-      raise << "routine has no global space\n" << end();
+      raise_error << "routine has no global space\n" << end();
     return Current_routine->global_space;
   }
 
@@ -51,14 +56,14 @@ global_space = 0;
 //: don't want to make them too comfortable to use.
 
 :(scenario global_space_with_names)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   global-space:address:array:location <- new location:type, 10
   x:number <- copy 23
   1:number/space:global <- copy 24
 ]
-# don't warn that we're mixing numeric addresses and names
-$warn: 0
+# don't complain about mixing numeric addresses and names
+$error: 0
 
 :(after "bool is_numeric_location(const reagent& x)")
   if (is_global(x)) return false;