Re: Opcode compilation

From: Date: Fri, 16 Jul 2004 22:27:42 +0000
Subject: Re: Opcode compilation
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-968@lists.php.net to get a copy of this message
Hello, On 07/16/2004 06:39 PM, Bgardner333 wrote:
I am writing (yet another!) Opcode compiler for PHP. I understand the basics of writing extensions, but I was wondering if there is any thorough documentation of zend's compilation methods etc...
The best documentation that I ever read on writing extensions is actually a book dedicated to that specific goal: Building Custom PHP Extensions. Here is a full review: http://www.phpclasses.org/reviews/id/1411601882.html
The other question I have would be more of a general programming question : what is the best way to serialize the zend_op_array structure into a format that I can write to a file?
Now you are asking for the main secret of encoders! ;-) Binary serialization is an old programming topic. You may want to start here: http://www.google.com/search?q=binary+serialization+ansi+c You want to achieve portability of the serialized data structure (and you should for encoding), need to consider word length (how many bits in a int, long, etc...) and endianess (most significant byte first or last). Other than that usually the algorithm is to go recursively and serialize each member of each data structure using a separate function for each data type. Each of those functions writes to a stream is is basically your encoder output. The loader/decoder does the opposite. Keep in mind that the serialization has to be done on all data structures that result from a script compilation: global script, global functions, classes and whatever ZE2 generates besides what ZE1 generated. -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html

« previous php.pecl.dev (#968) next »