[phc-internals] [phc commit] r1723 - in trunk: libphc src/codegen test/subjects/codegen

Edsko de Vries edsko at phpcompiler.org
Fri Oct 3 13:25:46 IST 2008


On Fri, Oct 03, 2008 at 12:46:20PM +0100, Paul Biggar wrote:
> On Fri, Oct 3, 2008 at 12:19 PM,  <codesite-noreply at google.com> wrote:
> > Author: edskodevries
> > Date: Fri Oct  3 04:18:12 2008
> > New Revision: 1723
> >
> > Added:
> >   trunk/test/subjects/codegen/null_var_var_read.php
> >   trunk/test/subjects/codegen/null_var_var_write.php
> > Modified:
> >   trunk/libphc/support_routines.c
> >   trunk/src/codegen/Generate_C.cpp
> >
> > Log:
> > Reading and writing to the 'null variable variable' is now supported (see
> > two
> > example tests).
> >
> > To get this working, it was convenient to have access to a zval*
> > corresponding
> > to the empty string within the runtime. I've added init_runtime() and
> > finalize_runtime() functions which are invoked by the phc generated code
> > which
> > enable to the runtime to initialize its own memory. At the moment this is
> > used
> > only to initialize the (static) zval "empty_string", but will probably be
> > useful for more stuff in the future. We might even envision initializing PHP
> > from within the phc runtime, so that more code is moved to support_routines
> > from Generate_C.
> 
> Did you check
> 
> $x = 5;
> $$x = 10;
> echo $GLOBALS["5"];
> 
> ? I think there needs to be a cast_to_string in there somewhere. That
> would also handle the uninitialized value, and other values of NULL
> which dont have the same address.

We handle such conversions correctly. As far as NULL is concerned, I'm
not sure there *should* be other values of NULL? Atm, a NULL with a
different address will cause a segfault in ht_find.

Edsko


More information about the phc-internals mailing list