Re: 2 Pass Binder
- Posted by Robert Craig <rds at ATTCANADA.NET> Aug 17, 1999
- 418 views
David Cuny writes: > constant foo_ = define_c_routine( gtc, "foo", {} ) > global procedure foo() > c_proc( foo_, {} ) > end procedure > I would imagine that the first pass would get rid of the > routine foo(), but leave the constant foo_. > Since my libraries tend to use routine_id heavily, the > two-pass binder wouldn't be usable anyway, right? Hmmm... I guess the 2-pass binder will have to be more sophisticated than I thought. At the end of the first pass it will have to traverse a large data structure that shows which symbols are needed by which other symbols. It will do a kind of "transitive closure" operation to garbage-collect the unused symbols. Any symbol that is needed will be marked, then any symbol needed by *that* symbol will be marked... On the second pass any unmarked symbols will be skipped as code is being written out to the .exe. Constant strings inside routine_id("...") calls will be examined too, and it will be assumed that a symbol is needed if it might be the target of a routine_id() call. If you have routine_id(expression) where the binder can't tell which routine(s) you are referencing, it will have to mark all possible routines (earlier in the source, and visible). Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/