On Mon, Feb 16, 2015 at 4:47 PM, Dmitry Stogov <dmi...@zend.com> wrote:
> Hi Nikita, > > it looks like a part of old implementation is not trivial with new AST > compiler. > > previously we translated assert(condition) into assert(condition, > "assert(condition)"). > actually we just captured a part of input buffer and added missing string > argument. > > Is there a simple way to do the same now? > Not very simple, but we could store pointers/offsets to the start and end of the fcall in the ast node, similar to what is done with lex_pos for declarations: http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_ast.h#177 It would be nice if we could have precise offset information for all nodes (this is particularly valuable if the ast is exposed to userland), but that would increase memory usage during compilation, not sure if it's worthwhile. > It's possible to convert AST into string using recursive pretty-printer. > It's not a simple task itself, but it may be reused for other things. > > Joe, the rest (including zero-cost assert) is implemented at > https://github.com/php/php-src/pull/1088/files > 9 related tests are failed for now. > As this is implemented right now, it would require writing \assert() in order to be zero-cost. Maybe we should disallow redefinition of assert as a namespaced function, so we can always optimize this? Nikita