Will update RFC today, thanks for working on it Dmitry :) Cheers Joe
On Tue, Feb 17, 2015 at 9:50 PM, Dmitry Stogov <dmi...@zend.com> wrote: > Hi Joe > > The patch is ready https://github.com/php/php-src/pull/1088/files > > 1) I implemented AST pretty-printer to reconstruct the source. It may be > reused in Reflection and other places through > > ZEND_API zend_string *zend_ast_export(const char *prefix, zend_ast *ast, > const char *suffix); > > 2) zend.assertions=-1 - makes zero-cost asserts > > 3) assert() in a namespace leads to call a function defined in this > namespace (if it's defined), but zend.assertions is still may disable this > call or even prevent code generation for it. it's possible to use \assert() > to call the system function. > > Please, make update RFC, add notes about (2) and (3). > Then, it should be ready for voting. > > Nikita, please take a quick look over the patch. I hope, you don't have > objections. > > Thanks. Dmitry. > > > > > On Tue, Feb 17, 2015 at 6:51 PM, Dmitry Stogov <dmi...@zend.com> wrote: > >> >> >> On Tue, Feb 17, 2015 at 5:11 PM, Nikita Popov <nikita....@gmail.com> >> wrote: >> >>> 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. >>>> >>> >> I went by this way... :) >> It must be ready soo. >> >> >>> >>>> 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? >>> >> >> good catch. >> >> Thanks. >> >> >>> >>> Nikita >>> >> >> >