From 5f98a10cc78829a03c9fa5a137392e7d5e9030ac Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 6 Oct 2015 22:15:45 -0700 Subject: 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. --- 047global.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to '047global.cc') 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 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; -- cgit 1.4.1-2-gfad0