[phc-general] view source

Paul Biggar paul.biggar at gmail.com
Tue Oct 26 19:26:50 IST 2010


Hi Vash,

On Tue, Oct 26, 2010 at 11:00 AM, vash cs <vashrf at gmail.com> wrote:
> making a phc plugin to do it. It would need to be a pretty
> straightforward translation, without looking too closely at the
> semantics (which I think is what you want). But this wouldn't be too
> hard to do.
>
> Please expand. I don't completely understand this approach.

Sure. What I mean is that you could write a plugin to phc that takes
the intermediate representation and spits out C code which is roughly
equivalent. So it could turn classes into structs for example, and use
the optimization framework for types. I'm not sure 100% how it would
work, but something simple wouldn't be more than a few days work I
expect.


> Also, what roles does rose compiler play in all of this?

You might be on to something here, I hadn't thought of it. It should
be possible to use Rose to convert PHP automatically to C++. You'd
need to write code to move the PHP AST nodes to C++ AST nodes, but its
probably possible. However, as I recall Rose doesn't support the full
set of phc AST nodes, so i'm not positive this will work.


Hope this hepls,
Paul


> On 10/26/10 3:25 AM, Paul Biggar wrote:
>
> On Mon, Oct 25, 2010 at 5:40 PM, Andrei Alvares <logytech at gmail.com> wrote:
>
>  It is indeed possible to convert the PHP program to C source with phc.
>  You can try it yourself, as long as you compile phc with PHP embed
> SAPI (http://www.phpcompiler.org/doc/latest/install.html):
>  $ phc --generate-c file.php > file.c
>
> If you do this, you can use the GNU indent program to make it readable.
>
> But Andrei is right, this isn't the right solution. What could work is
> making a phc plugin to do it. It would need to be a pretty
> straightforward translation, without looking too closely at the
> semantics (which I think is what you want). But this wouldn't be too
> hard to do.
>
> Paul
>
>
>



-- 
Paul Biggar
paul.biggar at gmail.com


More information about the phc-general mailing list