Smart Expression Compiler for Turbo/Borland Pascal 7.0
Note: this expression compiler is known to be buggy, its optimizer will
sometimes incorrectly swap operands. The code got too complex, so I've
given up on it back in 1994 (didn't have a real need for it anymore as
well). Except for this little detail <g>, you might find it to be a good
example of hacks specific to Borland Pascal for generating x86 assembly
code for an expression at runtime, with only a 25% performance penalty
compared to code generated by BP itself (not that it's any good). This
can also serve as an example of how complex things tend to need re-coding
to make their code readable once again after some design decisions have
changed. In this case, that decision was to add the ability to detect
and calculate constant subexpressions at compile time.
Solar Designer
|