cvs: pear /PECL/bcompiler bcompiler.c php_bcompiler.h
| From: | Alan Knowles | Date: | Tue, 23 Jul 2002 08:31:05 +0000 |
| Subject: | cvs: pear /PECL/bcompiler bcompiler.c php_bcompiler.h | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5292@lists.php.net to get a copy of this message | ||
alan_k Tue Jul 23 04:31:05 2002 EDT
Modified files:
/pear/PECL/bcompiler php_bcompiler.h bcompiler.c
Log:
major tidy up - removed unneed functions - class inheritance should work better
Index: pear/PECL/bcompiler/php_bcompiler.h diff -u pear/PECL/bcompiler/php_bcompiler.h:1.1 pear/PECL/bcompiler/php_bcompiler.h:1.2 --- pear/PECL/bcompiler/php_bcompiler.h:1.1 Tue Jul 23 02:55:57 2002 +++ pear/PECL/bcompiler/php_bcompiler.h Tue Jul 23 04:31:04 2002 @@ -1,4 +1,27 @@ -/* __header_here__ */ +/* + +----------------------------------------------------------------------+ + | PHP bcompiler Based on APC Cache | + +----------------------------------------------------------------------+ + | Copyright (c) 2000-2001 Community Connect, Inc. (apc_* functions) | + | Copyright (c) 1997-2002 The PHP Group (remaining code) | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Alan Knowles <alan@akbkhome.com> (php module) | + | Daniel Cowgill <dan@mail.communityconnect.com> | + | George Schlossnagle <george@lethargy.org> | + | Mike Bretz <mike@metropolis-ag.de> | + +----------------------------------------------------------------------+ + */ + + + #include "ext/standard/file.h" #ifndef PHP_BCOMPILER_H #define PHP_BCOMPILER_H @@ -23,17 +46,18 @@ PHP_RSHUTDOWN_FUNCTION(bcompiler); PHP_MINFO_FUNCTION(bcompiler); -/* __function_declarations_here__ */ -PHP_FUNCTION(confirm_bcompiler_compiled); /* For testing, remove later. */ + + PHP_FUNCTION(bcompile_write_class); /* Write a class */ PHP_FUNCTION(bcompile_write_header); /* Write the header */ -PHP_FUNCTION(bcompile_write_exe_footer); /* Write the end zero byte */ +PHP_FUNCTION(bcompile_write_exe_footer);/* Write the end zero byte */ PHP_FUNCTION(bcompile_write_footer); /* Write the tail for a exe type file*/ -PHP_FUNCTION(bcompile_read); /* Read a file handle */ -PHP_FUNCTION(bcompile_load); /* Read a file handle */ -PHP_FUNCTION(bcompile_load_exe); /* Read a file handle */ +PHP_FUNCTION(bcompile_read); /* Read a file handle */ +PHP_FUNCTION(bcompile_load); /* load a file */ +PHP_FUNCTION(bcompile_load_exe); /* loads an exe style file */ +PHP_FUNCTION(bcompile_parse_class); /* callback opcodes for a class */ + -PHP_FUNCTION(bcompile_parse_class); /* Write a class */ /* Declare any global variables you may need between the BEGIN @@ -49,17 +73,7 @@ #include "zend.h" #include "zend_variables.h" // for zval_dtor() - - -/* In every utility function you add that needs to use variables - in php_bcompiler_globals, call TSRM_FETCH(); after declaring other - variables used by that function, or better yet, pass in TSRMG_CC - after the last function argument and declare your utility function - with TSRMLS_DC after the last declared argument. Always refer to - the globals in your function as COMPILER_G(variable). You are - encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ + #ifdef ZTS #define BCOMPILERG(v) TSRMG(bcompiler_globals_id, zend_bcompiler_globals *, v) #else @@ -68,9 +82,7 @@ - -typedef void* (*apc_malloc_t)(int); - + /* By convention all apc_serialize_* functions serialize objects of the * specified type to the serialization buffer (dst). The apc_deserialize_* * functions deserialize objects of the specified type from the @@ -153,32 +165,12 @@ void apc_create_zend_function(zend_function** zf TSRMLS_DC); void apc_free_zend_function(zend_function** zf TSRMLS_DC); -/* special purpose */ -void apc_serialize_zend_function_table(HashTable* gft TSRMLS_DC); -void apc_deserialize_zend_function_table(HashTable* gft TSRMLS_DC); -void apc_serialize_zend_class_table(HashTable* gct TSRMLS_DC); -int apc_deserialize_zend_class_table(HashTable* gct TSRMLS_DC); -void apc_fixup_opcodes(zend_op* opcodes, int num_ops, apc_malloc_t ctor TSRMLS_DC); -void apc_fixup_class_table(HashTable* ht, apc_malloc_t ctor TSRMLS_DC); -void apc_free_string(char **ptr TSRMLS_DC); - -void apc_serialize_debug(char * string TSRMLS_DC); - - - - - - - - - - - - + + #endif /* PHP_BCOMPILER_H */ -/* __footer_here__ */ + \ No newline at end of file Index: pear/PECL/bcompiler/bcompiler.c diff -u pear/PECL/bcompiler/bcompiler.c:1.2 pear/PECL/bcompiler/bcompiler.c:1.3 --- pear/PECL/bcompiler/bcompiler.c:1.2 Tue Jul 23 03:01:05 2002 +++ pear/PECL/bcompiler/bcompiler.c Tue Jul 23 04:31:04 2002 @@ -19,7 +19,7 @@ | Mike Bretz <mike@metropolis-ag.de> | +----------------------------------------------------------------------+ */ -/* $Id: bcompiler.c,v 1.2 2002/07/23 07:01:05 alan_k Exp $ */ +/* $Id: bcompiler.c,v 1.3 2002/07/23 08:31:04 alan_k Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -36,43 +36,44 @@ #include <stdlib.h> #include <assert.h> +/* Define the header & version */ + #define BCOMPILER_VERSION "0.3" #ifdef PHP_HAVE_STREAMS #define BCOMPILER_STREAMS "s" #else #define BCOMPILER_STREAMS "" #endif - #define BCOMPILER_MAGIC_HEADER "bcompiler v" BCOMPILER_VERSION BCOMPILER_STREAMS -#define DEBUGLEVEL 0 +/* Debugging */ +#define DEBUGLEVEL 0 #if DEBUGLEVEL #define BCOMPILER_DEBUG(args) (printf("DEBUG: "), printf args) #else #define BCOMPILER_DEBUG(args) #endif -// If you declare any globals in php_compiler.h uncomment this: +/* we use globals */ ZEND_DECLARE_MODULE_GLOBALS(bcompiler) /* {{{ bcompiler_functions[] * - * Every user visible function must have an entry in bcompiler_functions[]. + * All the functions in bcompiler */ function_entry bcompiler_functions[] = { - PHP_FE(bcompile_write_header, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_write_class, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_write_footer, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_write_exe_footer, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_read, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_load, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_load_exe, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_parse_class, NULL) /* bCompiler a class and return data.*/ - /* __function_entries_here__ */ - {NULL, NULL, NULL} /* Must be the last line in compiler_functions[] */ + PHP_FE(bcompile_write_header, NULL) + PHP_FE(bcompile_write_class, NULL) + PHP_FE(bcompile_write_footer, NULL) + PHP_FE(bcompile_write_exe_footer, NULL) + PHP_FE(bcompile_read, NULL) + PHP_FE(bcompile_load, NULL) + PHP_FE(bcompile_load_exe, NULL) + PHP_FE(bcompile_parse_class, NULL) + {NULL, NULL, NULL} }; /* }}} */ @@ -86,8 +87,8 @@ bcompiler_functions, PHP_MINIT(bcompiler), PHP_MSHUTDOWN(bcompiler), - PHP_RINIT(bcompiler), /* Replace with NULL if there's nothing to do at request start */ - PHP_RSHUTDOWN(bcompiler), /* Replace with NULL if there's nothing to do at request end */ + PHP_RINIT(bcompiler), + PHP_RSHUTDOWN(bcompiler), PHP_MINFO(bcompiler), #if ZEND_MODULE_API_NO >= 20010901 BCOMPILER_VERSION BCOMPILER_STREAMS, /* Replace with version number for your extension */ @@ -100,30 +101,15 @@ ZEND_GET_MODULE(bcompiler) #endif -/* {{{ PHP_INI - */ -/* Remove comments and fill if you need to have entries in php.ini -PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("bcompiler.global_value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_bcompiler_globals, bcompiler_globals) - STD_PHP_INI_ENTRY("bcompiler.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_bcompiler_globals, bcompiler_globals) -PHP_INI_END() -*/ -/* }}} */ - -enum { START_SIZE = 1, GROW_FACTOR = 2 }; + /* {{{ php_bcompiler_init_globals */ static void php_bcompiler_init_globals(zend_bcompiler_globals *bcompiler_globals) { - /*if (bcompiler_globals->dst == 0) { - bcompiler_globals->dstsize = START_SIZE; - bcompiler_globals->dst = (char*) malloc(bcompiler_globals->dstsize); - } - bcompiler_globals->dstpos = 0; - */ - bcompiler_globals->buffer = (char*) emalloc(START_SIZE); + + bcompiler_globals->buffer = (char*) emalloc(1); bcompiler_globals->stream = NULL; bcompiler_globals->callback = NULL; bcompiler_globals->callback_value = NULL; @@ -136,10 +122,8 @@ */ PHP_MINIT_FUNCTION(bcompiler) { - // If you have INI entries, uncomment these lines + ZEND_INIT_MODULE_GLOBALS(bcompiler, php_bcompiler_init_globals, NULL); - //REGISTER_INI_ENTRIES(); - return SUCCESS; } /* }}} */ @@ -148,13 +132,11 @@ */ PHP_MSHUTDOWN_FUNCTION(bcompiler) { - // uncomment this line if you have INI entries - //UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ -/* Remove if there's nothing to do at request start */ + /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(bcompiler) @@ -163,7 +145,6 @@ } /* }}} */ -/* Remove if there's nothing to do at request end */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(bcompiler) @@ -181,9 +162,6 @@ php_info_print_table_header(2, "bcompiler support", "enabled"); php_info_print_table_end(); - /* Remove comments if you have entries in php.ini - DISPLAY_INI_ENTRIES(); - */ } /* }}} */ @@ -201,12 +179,18 @@ /* These are flags that define start points in the decompile code.. +At present theres only 1 - classes ... */ #define BCOMPILER_CLASS_ENTRY 1 -/* type: Fundamental operations */ -/* ------------- STREAM BASED - eg. => php 4.3 -------------- */ + + + + +/* Definitions that output stuff. */ + +/* --------------------------------------- STREAM BASED - eg. => php 4.3 -------------- */ #ifdef PHP_HAVE_STREAMS @@ -257,9 +241,18 @@ #else -/* ------------- NON STREAM BASED - eg. before php 4.3 -------------- */ -/* SERIALIZE_SCALAR: write a scalar value to dst */ + + + + + + + +/* Definitions that output stuff. */ + +/* --------------------------------------- NON STREAM BASED - eg. < php 4.3 -------------- */ + #define SERIALIZE_SCALAR(x, type) { \ if (BCOMPILERG(stream) != NULL) { \ char _buf[255]; \ @@ -300,7 +293,7 @@ BCOMPILERG(buffer) = (char*) erealloc(BCOMPILERG(buffer), n + 1); \ fread(BCOMPILERG(buffer) ,1, n, (FILE*) BCOMPILERG(stream)); \ memcpy((char*)bytes, BCOMPILERG(buffer), n); \ - BCOMPILER_DEBUG(("Got: %s\n",(char*)BCOMPILERG(buffer))); \ + /* BCOMPILER_DEBUG(("Got: %s\n",(char*)BCOMPILERG(buffer))); */ \ } @@ -405,14 +398,17 @@ } \ } -/* ---------------------------------------------------------------------------- -* -* function defs - putting this in .h doesnt work. -* -* -* ---------------------------------------------------------------------------- -*/ + + +/* ------------------- All the public php functions ------------------------*/ + + + + + + + /* {{{ proto boolean bcompile_write_class(stream out | filehandle, string class_name) Writes compiled data to stream*/ @@ -451,6 +447,13 @@ } /* }}} */ + + + + + + + /* {{{ proto boolean bcompile_parse_class(callback, string class_name) Writes compiled data to stream*/ PHP_FUNCTION(bcompile_parse_class) @@ -484,6 +487,11 @@ RETURN_TRUE; } /* }}} */ + + + + + /* {{{ proto boolean bcompiler_write_header(stream out) Writes the start flag*/ PHP_FUNCTION(bcompile_write_header) @@ -510,6 +518,14 @@ RETURN_TRUE; } /* }}} */ + + + + + + + + /* {{{ proto boolean bcompiler_write_end(stream out) Writes the end zero*/ PHP_FUNCTION(bcompile_write_footer) @@ -536,6 +552,14 @@ } /* }}} */ + + + + + + + + /* {{{ proto boolean bcompile_class(stream out, int start_pos) Writes compiled data to stream*/ PHP_FUNCTION(bcompile_write_exe_footer) @@ -564,6 +588,10 @@ RETURN_TRUE; } /* }}} */ + + + + /* {{{ proto boolean bcompile_read(stream in) Reads compiled data from stream*/ PHP_FUNCTION(bcompile_read) @@ -605,6 +633,12 @@ RETURN_TRUE; } +/* }}} */ + + + + + /* {{{ proto boolean bcompile_load(bziped file) Reads compiled data bziped file*/ @@ -676,6 +710,12 @@ RETURN_TRUE; } /* }}} */ + + + + + + /* {{{ proto boolean bcompile_load(bziped file) Reads compiled data bziped file*/ PHP_FUNCTION(bcompile_load_exe) @@ -814,6 +854,8 @@ +/* {{{ bcompiler_read - the real reading method.*/ + void bcompiler_read(TSRMLS_DC) { char item; @@ -837,7 +879,12 @@ } else { (*zc->refcount)++; BCOMPILER_DEBUG(("ADDING %s \n",zc->name)); - zend_hash_add(EG(class_table), zc->name, zc->name_length+1, zc, sizeof(zend_class_entry), NULL); + if (zend_hash_add(EG(class_table), zc->name, zc->name_length+1, zc, sizeof(zend_class_entry), NULL) == FAILURE) { + (*zc->refcount)--; + zend_hash_destroy(&zc->function_table); + zend_hash_destroy(&zc->default_properties); + php_error(E_ERROR, "bcompiler: Read Past End of File"); + } } } @@ -845,6 +892,7 @@ } } +/* }}} */ @@ -860,35 +908,7 @@ - - - -char* apclib_vstrdup(const char* s, apc_malloc_t ctor) -{ - int n; - char* t; - - if (s == NULL) { - return NULL; - } - n = strlen(s) + 1; - t = (char*) ctor(n); - memcpy(t, s, n); - return t; -} - -void* apclib_vmemcpy(void* p, int n, apc_malloc_t ctor) -{ - void* q; - - if (p == NULL) { - return NULL; - } - q = ctor(n); - memcpy(q, p, n); - return q; -} - + char* apclib_estrdup(const char* s) { @@ -928,15 +948,6 @@ *string = NULL; } -/* expandbuf: resize buffer to be at least minsize bytes in length */ -static void apclib_expandbuf(char** bufptr, int* cursize, int minsize) -{ - while (*cursize < minsize) { - *cursize *= GROW_FACTOR; - } - *bufptr = (char*) realloc(*bufptr, *cursize); -} - int apclib_alignword_int(int x) { @@ -949,6 +960,8 @@ /* NO IDEA WHAT THIS STUFF IS ABOUT - probably needs sorting out... +-- it's only used in defered class declarations - which shouldnt really be supported */ + /* namearray_t is used to record deferred inheritance relationships */ typedef struct namearray_t namearray_t; @@ -959,17 +972,7 @@ int size; /* physical size of strings */ }; -/* namearray_dtor: used to clean up deferred_inheritance table (see below) */ -static void namearray_dtor(void* p) -{ - namearray_t* na = (namearray_t*) p; - - if (na->strings != 0) { - free(na->strings); - } - free(na); -} - + @@ -988,122 +991,159 @@ static const char* opcodes[] = { - "NOP", /* 0 */ - "ADD", /* 1 */ - "SUB", /* 2 */ - "MUL", /* 3 */ - "DIV", /* 4 */ - "MOD", /* 5 */ - "SL", /* 6 */ - "SR", /* 7 */ - "CONCAT", /* 8 */ - "BW_OR", /* 9 */ - "BW_AND", /* 10 */ - "BW_XOR", /* 11 */ - "BW_NOT", /* 12 */ - "BOOL_NOT", /* 13 */ - "BOOL_XOR", /* 14 */ - "IS_IDENTICAL", /* 15 */ - "IS_NOT_IDENTICAL", /* 16 */ - "IS_EQUAL", /* 17 */ - "IS_NOT_EQUAL", /* 18 */ - "IS_SMALLER", /* 19 */ - "IS_SMALLER_OR_EQUAL", /* 20 */ - "CAST", /* 21 */ - "QM_ASSIGN", /* 22 */ - "ASSIGN_ADD", /* 23 */ - "ASSIGN_SUB", /* 24 */ - "ASSIGN_MUL", /* 25 */ - "ASSIGN_DIV", /* 26 */ - "ASSIGN_MOD", /* 27 */ - "ASSIGN_SL", /* 28 */ - "ASSIGN_SR", /* 29 */ - "ASSIGN_CONCAT", /* 30 */ - "ASSIGN_BW_OR", /* 31 */ - "ASSIGN_BW_AND", /* 32 */ - "ASSIGN_BW_XOR", /* 33 */ - "PRE_INC", /* 34 */ - "PRE_DEC", /* 35 */ - "POST_INC", /* 36 */ - "POST_DEC", /* 37 */ - "ASSIGN", /* 38 */ - "ASSIGN_REF", /* 39 */ - "ECHO", /* 40 */ - "PRINT", /* 41 */ - "JMP", /* 42 */ - "JMPZ", /* 43 */ - "JMPNZ", /* 44 */ - "JMPZNZ", /* 45 */ - "JMPZ_EX", /* 46 */ - "JMPNZ_EX", /* 47 */ - "CASE", /* 48 */ - "SWITCH_FREE", /* 49 */ - "BRK", /* 50 */ - "CONT", /* 51 */ - "BOOL", /* 52 */ - "INIT_STRING", /* 53 */ - "ADD_CHAR", /* 54 */ - "ADD_STRING", /* 55 */ - "ADD_VAR", /* 56 */ - "BEGIN_SILENCE", /* 57 */ - "END_SILENCE", /* 58 */ - "INIT_FCALL_BY_NAME", /* 59 */ - "DO_FCALL", /* 60 */ - "DO_FCALL_BY_NAME", /* 61 */ - "RETURN", /* 62 */ - "RECV", /* 63 */ - "RECV_INIT", /* 64 */ - "SEND_VAL", /* 65 */ - "SEND_VAR", /* 66 */ - "SEND_REF", /* 67 */ - "NEW", /* 68 */ - "JMP_NO_CTOR", /* 69 */ - "FREE", /* 70 */ - "INIT_ARRAY", /* 71 */ - "ADD_ARRAY_ELEMENT", /* 72 */ - "INCLUDE_OR_EVAL", /* 73 */ - "UNSET_VAR", /* 74 */ - "UNSET_DIM_OBJ", /* 75 */ - "ISSET_ISEMPTY", /* 76 */ - "FE_RESET", /* 77 */ - "FE_FETCH", /* 78 */ - "EXIT", /* 79 */ - "FETCH_R", /* 80 */ - "FETCH_DIM_R", /* 81 */ - "FETCH_OBJ_R", /* 82 */ - "FETCH_W", /* 83 */ - "FETCH_DIM_W", /* 84 */ - "FETCH_OBJ_W", /* 85 */ - "FETCH_RW", /* 86 */ - "FETCH_DIM_RW", /* 87 */ - "FETCH_OBJ_RW", /* 88 */ - "FETCH_IS", /* 89 */ - "FETCH_DIM_IS", /* 90 */ - "FETCH_OBJ_IS", /* 91 */ - "FETCH_FUNC_ARG", /* 92 */ - "FETCH_DIM_FUNC_ARG", /* 93 */ - "FETCH_OBJ_FUNC_ARG", /* 94 */ - "FETCH_UNSET", /* 95 */ - "FETCH_DIM_UNSET", /* 96 */ - "FETCH_OBJ_UNSET", /* 97 */ - "FETCH_DIM_TMP_VAR", /* 98 */ - "FETCH_CONSTANT", /* 99 */ - "DECLARE_FUNCTION_OR_CLASS", /* 100 */ - "EXT_STMT", /* 101 */ - "EXT_FCALL_BEGIN", /* 102 */ - "EXT_FCALL_END", /* 103 */ - "EXT_NOP", /* 104 */ - "TICKS", /* 105 */ - "SEND_VAR_NO_REF", /* 106 */ - "BEGIN_CLASS_DEF", /* 107 */ - "BEGIN_HASH_DEF", /* 108 */ - "OPCODE_ARRAY", /* 109 */ + "NOP", /* 0 */ + "ADD", /* 1 */ + "SUB", /* 2 */ + "MUL", /* 3 */ + "DIV", /* 4 */ + "MOD", /* 5 */ + "SL", /* 6 */ + "SR", /* 7 */ + "CONCAT", /* 8 */ + "BW_OR", /* 9 */ + "BW_AND", /* 10 */ + "BW_XOR", /* 11 */ + "BW_NOT", /* 12 */ + "BOOL_NOT", /* 13 */ + "BOOL_XOR", /* 14 */ + "IS_IDENTICAL", /* 15 */ + "IS_NOT_IDENTICAL", /* 16 */ + "IS_EQUAL", /* 17 */ + "IS_NOT_EQUAL", /* 18 */ + "IS_SMALLER", /* 19 */ + "IS_SMALLER_OR_EQUAL", /* 20 */ + "CAST", /* 21 */ + "QM_ASSIGN", /* 22 */ + "ASSIGN_ADD", /* 23 */ + "ASSIGN_SUB", /* 24 */ + "ASSIGN_MUL", /* 25 */ + "ASSIGN_DIV", /* 26 */ + "ASSIGN_MOD", /* 27 */ + "ASSIGN_SL", /* 28 */ + "ASSIGN_SR", /* 29 */ + "ASSIGN_CONCAT", /* 30 */ + "ASSIGN_BW_OR", /* 31 */ + "ASSIGN_BW_AND", /* 32 */ + "ASSIGN_BW_XOR", /* 33 */ + "PRE_INC", /* 34 */ + "PRE_DEC", /* 35 */ + "POST_INC", /* 36 */ + "POST_DEC", /* 37 */ + "ASSIGN", /* 38 */ + "ASSIGN_REF", /* 39 */ + "ECHO", /* 40 */ + "PRINT", /* 41 */ + "JMP", /* 42 */ + "JMPZ", /* 43 */ + "JMPNZ", /* 44 */ + "JMPZNZ", /* 45 */ + "JMPZ_EX", /* 46 */ + "JMPNZ_EX", /* 47 */ + "CASE", /* 48 */ + "SWITCH_FREE", /* 49 */ + "BRK", /* 50 */ + "CONT", /* 51 */ + "BOOL", /* 52 */ + "INIT_STRING", /* 53 */ + "ADD_CHAR", /* 54 */ + "ADD_STRING", /* 55 */ + "ADD_VAR", /* 56 */ + "BEGIN_SILENCE", /* 57 */ + "END_SILENCE", /* 58 */ + "INIT_FCALL_BY_NAME", /* 59 */ + "DO_FCALL", /* 60 */ + "DO_FCALL_BY_NAME", /* 61 */ + "RETURN", /* 62 */ + "RECV", /* 63 */ + "RECV_INIT", /* 64 */ + "SEND_VAL", /* 65 */ + "SEND_VAR", /* 66 */ + "SEND_REF", /* 67 */ + "NEW", /* 68 */ + "JMP_NO_CTOR", /* 69 */ + "FREE", /* 70 */ + "INIT_ARRAY", /* 71 */ + "ADD_ARRAY_ELEMENT", /* 72 */ + "INCLUDE_OR_EVAL", /* 73 */ + "UNSET_VAR", /* 74 */ + "UNSET_DIM_OBJ", /* 75 */ + "ISSET_ISEMPTY", /* 76 */ + "FE_RESET", /* 77 */ + "FE_FETCH", /* 78 */ + "EXIT", /* 79 */ + "FETCH_R", /* 80 */ + "FETCH_DIM_R", /* 81 */ + "FETCH_OBJ_R", /* 82 */ + "FETCH_W", /* 83 */ + "FETCH_DIM_W", /* 84 */ + "FETCH_OBJ_W", /* 85 */ + "FETCH_RW", /* 86 */ + "FETCH_DIM_RW", /* 87 */ + "FETCH_OBJ_RW", /* 88 */ + "FETCH_IS", /* 89 */ + "FETCH_DIM_IS", /* 90 */ + "FETCH_OBJ_IS", /* 91 */ + "FETCH_FUNC_ARG", /* 92 */ + "FETCH_DIM_FUNC_ARG", /* 93 */ + "FETCH_OBJ_FUNC_ARG", /* 94 */ + "FETCH_UNSET", /* 95 */ + "FETCH_DIM_UNSET", /* 96 */ + "FETCH_OBJ_UNSET", /* 97 */ + "FETCH_DIM_TMP_VAR", /* 98 */ + "FETCH_CONSTANT", /* 99 */ + "DECLARE_FUNCTION_OR_CLASS", /* 100 */ + "EXT_STMT", /* 101 */ + "EXT_FCALL_BEGIN", /* 102 */ + "EXT_FCALL_END", /* 103 */ + "EXT_NOP", /* 104 */ + "TICKS", /* 105 */ + "SEND_VAR_NO_REF", /* 106 */ + + "ZEND_CATCH", /* 107 */ + "ZEND_THROW", /* 108 */ + "ZEND_FETCH_CLASS", /* 109 */ + "ZEND_CLONE", /* 110 */ + "ZEND_INIT_CTOR_CALL", /* 111 */ + "ZEND_INIT_METHOD_CALL", /* 112 */ + "ZEND_INIT_STATIC_METHOD_CALL", /* 113 */ + "ZEND_ISSET_ISEMPTY_VAR", /* 114 */ + "ZEND_ISSET_ISEMPTY_DIM_OBJ", /* 115 */ + "ZEND_IMPORT_FUNCTION", /* 116 */ + "ZEND_IMPORT_CLASS", /* 117 */ + "ZEND_IMPORT_CONST", /* 118 */ + + "**UNKNOWN**", /* 119 */ + "**UNKNOWN**", /* 120 */ + + "ZEND_ASSIGN_ADD_OBJ", /* 121 */ + "ZEND_ASSIGN_SUB_OBJ", /* 122 */ + "ZEND_ASSIGN_MUL_OBJ", /* 123 */ + "ZEND_ASSIGN_DIV_OBJ", /* 124 */ + "ZEND_ASSIGN_MOD_OBJ", /* 125 */ + "ZEND_ASSIGN_SL_OBJ", /* 126 */ + "ZEND_ASSIGN_SR_OBJ", /* 127 */ + "ZEND_ASSIGN_CONCAT_OBJ", /* 128 */ + "ZEND_ASSIGN_BW_OR_OBJ", /* 129 */ + "END_ASSIGN_BW_AND_OBJ", /* 130 */ + "END_ASSIGN_BW_XOR_OBJ", /* 131 */ + "ZEND_PRE_INC_OBJ", /* 132 */ + "ZEND_PRE_DEC_OBJ", /* 133 */ + "ZEND_POST_INC_OBJ", /* 134 */ + "ZEND_POST_DEC_OBJ", /* 135 */ + "ZEND_ASSIGN_OBJ", /* 136 */ + "ZEND_MAKE_VAR", /* 137 */ + + + + + "BEGIN_HASH_DEF", /* 138 */ + "OPCODE_ARRAY" /* 139 */ }; -#define ZEND_BEGIN_HASH_DEF 108 -#define ZEND_OPCODE_ARRAY 109 +#define ZEND_BEGIN_HASH_DEF 138 +#define ZEND_OPCODE_ARRAY 139 static const int NUM_OPCODES = sizeof(opcodes) / sizeof(opcodes[0]); @@ -1123,74 +1163,29 @@ -/* ---------------------------------------------------------------------------- -* -* STUFF THAT PROBALY NEEDS DELETING. -* -* -* ---------------------------------------------------------------------------- -*/ - - - - - - - -/* inherit: recursively inherit methods from base to all the children + /* inherit: recursively inherit methods from base to all the children * of parent, the children of parent's children, and so on */ - /* -static void apc_inherit(zend_class_entry* base, zend_class_entry* parent, TSRMLS_DC) + +static void bcompiler_inherit(zend_class_entry* base TSRMLS_DC) { - namearray_t* children; // classes derived directly from parent - char* child_name; // name of the ith child of parent - int i; - - - return; - // stuff in here is ignored at present.. - // later - - // children = apc_nametable_retrieve(deferred_inheritance, parent->name); - - if (!children) { + + + zend_class_entry* child; + BCOMPILER_DEBUG(("base: %s",base->name)); + + if (!base->parent) { return; // 'parent' has no children, nothing to do } - - // For each child of parent, resolve the inheritance from base - // to the child. - - for (i = 0; i < children->length; i += strlen(child_name) + 1) { - zend_class_entry* child; - int result; - - child_name = children->strings + i; - - // look up the child class entry - result = zend_hash_find(CG(class_table), child_name, - strlen(child_name) + 1, (void**) &child); - assert(result == SUCCESS); // FIXME: is this correct? - - // child inherits from base - ZEND_DO_INHERITANCE(child, parent); - - // all children of child inherit from base - apc_inherit(parent, child); + child = base->parent; + + while(child) { + BCOMPILER_DEBUG(("child: %s",child->name)); + zend_do_inheritance(base,child); + child = child->parent; } -}*/ - -/* call_inherit */ - -static void apc_call_inherit(char *key, void *data TSRMLS_DC) -{ - zend_class_entry *ce; - - if(zend_hash_find(CG(class_table), key, strlen(key) + 1, (void **) &ce) - == SUCCESS) - { - apc_inherit(ce, ce); - } } + @@ -1203,47 +1198,14 @@ /* ---------------------------------------------------------------------------- * -* START STUFF THAT NEEDS GLOBALS.... +* START STUFF THAT NEEDS GLOBALS.... (eg. TSRMLS_DC) * * * ---------------------------------------------------------------------------- */ - - - - - - - - - - - - - - - - -/* First step in deserialization. Sets the size/position of the - * serialized buffer */ -void apc_init_deserializer(char* input, int size TSRMLS_DC) -{ -} - -/* apc_serialize_debug: prints information about the source and - * destination serialization buffers */ -void apc_serialize_debug(char * string TSRMLS_DC) -{ - BCOMPILER_DEBUG(("%s\n", string)); - //printf( "src=%p, srcpos=%d, srcsize=%d\n", BCOMPILERG(src), BCOMPILERG(srcpos), BCOMPILERG(srcsize)); - //printf( "dst=%p, dstpos=%d, dstsize=%d\n", BCOMPILERG(dst), BCOMPILERG(dstpos), BCOMPILERG(dstsize)); -} - - - - + void apc_serialize_string(char* string TSRMLS_DC) { @@ -1747,7 +1709,7 @@ } -/* type: zend_overloaded_element */ +/* type: zend_overloaded_element - i dont think these are used!*/ void apc_serialize_zend_overloaded_element(zend_overloaded_element* zoe TSRMLS_DC) @@ -1789,12 +1751,12 @@ - /*apc_serialize_debug("starting adding class :" TSRMLS_CC); */ + BCOMPILER_DEBUG(("adding type : %i\n",zce->type )); SERIALIZE_SCALAR(zce->type, char); apc_serialize_zstring(zce->name, zce->name_length TSRMLS_CC); SERIALIZE_SCALAR(zce->name_length, uint); - /*apc_serialize_debug("done name" TSRMLS_CC); */ + /* Serialize the name of this class's parent class (if it has one) * so that we can perform inheritance during deserialization (see * apc_deserialize_zend_class_entry). */ @@ -1813,7 +1775,7 @@ CALLBACK_ADD_STRING(zce->name, zce->name_length); CALLBACK_END(); /* now callback to class/funct etc. */ - /* apc_serialize_debug("done exists?" TSRMLS_CC); */ + @@ -1840,7 +1802,7 @@ for (i = 0; i < count; i++) { apc_serialize_zend_function_entry(&zce->builtin_functions[i] TSRMLS_CC); } - /* apc_serialize_debug("tail stuff" TSRMLS_CC); */ + SERIALIZE_SCALAR(zce->handle_function_call, void*); SERIALIZE_SCALAR(zce->handle_property_get, void*); SERIALIZE_SCALAR(zce->handle_property_set, void*); @@ -1922,16 +1884,7 @@ */ /* code from zend_do_inheritance - ignores constructor inheritance currenlty? */ if (zce->parent) { - zval *tmp; - zend_function tmp_zend_function; - zend_hash_merge(&zce->default_properties, &zce->parent->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); - zend_hash_merge(&zce->function_table, &zce->parent->function_table, (void (*)(void *)) function_add_ref, &tmp_zend_function, sizeof(zend_function), 0); - if (!zce->handle_property_get) - zce->handle_property_get = zce->parent->handle_property_get; - if (!zce->handle_property_set) - zce->handle_property_set = zce->parent->handle_property_set; - if (!zce->handle_function_call) - zce->handle_function_call = zce->parent->handle_function_call; + bcompiler_inherit(zce); } } @@ -2016,7 +1969,7 @@ void apc_serialize_zend_op(int id, zend_op* zo TSRMLS_DC) { - /* apc_serialize_debug(getOpcodeName(zo->opcode)); */ + //fprintf(stderr, "Outputting %s\n", getOpcodeName(zo->opcode)); CALLBACK_START(zo->opcode); SERIALIZE_SCALAR(zo->opcode, zend_uchar); @@ -2431,82 +2384,7 @@ /* The logic for serialize_class_table and deserialize_class_table * mirror that of the corresponding function_table functions (see * above), with classes in place of functions. */ - -static int store_class_table(void *element, int num_args, va_list args, zend_hash_key *hash_key TSRMLS_DC) -{ - zend_class_entry* zc; - - zc = (zend_class_entry*) element; - - /* do not serialize internal classes */ - if (zc->type == ZEND_INTERNAL_CLASS) { - return 0; - } - - /* serialize differences */ - SERIALIZE_SCALAR(1, char); - apc_serialize_zend_class_entry(zc TSRMLS_CC); - if(zc->parent != NULL) { - //apc_nametable_insert(priv, zc->name, 0); - } - return 0; - -} - -static int store_class_table_ex(void *element, int num_args, va_list args, zend_hash_key *hash_key TSRMLS_DC) -{ - zend_class_entry* zc; - zc = (zend_class_entry*) element; - - /* do not serialize internal classes */ - if (zc->type == ZEND_INTERNAL_CLASS) { - return 0; - } - - /* serialize differences */ - SERIALIZE_SCALAR(1, char); - // apc_serialize_zstring(hash_key->arKey, hash_key->nKeyLength); - apc_serialize_zend_class_entry(zc TSRMLS_CC); - // Think about tracking same-file inheritance - return 0; -} - -void apc_serialize_zend_class_table(HashTable* gct TSRMLS_DC) -{ - zend_hash_apply_with_arguments(gct, store_class_table, 0, NULL); - SERIALIZE_SCALAR(0, char); -} - -int apc_deserialize_zend_class_table(HashTable* gct TSRMLS_DC) -{ - char exists; - int i; - zend_class_entry* zc; - - i = 0; - - DESERIALIZE_SCALAR(&exists, char); - while (exists) { - apc_create_zend_class_entry(&zc TSRMLS_CC); - if (zend_hash_add(gct, zc->name, zc->name_length + 1, - zc, sizeof(zend_class_entry), NULL) == FAILURE) - { - /* This can validly happen. */ - } - /* We may only want to do this insert if zc->parent is NULL */ - //apc_nametable_insert(parental_inheritors, zc->name, NULL); - //apc_nametable_insert(acc, zc->name, 0); - //apc_nametable_insert(priv, zc->name, 0); - DESERIALIZE_SCALAR(&exists, char); - // apc_free_zend_class_entry - if (zc != NULL) - efree(zc); // ADDED BY MPB - i++; - } - return i; -} - - + /*
Index: pear/PECL/bcompiler/php_bcompiler.h diff -u pear/PECL/bcompiler/php_bcompiler.h:1.1 pear/PECL/bcompiler/php_bcompiler.h:1.2 --- pear/PECL/bcompiler/php_bcompiler.h:1.1 Tue Jul 23 02:55:57 2002 +++ pear/PECL/bcompiler/php_bcompiler.h Tue Jul 23 04:31:04 2002 @@ -1,4 +1,27 @@ -/* __header_here__ */ +/* + +----------------------------------------------------------------------+ + | PHP bcompiler Based on APC Cache | + +----------------------------------------------------------------------+ + | Copyright (c) 2000-2001 Community Connect, Inc. (apc_* functions) | + | Copyright (c) 1997-2002 The PHP Group (remaining code) | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Alan Knowles <alan@akbkhome.com> (php module) | + | Daniel Cowgill <dan@mail.communityconnect.com> | + | George Schlossnagle <george@lethargy.org> | + | Mike Bretz <mike@metropolis-ag.de> | + +----------------------------------------------------------------------+ + */ + + + #include "ext/standard/file.h" #ifndef PHP_BCOMPILER_H #define PHP_BCOMPILER_H @@ -23,17 +46,18 @@ PHP_RSHUTDOWN_FUNCTION(bcompiler); PHP_MINFO_FUNCTION(bcompiler); -/* __function_declarations_here__ */ -PHP_FUNCTION(confirm_bcompiler_compiled); /* For testing, remove later. */ + + PHP_FUNCTION(bcompile_write_class); /* Write a class */ PHP_FUNCTION(bcompile_write_header); /* Write the header */ -PHP_FUNCTION(bcompile_write_exe_footer); /* Write the end zero byte */ +PHP_FUNCTION(bcompile_write_exe_footer);/* Write the end zero byte */ PHP_FUNCTION(bcompile_write_footer); /* Write the tail for a exe type file*/ -PHP_FUNCTION(bcompile_read); /* Read a file handle */ -PHP_FUNCTION(bcompile_load); /* Read a file handle */ -PHP_FUNCTION(bcompile_load_exe); /* Read a file handle */ +PHP_FUNCTION(bcompile_read); /* Read a file handle */ +PHP_FUNCTION(bcompile_load); /* load a file */ +PHP_FUNCTION(bcompile_load_exe); /* loads an exe style file */ +PHP_FUNCTION(bcompile_parse_class); /* callback opcodes for a class */ + -PHP_FUNCTION(bcompile_parse_class); /* Write a class */ /* Declare any global variables you may need between the BEGIN @@ -49,17 +73,7 @@ #include "zend.h" #include "zend_variables.h" // for zval_dtor() - - -/* In every utility function you add that needs to use variables - in php_bcompiler_globals, call TSRM_FETCH(); after declaring other - variables used by that function, or better yet, pass in TSRMG_CC - after the last function argument and declare your utility function - with TSRMLS_DC after the last declared argument. Always refer to - the globals in your function as COMPILER_G(variable). You are - encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ + #ifdef ZTS #define BCOMPILERG(v) TSRMG(bcompiler_globals_id, zend_bcompiler_globals *, v) #else @@ -68,9 +82,7 @@ - -typedef void* (*apc_malloc_t)(int); - + /* By convention all apc_serialize_* functions serialize objects of the * specified type to the serialization buffer (dst). The apc_deserialize_* * functions deserialize objects of the specified type from the @@ -153,32 +165,12 @@ void apc_create_zend_function(zend_function** zf TSRMLS_DC); void apc_free_zend_function(zend_function** zf TSRMLS_DC); -/* special purpose */ -void apc_serialize_zend_function_table(HashTable* gft TSRMLS_DC); -void apc_deserialize_zend_function_table(HashTable* gft TSRMLS_DC); -void apc_serialize_zend_class_table(HashTable* gct TSRMLS_DC); -int apc_deserialize_zend_class_table(HashTable* gct TSRMLS_DC); -void apc_fixup_opcodes(zend_op* opcodes, int num_ops, apc_malloc_t ctor TSRMLS_DC); -void apc_fixup_class_table(HashTable* ht, apc_malloc_t ctor TSRMLS_DC); -void apc_free_string(char **ptr TSRMLS_DC); - -void apc_serialize_debug(char * string TSRMLS_DC); - - - - - - - - - - - - + + #endif /* PHP_BCOMPILER_H */ -/* __footer_here__ */ + \ No newline at end of file Index: pear/PECL/bcompiler/bcompiler.c diff -u pear/PECL/bcompiler/bcompiler.c:1.2 pear/PECL/bcompiler/bcompiler.c:1.3 --- pear/PECL/bcompiler/bcompiler.c:1.2 Tue Jul 23 03:01:05 2002 +++ pear/PECL/bcompiler/bcompiler.c Tue Jul 23 04:31:04 2002 @@ -19,7 +19,7 @@ | Mike Bretz <mike@metropolis-ag.de> | +----------------------------------------------------------------------+ */ -/* $Id: bcompiler.c,v 1.2 2002/07/23 07:01:05 alan_k Exp $ */ +/* $Id: bcompiler.c,v 1.3 2002/07/23 08:31:04 alan_k Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -36,43 +36,44 @@ #include <stdlib.h> #include <assert.h> +/* Define the header & version */ + #define BCOMPILER_VERSION "0.3" #ifdef PHP_HAVE_STREAMS #define BCOMPILER_STREAMS "s" #else #define BCOMPILER_STREAMS "" #endif - #define BCOMPILER_MAGIC_HEADER "bcompiler v" BCOMPILER_VERSION BCOMPILER_STREAMS -#define DEBUGLEVEL 0 +/* Debugging */ +#define DEBUGLEVEL 0 #if DEBUGLEVEL #define BCOMPILER_DEBUG(args) (printf("DEBUG: "), printf args) #else #define BCOMPILER_DEBUG(args) #endif -// If you declare any globals in php_compiler.h uncomment this: +/* we use globals */ ZEND_DECLARE_MODULE_GLOBALS(bcompiler) /* {{{ bcompiler_functions[] * - * Every user visible function must have an entry in bcompiler_functions[]. + * All the functions in bcompiler */ function_entry bcompiler_functions[] = { - PHP_FE(bcompile_write_header, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_write_class, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_write_footer, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_write_exe_footer, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_read, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_load, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_load_exe, NULL) /* bCompiler a class and return data.*/ - PHP_FE(bcompile_parse_class, NULL) /* bCompiler a class and return data.*/ - /* __function_entries_here__ */ - {NULL, NULL, NULL} /* Must be the last line in compiler_functions[] */ + PHP_FE(bcompile_write_header, NULL) + PHP_FE(bcompile_write_class, NULL) + PHP_FE(bcompile_write_footer, NULL) + PHP_FE(bcompile_write_exe_footer, NULL) + PHP_FE(bcompile_read, NULL) + PHP_FE(bcompile_load, NULL) + PHP_FE(bcompile_load_exe, NULL) + PHP_FE(bcompile_parse_class, NULL) + {NULL, NULL, NULL} }; /* }}} */ @@ -86,8 +87,8 @@ bcompiler_functions, PHP_MINIT(bcompiler), PHP_MSHUTDOWN(bcompiler), - PHP_RINIT(bcompiler), /* Replace with NULL if there's nothing to do at request start */ - PHP_RSHUTDOWN(bcompiler), /* Replace with NULL if there's nothing to do at request end */ + PHP_RINIT(bcompiler), + PHP_RSHUTDOWN(bcompiler), PHP_MINFO(bcompiler), #if ZEND_MODULE_API_NO >= 20010901 BCOMPILER_VERSION BCOMPILER_STREAMS, /* Replace with version number for your extension */ @@ -100,30 +101,15 @@ ZEND_GET_MODULE(bcompiler) #endif -/* {{{ PHP_INI - */ -/* Remove comments and fill if you need to have entries in php.ini -PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("bcompiler.global_value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_bcompiler_globals, bcompiler_globals) - STD_PHP_INI_ENTRY("bcompiler.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_bcompiler_globals, bcompiler_globals) -PHP_INI_END() -*/ -/* }}} */ - -enum { START_SIZE = 1, GROW_FACTOR = 2 }; + /* {{{ php_bcompiler_init_globals */ static void php_bcompiler_init_globals(zend_bcompiler_globals *bcompiler_globals) { - /*if (bcompiler_globals->dst == 0) { - bcompiler_globals->dstsize = START_SIZE; - bcompiler_globals->dst = (char*) malloc(bcompiler_globals->dstsize); - } - bcompiler_globals->dstpos = 0; - */ - bcompiler_globals->buffer = (char*) emalloc(START_SIZE); + + bcompiler_globals->buffer = (char*) emalloc(1); bcompiler_globals->stream = NULL; bcompiler_globals->callback = NULL; bcompiler_globals->callback_value = NULL; @@ -136,10 +122,8 @@ */ PHP_MINIT_FUNCTION(bcompiler) { - // If you have INI entries, uncomment these lines + ZEND_INIT_MODULE_GLOBALS(bcompiler, php_bcompiler_init_globals, NULL); - //REGISTER_INI_ENTRIES(); - return SUCCESS; } /* }}} */ @@ -148,13 +132,11 @@ */ PHP_MSHUTDOWN_FUNCTION(bcompiler) { - // uncomment this line if you have INI entries - //UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ -/* Remove if there's nothing to do at request start */ + /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(bcompiler) @@ -163,7 +145,6 @@ } /* }}} */ -/* Remove if there's nothing to do at request end */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(bcompiler) @@ -181,9 +162,6 @@ php_info_print_table_header(2, "bcompiler support", "enabled"); php_info_print_table_end(); - /* Remove comments if you have entries in php.ini - DISPLAY_INI_ENTRIES(); - */ } /* }}} */ @@ -201,12 +179,18 @@ /* These are flags that define start points in the decompile code.. +At present theres only 1 - classes ... */ #define BCOMPILER_CLASS_ENTRY 1 -/* type: Fundamental operations */ -/* ------------- STREAM BASED - eg. => php 4.3 -------------- */ + + + + +/* Definitions that output stuff. */ + +/* --------------------------------------- STREAM BASED - eg. => php 4.3 -------------- */ #ifdef PHP_HAVE_STREAMS @@ -257,9 +241,18 @@ #else -/* ------------- NON STREAM BASED - eg. before php 4.3 -------------- */ -/* SERIALIZE_SCALAR: write a scalar value to dst */ + + + + + + + +/* Definitions that output stuff. */ + +/* --------------------------------------- NON STREAM BASED - eg. < php 4.3 -------------- */ + #define SERIALIZE_SCALAR(x, type) { \ if (BCOMPILERG(stream) != NULL) { \ char _buf[255]; \ @@ -300,7 +293,7 @@ BCOMPILERG(buffer) = (char*) erealloc(BCOMPILERG(buffer), n + 1); \ fread(BCOMPILERG(buffer) ,1, n, (FILE*) BCOMPILERG(stream)); \ memcpy((char*)bytes, BCOMPILERG(buffer), n); \ - BCOMPILER_DEBUG(("Got: %s\n",(char*)BCOMPILERG(buffer))); \ + /* BCOMPILER_DEBUG(("Got: %s\n",(char*)BCOMPILERG(buffer))); */ \ } @@ -405,14 +398,17 @@ } \ } -/* ---------------------------------------------------------------------------- -* -* function defs - putting this in .h doesnt work. -* -* -* ---------------------------------------------------------------------------- -*/ + + +/* ------------------- All the public php functions ------------------------*/ + + + + + + + /* {{{ proto boolean bcompile_write_class(stream out | filehandle, string class_name) Writes compiled data to stream*/ @@ -451,6 +447,13 @@ } /* }}} */ + + + + + + + /* {{{ proto boolean bcompile_parse_class(callback, string class_name) Writes compiled data to stream*/ PHP_FUNCTION(bcompile_parse_class) @@ -484,6 +487,11 @@ RETURN_TRUE; } /* }}} */ + + + + + /* {{{ proto boolean bcompiler_write_header(stream out) Writes the start flag*/ PHP_FUNCTION(bcompile_write_header) @@ -510,6 +518,14 @@ RETURN_TRUE; } /* }}} */ + + + + + + + + /* {{{ proto boolean bcompiler_write_end(stream out) Writes the end zero*/ PHP_FUNCTION(bcompile_write_footer) @@ -536,6 +552,14 @@ } /* }}} */ + + + + + + + + /* {{{ proto boolean bcompile_class(stream out, int start_pos) Writes compiled data to stream*/ PHP_FUNCTION(bcompile_write_exe_footer) @@ -564,6 +588,10 @@ RETURN_TRUE; } /* }}} */ + + + + /* {{{ proto boolean bcompile_read(stream in) Reads compiled data from stream*/ PHP_FUNCTION(bcompile_read) @@ -605,6 +633,12 @@ RETURN_TRUE; } +/* }}} */ + + + + + /* {{{ proto boolean bcompile_load(bziped file) Reads compiled data bziped file*/ @@ -676,6 +710,12 @@ RETURN_TRUE; } /* }}} */ + + + + + + /* {{{ proto boolean bcompile_load(bziped file) Reads compiled data bziped file*/ PHP_FUNCTION(bcompile_load_exe) @@ -814,6 +854,8 @@ +/* {{{ bcompiler_read - the real reading method.*/ + void bcompiler_read(TSRMLS_DC) { char item; @@ -837,7 +879,12 @@ } else { (*zc->refcount)++; BCOMPILER_DEBUG(("ADDING %s \n",zc->name)); - zend_hash_add(EG(class_table), zc->name, zc->name_length+1, zc, sizeof(zend_class_entry), NULL); + if (zend_hash_add(EG(class_table), zc->name, zc->name_length+1, zc, sizeof(zend_class_entry), NULL) == FAILURE) { + (*zc->refcount)--; + zend_hash_destroy(&zc->function_table); + zend_hash_destroy(&zc->default_properties); + php_error(E_ERROR, "bcompiler: Read Past End of File"); + } } } @@ -845,6 +892,7 @@ } } +/* }}} */ @@ -860,35 +908,7 @@ - - - -char* apclib_vstrdup(const char* s, apc_malloc_t ctor) -{ - int n; - char* t; - - if (s == NULL) { - return NULL; - } - n = strlen(s) + 1; - t = (char*) ctor(n); - memcpy(t, s, n); - return t; -} - -void* apclib_vmemcpy(void* p, int n, apc_malloc_t ctor) -{ - void* q; - - if (p == NULL) { - return NULL; - } - q = ctor(n); - memcpy(q, p, n); - return q; -} - + char* apclib_estrdup(const char* s) { @@ -928,15 +948,6 @@ *string = NULL; } -/* expandbuf: resize buffer to be at least minsize bytes in length */ -static void apclib_expandbuf(char** bufptr, int* cursize, int minsize) -{ - while (*cursize < minsize) { - *cursize *= GROW_FACTOR; - } - *bufptr = (char*) realloc(*bufptr, *cursize); -} - int apclib_alignword_int(int x) { @@ -949,6 +960,8 @@ /* NO IDEA WHAT THIS STUFF IS ABOUT - probably needs sorting out... +-- it's only used in defered class declarations - which shouldnt really be supported */ + /* namearray_t is used to record deferred inheritance relationships */ typedef struct namearray_t namearray_t; @@ -959,17 +972,7 @@ int size; /* physical size of strings */ }; -/* namearray_dtor: used to clean up deferred_inheritance table (see below) */ -static void namearray_dtor(void* p) -{ - namearray_t* na = (namearray_t*) p; - - if (na->strings != 0) { - free(na->strings); - } - free(na); -} - + @@ -988,122 +991,159 @@ static const char* opcodes[] = { - "NOP", /* 0 */ - "ADD", /* 1 */ - "SUB", /* 2 */ - "MUL", /* 3 */ - "DIV", /* 4 */ - "MOD", /* 5 */ - "SL", /* 6 */ - "SR", /* 7 */ - "CONCAT", /* 8 */ - "BW_OR", /* 9 */ - "BW_AND", /* 10 */ - "BW_XOR", /* 11 */ - "BW_NOT", /* 12 */ - "BOOL_NOT", /* 13 */ - "BOOL_XOR", /* 14 */ - "IS_IDENTICAL", /* 15 */ - "IS_NOT_IDENTICAL", /* 16 */ - "IS_EQUAL", /* 17 */ - "IS_NOT_EQUAL", /* 18 */ - "IS_SMALLER", /* 19 */ - "IS_SMALLER_OR_EQUAL", /* 20 */ - "CAST", /* 21 */ - "QM_ASSIGN", /* 22 */ - "ASSIGN_ADD", /* 23 */ - "ASSIGN_SUB", /* 24 */ - "ASSIGN_MUL", /* 25 */ - "ASSIGN_DIV", /* 26 */ - "ASSIGN_MOD", /* 27 */ - "ASSIGN_SL", /* 28 */ - "ASSIGN_SR", /* 29 */ - "ASSIGN_CONCAT", /* 30 */ - "ASSIGN_BW_OR", /* 31 */ - "ASSIGN_BW_AND", /* 32 */ - "ASSIGN_BW_XOR", /* 33 */ - "PRE_INC", /* 34 */ - "PRE_DEC", /* 35 */ - "POST_INC", /* 36 */ - "POST_DEC", /* 37 */ - "ASSIGN", /* 38 */ - "ASSIGN_REF", /* 39 */ - "ECHO", /* 40 */ - "PRINT", /* 41 */ - "JMP", /* 42 */ - "JMPZ", /* 43 */ - "JMPNZ", /* 44 */ - "JMPZNZ", /* 45 */ - "JMPZ_EX", /* 46 */ - "JMPNZ_EX", /* 47 */ - "CASE", /* 48 */ - "SWITCH_FREE", /* 49 */ - "BRK", /* 50 */ - "CONT", /* 51 */ - "BOOL", /* 52 */ - "INIT_STRING", /* 53 */ - "ADD_CHAR", /* 54 */ - "ADD_STRING", /* 55 */ - "ADD_VAR", /* 56 */ - "BEGIN_SILENCE", /* 57 */ - "END_SILENCE", /* 58 */ - "INIT_FCALL_BY_NAME", /* 59 */ - "DO_FCALL", /* 60 */ - "DO_FCALL_BY_NAME", /* 61 */ - "RETURN", /* 62 */ - "RECV", /* 63 */ - "RECV_INIT", /* 64 */ - "SEND_VAL", /* 65 */ - "SEND_VAR", /* 66 */ - "SEND_REF", /* 67 */ - "NEW", /* 68 */ - "JMP_NO_CTOR", /* 69 */ - "FREE", /* 70 */ - "INIT_ARRAY", /* 71 */ - "ADD_ARRAY_ELEMENT", /* 72 */ - "INCLUDE_OR_EVAL", /* 73 */ - "UNSET_VAR", /* 74 */ - "UNSET_DIM_OBJ", /* 75 */ - "ISSET_ISEMPTY", /* 76 */ - "FE_RESET", /* 77 */ - "FE_FETCH", /* 78 */ - "EXIT", /* 79 */ - "FETCH_R", /* 80 */ - "FETCH_DIM_R", /* 81 */ - "FETCH_OBJ_R", /* 82 */ - "FETCH_W", /* 83 */ - "FETCH_DIM_W", /* 84 */ - "FETCH_OBJ_W", /* 85 */ - "FETCH_RW", /* 86 */ - "FETCH_DIM_RW", /* 87 */ - "FETCH_OBJ_RW", /* 88 */ - "FETCH_IS", /* 89 */ - "FETCH_DIM_IS", /* 90 */ - "FETCH_OBJ_IS", /* 91 */ - "FETCH_FUNC_ARG", /* 92 */ - "FETCH_DIM_FUNC_ARG", /* 93 */ - "FETCH_OBJ_FUNC_ARG", /* 94 */ - "FETCH_UNSET", /* 95 */ - "FETCH_DIM_UNSET", /* 96 */ - "FETCH_OBJ_UNSET", /* 97 */ - "FETCH_DIM_TMP_VAR", /* 98 */ - "FETCH_CONSTANT", /* 99 */ - "DECLARE_FUNCTION_OR_CLASS", /* 100 */ - "EXT_STMT", /* 101 */ - "EXT_FCALL_BEGIN", /* 102 */ - "EXT_FCALL_END", /* 103 */ - "EXT_NOP", /* 104 */ - "TICKS", /* 105 */ - "SEND_VAR_NO_REF", /* 106 */ - "BEGIN_CLASS_DEF", /* 107 */ - "BEGIN_HASH_DEF", /* 108 */ - "OPCODE_ARRAY", /* 109 */ + "NOP", /* 0 */ + "ADD", /* 1 */ + "SUB", /* 2 */ + "MUL", /* 3 */ + "DIV", /* 4 */ + "MOD", /* 5 */ + "SL", /* 6 */ + "SR", /* 7 */ + "CONCAT", /* 8 */ + "BW_OR", /* 9 */ + "BW_AND", /* 10 */ + "BW_XOR", /* 11 */ + "BW_NOT", /* 12 */ + "BOOL_NOT", /* 13 */ + "BOOL_XOR", /* 14 */ + "IS_IDENTICAL", /* 15 */ + "IS_NOT_IDENTICAL", /* 16 */ + "IS_EQUAL", /* 17 */ + "IS_NOT_EQUAL", /* 18 */ + "IS_SMALLER", /* 19 */ + "IS_SMALLER_OR_EQUAL", /* 20 */ + "CAST", /* 21 */ + "QM_ASSIGN", /* 22 */ + "ASSIGN_ADD", /* 23 */ + "ASSIGN_SUB", /* 24 */ + "ASSIGN_MUL", /* 25 */ + "ASSIGN_DIV", /* 26 */ + "ASSIGN_MOD", /* 27 */ + "ASSIGN_SL", /* 28 */ + "ASSIGN_SR", /* 29 */ + "ASSIGN_CONCAT", /* 30 */ + "ASSIGN_BW_OR", /* 31 */ + "ASSIGN_BW_AND", /* 32 */ + "ASSIGN_BW_XOR", /* 33 */ + "PRE_INC", /* 34 */ + "PRE_DEC", /* 35 */ + "POST_INC", /* 36 */ + "POST_DEC", /* 37 */ + "ASSIGN", /* 38 */ + "ASSIGN_REF", /* 39 */ + "ECHO", /* 40 */ + "PRINT", /* 41 */ + "JMP", /* 42 */ + "JMPZ", /* 43 */ + "JMPNZ", /* 44 */ + "JMPZNZ", /* 45 */ + "JMPZ_EX", /* 46 */ + "JMPNZ_EX", /* 47 */ + "CASE", /* 48 */ + "SWITCH_FREE", /* 49 */ + "BRK", /* 50 */ + "CONT", /* 51 */ + "BOOL", /* 52 */ + "INIT_STRING", /* 53 */ + "ADD_CHAR", /* 54 */ + "ADD_STRING", /* 55 */ + "ADD_VAR", /* 56 */ + "BEGIN_SILENCE", /* 57 */ + "END_SILENCE", /* 58 */ + "INIT_FCALL_BY_NAME", /* 59 */ + "DO_FCALL", /* 60 */ + "DO_FCALL_BY_NAME", /* 61 */ + "RETURN", /* 62 */ + "RECV", /* 63 */ + "RECV_INIT", /* 64 */ + "SEND_VAL", /* 65 */ + "SEND_VAR", /* 66 */ + "SEND_REF", /* 67 */ + "NEW", /* 68 */ + "JMP_NO_CTOR", /* 69 */ + "FREE", /* 70 */ + "INIT_ARRAY", /* 71 */ + "ADD_ARRAY_ELEMENT", /* 72 */ + "INCLUDE_OR_EVAL", /* 73 */ + "UNSET_VAR", /* 74 */ + "UNSET_DIM_OBJ", /* 75 */ + "ISSET_ISEMPTY", /* 76 */ + "FE_RESET", /* 77 */ + "FE_FETCH", /* 78 */ + "EXIT", /* 79 */ + "FETCH_R", /* 80 */ + "FETCH_DIM_R", /* 81 */ + "FETCH_OBJ_R", /* 82 */ + "FETCH_W", /* 83 */ + "FETCH_DIM_W", /* 84 */ + "FETCH_OBJ_W", /* 85 */ + "FETCH_RW", /* 86 */ + "FETCH_DIM_RW", /* 87 */ + "FETCH_OBJ_RW", /* 88 */ + "FETCH_IS", /* 89 */ + "FETCH_DIM_IS", /* 90 */ + "FETCH_OBJ_IS", /* 91 */ + "FETCH_FUNC_ARG", /* 92 */ + "FETCH_DIM_FUNC_ARG", /* 93 */ + "FETCH_OBJ_FUNC_ARG", /* 94 */ + "FETCH_UNSET", /* 95 */ + "FETCH_DIM_UNSET", /* 96 */ + "FETCH_OBJ_UNSET", /* 97 */ + "FETCH_DIM_TMP_VAR", /* 98 */ + "FETCH_CONSTANT", /* 99 */ + "DECLARE_FUNCTION_OR_CLASS", /* 100 */ + "EXT_STMT", /* 101 */ + "EXT_FCALL_BEGIN", /* 102 */ + "EXT_FCALL_END", /* 103 */ + "EXT_NOP", /* 104 */ + "TICKS", /* 105 */ + "SEND_VAR_NO_REF", /* 106 */ + + "ZEND_CATCH", /* 107 */ + "ZEND_THROW", /* 108 */ + "ZEND_FETCH_CLASS", /* 109 */ + "ZEND_CLONE", /* 110 */ + "ZEND_INIT_CTOR_CALL", /* 111 */ + "ZEND_INIT_METHOD_CALL", /* 112 */ + "ZEND_INIT_STATIC_METHOD_CALL", /* 113 */ + "ZEND_ISSET_ISEMPTY_VAR", /* 114 */ + "ZEND_ISSET_ISEMPTY_DIM_OBJ", /* 115 */ + "ZEND_IMPORT_FUNCTION", /* 116 */ + "ZEND_IMPORT_CLASS", /* 117 */ + "ZEND_IMPORT_CONST", /* 118 */ + + "**UNKNOWN**", /* 119 */ + "**UNKNOWN**", /* 120 */ + + "ZEND_ASSIGN_ADD_OBJ", /* 121 */ + "ZEND_ASSIGN_SUB_OBJ", /* 122 */ + "ZEND_ASSIGN_MUL_OBJ", /* 123 */ + "ZEND_ASSIGN_DIV_OBJ", /* 124 */ + "ZEND_ASSIGN_MOD_OBJ", /* 125 */ + "ZEND_ASSIGN_SL_OBJ", /* 126 */ + "ZEND_ASSIGN_SR_OBJ", /* 127 */ + "ZEND_ASSIGN_CONCAT_OBJ", /* 128 */ + "ZEND_ASSIGN_BW_OR_OBJ", /* 129 */ + "END_ASSIGN_BW_AND_OBJ", /* 130 */ + "END_ASSIGN_BW_XOR_OBJ", /* 131 */ + "ZEND_PRE_INC_OBJ", /* 132 */ + "ZEND_PRE_DEC_OBJ", /* 133 */ + "ZEND_POST_INC_OBJ", /* 134 */ + "ZEND_POST_DEC_OBJ", /* 135 */ + "ZEND_ASSIGN_OBJ", /* 136 */ + "ZEND_MAKE_VAR", /* 137 */ + + + + + "BEGIN_HASH_DEF", /* 138 */ + "OPCODE_ARRAY" /* 139 */ }; -#define ZEND_BEGIN_HASH_DEF 108 -#define ZEND_OPCODE_ARRAY 109 +#define ZEND_BEGIN_HASH_DEF 138 +#define ZEND_OPCODE_ARRAY 139 static const int NUM_OPCODES = sizeof(opcodes) / sizeof(opcodes[0]); @@ -1123,74 +1163,29 @@ -/* ---------------------------------------------------------------------------- -* -* STUFF THAT PROBALY NEEDS DELETING. -* -* -* ---------------------------------------------------------------------------- -*/ - - - - - - - -/* inherit: recursively inherit methods from base to all the children + /* inherit: recursively inherit methods from base to all the children * of parent, the children of parent's children, and so on */ - /* -static void apc_inherit(zend_class_entry* base, zend_class_entry* parent, TSRMLS_DC) + +static void bcompiler_inherit(zend_class_entry* base TSRMLS_DC) { - namearray_t* children; // classes derived directly from parent - char* child_name; // name of the ith child of parent - int i; - - - return; - // stuff in here is ignored at present.. - // later - - // children = apc_nametable_retrieve(deferred_inheritance, parent->name); - - if (!children) { + + + zend_class_entry* child; + BCOMPILER_DEBUG(("base: %s",base->name)); + + if (!base->parent) { return; // 'parent' has no children, nothing to do } - - // For each child of parent, resolve the inheritance from base - // to the child. - - for (i = 0; i < children->length; i += strlen(child_name) + 1) { - zend_class_entry* child; - int result; - - child_name = children->strings + i; - - // look up the child class entry - result = zend_hash_find(CG(class_table), child_name, - strlen(child_name) + 1, (void**) &child); - assert(result == SUCCESS); // FIXME: is this correct? - - // child inherits from base - ZEND_DO_INHERITANCE(child, parent); - - // all children of child inherit from base - apc_inherit(parent, child); + child = base->parent; + + while(child) { + BCOMPILER_DEBUG(("child: %s",child->name)); + zend_do_inheritance(base,child); + child = child->parent; } -}*/ - -/* call_inherit */ - -static void apc_call_inherit(char *key, void *data TSRMLS_DC) -{ - zend_class_entry *ce; - - if(zend_hash_find(CG(class_table), key, strlen(key) + 1, (void **) &ce) - == SUCCESS) - { - apc_inherit(ce, ce); - } } + @@ -1203,47 +1198,14 @@ /* ---------------------------------------------------------------------------- * -* START STUFF THAT NEEDS GLOBALS.... +* START STUFF THAT NEEDS GLOBALS.... (eg. TSRMLS_DC) * * * ---------------------------------------------------------------------------- */ - - - - - - - - - - - - - - - - -/* First step in deserialization. Sets the size/position of the - * serialized buffer */ -void apc_init_deserializer(char* input, int size TSRMLS_DC) -{ -} - -/* apc_serialize_debug: prints information about the source and - * destination serialization buffers */ -void apc_serialize_debug(char * string TSRMLS_DC) -{ - BCOMPILER_DEBUG(("%s\n", string)); - //printf( "src=%p, srcpos=%d, srcsize=%d\n", BCOMPILERG(src), BCOMPILERG(srcpos), BCOMPILERG(srcsize)); - //printf( "dst=%p, dstpos=%d, dstsize=%d\n", BCOMPILERG(dst), BCOMPILERG(dstpos), BCOMPILERG(dstsize)); -} - - - - + void apc_serialize_string(char* string TSRMLS_DC) { @@ -1747,7 +1709,7 @@ } -/* type: zend_overloaded_element */ +/* type: zend_overloaded_element - i dont think these are used!*/ void apc_serialize_zend_overloaded_element(zend_overloaded_element* zoe TSRMLS_DC) @@ -1789,12 +1751,12 @@ - /*apc_serialize_debug("starting adding class :" TSRMLS_CC); */ + BCOMPILER_DEBUG(("adding type : %i\n",zce->type )); SERIALIZE_SCALAR(zce->type, char); apc_serialize_zstring(zce->name, zce->name_length TSRMLS_CC); SERIALIZE_SCALAR(zce->name_length, uint); - /*apc_serialize_debug("done name" TSRMLS_CC); */ + /* Serialize the name of this class's parent class (if it has one) * so that we can perform inheritance during deserialization (see * apc_deserialize_zend_class_entry). */ @@ -1813,7 +1775,7 @@ CALLBACK_ADD_STRING(zce->name, zce->name_length); CALLBACK_END(); /* now callback to class/funct etc. */ - /* apc_serialize_debug("done exists?" TSRMLS_CC); */ + @@ -1840,7 +1802,7 @@ for (i = 0; i < count; i++) { apc_serialize_zend_function_entry(&zce->builtin_functions[i] TSRMLS_CC); } - /* apc_serialize_debug("tail stuff" TSRMLS_CC); */ + SERIALIZE_SCALAR(zce->handle_function_call, void*); SERIALIZE_SCALAR(zce->handle_property_get, void*); SERIALIZE_SCALAR(zce->handle_property_set, void*); @@ -1922,16 +1884,7 @@ */ /* code from zend_do_inheritance - ignores constructor inheritance currenlty? */ if (zce->parent) { - zval *tmp; - zend_function tmp_zend_function; - zend_hash_merge(&zce->default_properties, &zce->parent->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); - zend_hash_merge(&zce->function_table, &zce->parent->function_table, (void (*)(void *)) function_add_ref, &tmp_zend_function, sizeof(zend_function), 0); - if (!zce->handle_property_get) - zce->handle_property_get = zce->parent->handle_property_get; - if (!zce->handle_property_set) - zce->handle_property_set = zce->parent->handle_property_set; - if (!zce->handle_function_call) - zce->handle_function_call = zce->parent->handle_function_call; + bcompiler_inherit(zce); } } @@ -2016,7 +1969,7 @@ void apc_serialize_zend_op(int id, zend_op* zo TSRMLS_DC) { - /* apc_serialize_debug(getOpcodeName(zo->opcode)); */ + //fprintf(stderr, "Outputting %s\n", getOpcodeName(zo->opcode)); CALLBACK_START(zo->opcode); SERIALIZE_SCALAR(zo->opcode, zend_uchar); @@ -2431,82 +2384,7 @@ /* The logic for serialize_class_table and deserialize_class_table * mirror that of the corresponding function_table functions (see * above), with classes in place of functions. */ - -static int store_class_table(void *element, int num_args, va_list args, zend_hash_key *hash_key TSRMLS_DC) -{ - zend_class_entry* zc; - - zc = (zend_class_entry*) element; - - /* do not serialize internal classes */ - if (zc->type == ZEND_INTERNAL_CLASS) { - return 0; - } - - /* serialize differences */ - SERIALIZE_SCALAR(1, char); - apc_serialize_zend_class_entry(zc TSRMLS_CC); - if(zc->parent != NULL) { - //apc_nametable_insert(priv, zc->name, 0); - } - return 0; - -} - -static int store_class_table_ex(void *element, int num_args, va_list args, zend_hash_key *hash_key TSRMLS_DC) -{ - zend_class_entry* zc; - zc = (zend_class_entry*) element; - - /* do not serialize internal classes */ - if (zc->type == ZEND_INTERNAL_CLASS) { - return 0; - } - - /* serialize differences */ - SERIALIZE_SCALAR(1, char); - // apc_serialize_zstring(hash_key->arKey, hash_key->nKeyLength); - apc_serialize_zend_class_entry(zc TSRMLS_CC); - // Think about tracking same-file inheritance - return 0; -} - -void apc_serialize_zend_class_table(HashTable* gct TSRMLS_DC) -{ - zend_hash_apply_with_arguments(gct, store_class_table, 0, NULL); - SERIALIZE_SCALAR(0, char); -} - -int apc_deserialize_zend_class_table(HashTable* gct TSRMLS_DC) -{ - char exists; - int i; - zend_class_entry* zc; - - i = 0; - - DESERIALIZE_SCALAR(&exists, char); - while (exists) { - apc_create_zend_class_entry(&zc TSRMLS_CC); - if (zend_hash_add(gct, zc->name, zc->name_length + 1, - zc, sizeof(zend_class_entry), NULL) == FAILURE) - { - /* This can validly happen. */ - } - /* We may only want to do this insert if zc->parent is NULL */ - //apc_nametable_insert(parental_inheritors, zc->name, NULL); - //apc_nametable_insert(acc, zc->name, 0); - //apc_nametable_insert(priv, zc->name, 0); - DESERIALIZE_SCALAR(&exists, char); - // apc_free_zend_class_entry - if (zc != NULL) - efree(zc); // ADDED BY MPB - i++; - } - return i; -} - - + /*