diff options
-rw-r--r-- | 052tangle.cc | 15 | ||||
-rw-r--r-- | 072channel.mu | 28 |
2 files changed, 17 insertions, 26 deletions
diff --git a/052tangle.cc b/052tangle.cc index 9c64bd00..896a073d 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -133,14 +133,15 @@ bool is_waypoint(string label) { } //: complain about unapplied fragments -:(before "End Globals") -bool Transform_check_insert_fragments_Ran = false; -:(after "Transform.push_back(insert_fragments)") -Transform.push_back(check_insert_fragments); // idempotent +//: This can't run during transform because later (shape-shifting recipes) +//: we'll encounter situations where fragments might get used long after +//: they're loaded, and we might run transform_all in between. To avoid +//: spurious errors, run this check right at the end, after all code is +//: loaded, right before we run main. +:(before "End Commandline Parsing") +check_insert_fragments(); :(code) -void check_insert_fragments(unused recipe_ordinal) { - if (Transform_check_insert_fragments_Ran) return; - Transform_check_insert_fragments_Ran = true; +void check_insert_fragments() { for (map<string, recipe>::iterator p = Before_fragments.begin(); p != Before_fragments.end(); ++p) { if (!contains_key(Fragments_used, p->first)) raise << "could not locate insert before " << p->first << '\n' << end(); diff --git a/072channel.mu b/072channel.mu index b70539e9..6fe96e91 100644 --- a/072channel.mu +++ b/072channel.mu @@ -62,9 +62,6 @@ def write out:address:sink:_elem, val:_elem -> out:address:sink:_elem [ load-ingredients chan:address:channel:_elem <- get *out, chan:offset <channel-write-initial> - # BUG: delete next 2 lines after enabling the tangle directives below - closed?:boolean <- get *chan, closed?:offset - reply-if closed? { # block if chan is full full:boolean <- channel-full? chan @@ -99,9 +96,6 @@ def read in:address:source:_elem -> result:_elem, in:address:source:_elem [ empty?:boolean <- channel-empty? chan break-unless empty? <channel-read-empty> - # BUG: delete next 2 lines after enabling the tangle directives below - closed?:boolean <- get *chan, closed?:offset - reply-if closed?, 0 # hack, will only work for scalar _elem; we need a method to clear arbitrary types free-address:location <- get-location *chan, first-free:offset wait-for-location free-address } @@ -288,19 +282,15 @@ def close x:address:sink:_elem -> x:address:sink:_elem [ # if a channel is closed for writing, # future reads continue until the channel empties, # then the channel is also closed for reading -# BUG: tangle directives on shape-shifting recipes work, but raise spurious warnings -# why this happens: tangling is a transform, and transforms only run during -# specialization. however the check that added fragments are used runs -# immediately and potentially before any specializations are encountered. -#? after <channel-write-initial> [ -#? closed?:boolean <- get *chan, closed?:offset -#? reply-if closed? -#? ] -#? -#? after <channel-read-empty> [ -#? closed?:boolean <- get *chan, closed?:offset -#? reply-if closed? -#? ] +after <channel-write-initial> [ + closed?:boolean <- get *chan, closed?:offset + reply-if closed? +] + +after <channel-read-empty> [ + closed?:boolean <- get *chan, closed?:offset + reply-if closed?, 0/hack # only scalar _elems supported in channels; need to support construction of arbitrary empty containers +] ## helpers |