Yasuo Ohgaki
yohga****@users*****
2002年 8月 3日 (土) 09:38:26 JST
yohgaki 02/08/03 09:38:26 Modified: . Tag: ORIG ChangeLog OBJECTS2_HOWTO ZEND_CHANGES Zend.m4 zend.c zend.h zend_API.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_execute.c zend_execute_API.c zend_extensions.c zend_globals.h zend_hash.c zend_language_parser.y zend_language_scanner.l zend_mm.c zend_object_handlers.c zend_objects_API.c zend_opcode.c zend_operators.c zend_operators.h Log: Recent cvs.php.net changes Revision Changes Path No revision No revision 1.2.2.6 +192 -0 ZendEngine2/ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ChangeLog,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -u -r1.2.2.5 -r1.2.2.6 --- ChangeLog 9 Jul 2002 09:02:24 -0000 1.2.2.5 +++ ChangeLog 3 Aug 2002 00:38:25 -0000 1.2.2.6 @@ -1,3 +1,195 @@ +2002-08-01 stas <stas****@pb1*****> + + * zend_execute.c + zend_hash.c: MFZE1 + +2002-07-30 jason <jason****@pb1*****> + + * zend_compile.c + zend_execute.c + zend_globals.h: MFZE1 global declare + + * zend_compile.c: Fix segfault + +2002-07-30 Andrei Zmievski <andre****@pb1*****> + + * zend_compile.c + zend_compile.h + zend_execute.c + zend_language_parser.y + zend_language_scanner.l + zend_operators.c + zend_operators.h: + - Adding 'is' operator that can be used to check the type of a variable, + or its class. + +2002-07-28 phanto <phant****@pb1*****> + + * OBJECTS2_HOWTO: update the handlers struct + +2002-07-27 Andi Gutmans <andi****@pb1*****> + + * zend_compile.c + zend_execute_API.c: + - Make sure classes are first looked for in the current scope. + - Make sure that during inheritance the global scope is searched if the + - current one doesn't work. + +2002-07-26 Andi Gutmans <andi****@pb1*****> + + * zend_execute.c + zend.c + zend_builtin_functions.c + zend_compile.h: + - Fix problem with debug_backtrace() reported by Stig. We weren't reporting + - global function information because it wasn't available. We have to do + - an additional assignment per-function call so that it'll be available. + - Also don't define the global scope as function name _main_ but leave it + - empty so that frameworks like Pear can decide what they want to do. + +2002-07-25 sniper <snipe****@pb1*****> + + * Zend.m4: Fixed 3 major failures in this test: + + 1. Tests work better when they are actually run.. + 2. When file is opened, it should be closed sometime too. + 3. AC_TRY_RUN cleans after itself (rm -f conftest.*), so it's + good idea to read the values while the file still exists. + + +2002-07-24 Andi Gutmans <andi****@pb1*****> + + * zend_mm.c: - Fix some compile problems with the new configure checks. + +2002-07-24 James Cox <imaje****@pb1*****> + + * Zend.m4 + zend_mm.c: move testing for the alignment values into configure. + + * Zend.m4: ws fixes. + +2002-07-23 Andi Gutmans <andi****@pb1*****> + + * zend_hash.c: - Fix WS. + +2002-07-21 Andi Gutmans <andi****@pb1*****> + + * zend_compile.c: + - Fix bug reported by Sebastian where old constructors didn't work in + - nested classes. + +2002-07-18 derick <deric****@pb1*****> + + * zend.h + zend_extensions.c: - MFZE1 - MacOSX fixes by Marko Karppinen + +2002-07-17 Andi Gutmans <andi****@pb1*****> + + * zend_compile.c: + - Remove code which wasn't supposed to go into the patch. + + * zend_compile.c + zend_language_parser.y: - Rejuggle some code. + +2002-07-17 sniper <snipe****@pb1*****> + + * ZEND_CHANGES: This was mentioned already above (with an example too :) + +2002-07-16 Andi Gutmans <andi****@pb1*****> + + * ZEND_CHANGES: - Before I forget to list it, this was also added. + + * zend_language_scanner.l: + - Syntactic sugar - Add "public" as a synonym for "var". + - Now we have the three P's. + You can do: + + <? + class MyClass { + public $a; + private $b; + protected $c; + } + + ?> + +2002-07-15 derick <deric****@pb1*****> + + * zend_operators.c: - MFH of the crap removal + +2002-07-15 Andi Gutmans <andi****@pb1*****> + + * ZEND_CHANGES + zend.c + zend.h + zend_API.c + zend_compile.c + zend_language_parser.y + zend_language_scanner.l + zend_opcode.c: + - Commit patch to support protected member variables (by Timm Friebe w/ + - some fixes by me). + - You can't access protected variables from outside the object. If you want + - to see a protected member from your ancestors you need to declare the + - member as protected in the class you want to use it in. You can't + - redeclare a protected variable as private nor the other way around. + + * zend_operators.c: + - Really implement bool increment/decrement as flip-flop. + +2002-07-14 Andi Gutmans <andi****@pb1*****> + + * zend_compile.c + zend_compile.h + zend_execute.c + zend_language_parser.y + zend_language_scanner.l + ZEND_CHANGES: + - Nuke delete(). It was a big mistake to introduce it and I finally + - understand why Java didn't do so. + - If you still want to control destruction of your object then either make + - sure you kill all references or create a destruction method which you + - call yourself. + + * zend_execute.c: - Nuke some unused code + +2002-07-14 derick <deric****@pb1*****> + + * zend_operators.c: MFZE1 + + * zend_operators.c: - MFZE1 + +2002-07-07 Andi Gutmans <andi****@zend*****> + + * zend_objects_API.c: - Path which should improve previous fix. + + * zend_objects_API.c: + - First try at solving problem with different objects being allocated the + - same id. + +2002-07-07 Stanislav Malyshev <stas****@zend*****> + + * zend_object_handlers.c: name length should be strlen+1 + +2002-07-07 Sebastian Bergmann <sb****@sebas*****> + + * zend_language_parser.y: + Allow for 'class Namespace::Bar extends Foo' syntax. Patch by Timm Friebe <theki****@theki*****>. + +2002-07-06 Andi Gutmans <andi****@zend*****> + + * zend_execute.c: + - Fix problem where scope was lost in nested function calls. + - Thanks to Timm Friebe for diving into this one. + +2002-07-06 Zeev Suraski <zeev****@zend*****> + + * zend_language_parser.y: spelling fix + +2002-07-05 Stig Bakken <ssb****@fast*****> + + * zend_builtin_functions.c: * folding fixes + 2002-07-01 Andi Gutmans <andi****@zend*****> * zend_compile.c: - Fix bug when acccessing $this not in class scope. 1.2.2.1 +3 -0 ZendEngine2/OBJECTS2_HOWTO Index: OBJECTS2_HOWTO =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/OBJECTS2_HOWTO,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- OBJECTS2_HOWTO 29 Apr 2002 02:25:26 -0000 1.2 +++ OBJECTS2_HOWTO 3 Aug 2002 00:38:25 -0000 1.2.2.1 @@ -135,6 +135,7 @@ zend_object_get_method_t get_method; zend_object_call_method_t call_method; zend_object_get_constructor_t get_constructor; + zend_object_get_class_entry_t get_class_entry; zend_object_get_class_name_t get_class_name; zend_object_compare_t compare_objects; } zend_object_handlers; @@ -184,6 +185,8 @@ for any other PHP internal function). get_constructor - get description for the object constructor method + +get_class_entry - should return the class entry get_class_name - get the name of the class the object belongs to 1.2.2.3 +26 -20 ZendEngine2/ZEND_CHANGES Index: ZEND_CHANGES =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ZEND_CHANGES,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- ZEND_CHANGES 9 Jul 2002 09:02:24 -0000 1.2.2.2 +++ ZEND_CHANGES 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -19,39 +19,58 @@ the box or after a very small amount of modifications would be high. - * Private Members. + * Private and Protected Members. - The Zend Engine 2.0 introduces private member variables. Note - that for performance reasons no error message is emitted in - case of an illegal access to a private member variable. + The Zend Engine 2.0 introduces private and protected member variables. + Note that for performance reasons no error message is emitted in + case of an illegal access to a private or protectecd member variable. Example: <?php class MyClass { private $Hello = "Hello, World!\n"; + protected $Bar = "Hello, Foo!\n"; + protected $Foo = "Hello, Bar!\n"; function printHello() { - print $this->Hello; + print "MyClass::printHello() ".$this->Hello; + print "MyClass::printHello() ".$this->Bar; + print "MyClass::printHello() ".$this->Foo; } } class MyClass2 extends MyClass { + protected $Foo; + function printHello() { MyClass::printHello(); /* Should print */ - print $this->Hello; /* Shouldn't print out anything */ + print "MyClass2::printHello() ".$this->Hello; /* Shouldn't print out anything */ + print "MyClass2::printHello() ".$this->Bar; /* Shouldn't print (not declared)*/ + print "MyClass2::printHello() ".$this->Foo; /* Should print */ } } $obj = new MyClass(); print $obj->Hello; /* Shouldn't print out anything */ + print $obj->Bar; /* Shouldn't print out anything */ + print $obj->Foo; /* Shouldn't print out anything */ $obj->printHello(); /* Should print */ $obj = new MyClass2(); print $obj->Hello; /* Shouldn't print out anything */ + print $obj->Bar; /* Shouldn't print out anything */ + print $obj->Foo; /* Shouldn't print out anything */ $obj->printHello(); ?> - + + Protected member variables can be accessed in classes extending the class + they are declared in, whereas private member variables can only be accessed + by the class they belong to. + + Note: Protected member variables have to be declared in every class they + are used! + * Object Cloning. The Zend Engine 1.0 offered no way a user could decide what copy @@ -120,19 +139,6 @@ print $obj->name . "\n"; print $obj->address . "\n"; ?> - - * Forced deletion of objects. - - The Zend Engine 1.0 had no means to force deletion of an object - if there are still references to it. The newly introduced delete - statement calls the object's destructor and frees it even if the - object is referenced by some other places in the engine. Other - references to the deleted object become stale and trying to - access them results in a fatal error. - - Note that if you have a user-defined function delete() in an old - script, this script will yield a parser error with the Zend - Engine 2.0, since 'delete' is now a reserved word. * Nested classes (namespaces). 1.2.2.2 +47 -17 ZendEngine2/Zend.m4 Index: Zend.m4 =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Zend.m4,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- Zend.m4 9 Jul 2002 09:02:24 -0000 1.2.2.1 +++ Zend.m4 3 Aug 2002 00:38:25 -0000 1.2.2.2 @@ -1,5 +1,5 @@ dnl -dnl $Id: Zend.m4,v 1.31 2002/06/24 16:10:33 sebastian Exp $ +dnl $Id: Zend.m4,v 1.34 2002/07/25 23:55:06 sniper Exp $ dnl dnl This file contains Zend specific autoconf functions. dnl @@ -77,7 +77,6 @@ AC_CHECK_TYPE( uint, unsigned int ) AC_CHECK_TYPE( ulong, unsigned long ) - dnl Checks for library functions. AC_FUNC_VPRINTF AC_FUNC_MEMCMP @@ -91,10 +90,6 @@ ]) - - - - AC_DEFUN(LIBZEND_ENABLE_DEBUG,[ AC_ARG_ENABLE(debug, @@ -106,17 +101,6 @@ ]) - - - - - - - - - - - AC_DEFUN(LIBZEND_OTHER_CHECKS,[ AC_ARG_ENABLE(experimental-zts, @@ -192,6 +176,52 @@ AC_C_INLINE AC_SUBST(INLINE_CFLAGS) + + +dnl test and set the alignment define for ZEND_MM +dnl this also does the logarithmic test for ZEND_MM. +AC_MSG_CHECKING(for MM alignment and log values) + +AC_TRY_RUN([ +#include <stdio.h> + +typedef union _mm_align_test { + void *ptr; + double dbl; + long lng; +} mm_align_test; + +#if (defined (__GNUC__) && __GNUC__ >= 2) +#define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test)) +#else +#define ZEND_MM_ALIGNMENT (sizeof(mm_align_test)) +#endif + +int main() +{ + int i = ZEND_MM_ALIGNMENT; + int zeros = 0; + FILE *fp; + + while (i & ~0x1) { + zeros++; + i = i >> 1; + } + + fp = fopen("conftest.zend", "w"); + fprintf(fp, "%d %d", ZEND_MM_ALIGNMENT, zeros); + fclose(fp); + + exit(0); +} +], [ + LIBZEND_MM_ALIGN=`cat conftest.zend | cut -d ' ' -f 1` + LIBZEND_MM_ALIGN_LOG2=`cat conftest.zend | cut -d ' ' -f 2` + AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT, $LIBZEND_MM_ALIGN, [ ]) + AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT_LOG2, $LIBZEND_MM_ALIGN_LOG2, [ ]) +]) + +AC_MSG_RESULT(done) ]) 1.2.2.3 +2 -8 ZendEngine2/zend.c Index: zend.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend.c 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend.c 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -254,6 +254,7 @@ zend_standard_class_def->parent = NULL; zend_hash_init_ex(&zend_standard_class_def->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0); zend_hash_init_ex(&zend_standard_class_def->private_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0); + zend_hash_init_ex(&zend_standard_class_def->protected_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0); zend_standard_class_def->static_members = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init_ex(zend_standard_class_def->static_members, 0, NULL, ZVAL_PTR_DTOR, 1, 0); zend_hash_init_ex(&zend_standard_class_def->constants_table, 0, NULL, ZVAL_PTR_DTOR, 1, 0); @@ -812,13 +813,7 @@ zend_file_handle *file_handle; zend_op_array *orig_op_array = EG(active_op_array); zval *local_retval=NULL; - zend_execute_data execute_data; - - EX(prev_execute_data) = NULL; - EG(current_execute_data) = &execute_data; - EX(object) = NULL; - EX(opline) = NULL; - + va_start(files, file_count); for (i=0; i<file_count; i++) { file_handle = va_arg(files, zend_file_handle *); @@ -828,7 +823,6 @@ EG(active_op_array) = zend_compile_file(file_handle, ZEND_INCLUDE TSRMLS_CC); zend_destroy_file_handle(file_handle TSRMLS_CC); if (EG(active_op_array)) { - EX(function_state).function = (zend_function *) EG(active_op_array); EG(return_value_ptr_ptr) = retval ? retval : &local_retval; zend_execute(EG(active_op_array) TSRMLS_CC); if (EG(exception)) { 1.2.2.3 +13 -1 ZendEngine2/zend.h Index: zend.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend.h,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend.h 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend.h 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.175 2002/06/29 19:37:10 andi Exp $ */ +/* $Id: zend.h,v 1.177 2002/07/18 11:16:34 derick Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -80,6 +80,17 @@ # include <dlfcn.h> #endif +#if HAVE_MACH_O_DYLD_H +#include <mach-o/dyld.h> + +/* MH_BUNDLE loading functions for Mac OS X / Darwin */ +void *zend_mh_bundle_load (char* bundle_path); +int zend_mh_bundle_unload (void *bundle_handle); +void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name); +const char *zend_mh_bundle_error(void); + +#endif /* HAVE_MACH_O_DYLD_H */ + #if defined(HAVE_LIBDL) # ifndef RTLD_LAZY @@ -291,6 +302,7 @@ HashTable function_table; HashTable default_properties; HashTable private_properties; /* This is only needed at compile-time */ + HashTable protected_properties; /* This is only needed at compile-time */ HashTable class_table; HashTable *static_members; HashTable constants_table; 1.2.2.3 +1 -0 ZendEngine2/zend_API.c Index: zend_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_API.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend_API.c 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend_API.c 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -1237,6 +1237,7 @@ class_entry->constants_updated = 0; zend_hash_init(&class_entry->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1); zend_hash_init(&class_entry->private_properties, 0, NULL, ZVAL_PTR_DTOR, 1); + zend_hash_init(&class_entry->protected_properties, 0, NULL, ZVAL_PTR_DTOR, 1); class_entry->static_members = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init(class_entry->static_members, 0, NULL, ZVAL_PTR_DTOR, 1); zend_hash_init(&class_entry->constants_table, 0, NULL, ZVAL_PTR_DTOR, 1); 1.2.2.5 +19 -28 ZendEngine2/zend_builtin_functions.c Index: zend_builtin_functions.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- zend_builtin_functions.c 9 Jul 2002 09:02:25 -0000 1.2.2.4 +++ zend_builtin_functions.c 3 Aug 2002 00:38:25 -0000 1.2.2.5 @@ -610,7 +610,7 @@ efree(lcname); RETURN_FALSE; } -/* }}} */ + /* {{{ proto bool is_subclass_of(object object, string class_name) Returns true if the object has this class as one of its parents */ @@ -955,6 +955,7 @@ } RETURN_TRUE; } +/* }}} */ static int copy_class_name(zend_class_entry **pce, int num_args, va_list args, zend_hash_key *hash_key) @@ -1186,6 +1187,7 @@ array_init(return_value); zend_hash_apply_with_argument(EG(zend_constants), (apply_func_arg_t) add_constant_info, return_value TSRMLS_CC); } +/* }}} */ /* {{{ proto void debug_backtrace(void) @@ -1199,10 +1201,11 @@ char *class_name; zend_uint class_name_length; zval *stack_frame; - zend_bool first_time = 1; ptr = EG(current_execute_data); - lineno = ptr->opline->lineno; + + /* Skip debug_backtrace() itself */ + ptr = ptr->prev_execute_data; array_init(return_value); @@ -1220,37 +1223,25 @@ class_name = ptr->function_state.function->common.scope->name; } function_name = ptr->function_state.function->common.function_name; - if (!function_name) { - function_name = "_main_"; - } - - ptr = ptr->prev_execute_data; - if (!ptr) { - zval_ptr_dtor(&stack_frame); - break; - } + + filename = ptr->op_array->filename; + lineno = ptr->opline->lineno; - filename = ptr->function_state.function->op_array.filename; - - if (!first_time) { /* Skip the first context which is debug_backtrace() itself */ + if (function_name) { add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1); - if (class_name) { - add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); - } - add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); - add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); - /* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */ - - add_next_index_zval(return_value, stack_frame); - } else { - first_time = 0; } - - if (ptr->opline) { - lineno = ptr->opline->lineno; + if (class_name) { + add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); } + add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); + add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); + /* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */ + add_next_index_zval(return_value, stack_frame); + + ptr = ptr->prev_execute_data; } } +/* }}} */ /* {{{ proto bool extension_loaded(string extension_name) 1.2.2.2 +111 -34 ZendEngine2/zend_compile.c Index: zend_compile.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_compile.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- zend_compile.c 9 Jul 2002 09:02:25 -0000 1.2.2.1 +++ zend_compile.c 3 Aug 2002 00:38:25 -0000 1.2.2.2 @@ -34,7 +34,6 @@ ZEND_API zend_executor_globals executor_globals; #endif - static void build_runtime_defined_function_key(zval *result, zval *name, zend_op *opline TSRMLS_DC) { char lineno_buf[32]; @@ -919,8 +918,19 @@ op_array.scope = CG(active_class_entry); if (is_method) { + char *short_class_name = CG(active_class_entry)->name; + zend_uint short_class_name_length = CG(active_class_entry)->name_length; + zend_uint i; + + for (i=0; i < CG(active_class_entry)->name_length; i++) { + if (CG(active_class_entry)->name[i] == ':') { + short_class_name = &CG(active_class_entry)->name[i+1]; + short_class_name_length = strlen(short_class_name); + } + } + zend_hash_update(&CG(active_class_entry)->function_table, name, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)); - if ((CG(active_class_entry)->name_length == (uint) name_len) && (!memcmp(CG(active_class_entry)->name, name, name_len))) { + if ((short_class_name_length == name_len) && (!memcmp(short_class_name, name, name_len))) { CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array); } else if ((function_name->u.constant.value.str.len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && (!memcmp(function_name->u.constant.value.str.val, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)))) { CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array); @@ -1151,10 +1161,11 @@ if (!case_sensitive) { zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); } - length = 1 + result->u.constant.value.str.len + class_name->u.constant.value.str.len; + + length = sizeof("::")-1 + result->u.constant.value.str.len + class_name->u.constant.value.str.len; result->u.constant.value.str.val = erealloc(result->u.constant.value.str.val, length+1); - memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len], ":", sizeof(":")-1); - memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len+1], class_name->u.constant.value.str.val, class_name->u.constant.value.str.len+1); + memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len], "::", sizeof("::")-1); + memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len + sizeof("::")-1], class_name->u.constant.value.str.val, class_name->u.constant.value.str.len+1); STR_FREE(class_name->u.constant.value.str.val); result->u.constant.value.str.len = length; } @@ -1499,6 +1510,7 @@ /* Perform inheritance */ zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); + /* STATIC_MEMBERS_FIXME */ zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); @@ -1531,6 +1543,7 @@ zend_hash_init(&new_class_entry->class_table, 10, NULL, ZEND_CLASS_DTOR, 0); zend_hash_init(&new_class_entry->default_properties, 10, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(&new_class_entry->private_properties, 10, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&new_class_entry->protected_properties, 10, NULL, ZVAL_PTR_DTOR, 0); ALLOC_HASHTABLE(new_class_entry->static_members); zend_hash_init(new_class_entry->static_members, 10, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(&new_class_entry->constants_table, 10, NULL, ZVAL_PTR_DTOR, 0); @@ -1651,7 +1664,6 @@ char *class_name, *parent_name; int found_ce; - found_ce = zend_hash_find(class_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, (void **) &pce); /* Restore base class / derived class names */ @@ -1693,6 +1705,7 @@ zend_hash_destroy(&ce->function_table); zend_hash_destroy(&ce->default_properties); zend_hash_destroy(&ce->private_properties); + zend_hash_destroy(&ce->protected_properties); zend_hash_destroy(ce->static_members); zend_hash_destroy(&ce->constants_table); return FAILURE; @@ -1710,7 +1723,7 @@ zend_op *opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1]; HashTable *table; - if (strchr(opline->op2.u.constant.value.str.val, ':')) { + if (opline->op2.op_type != IS_UNUSED && strchr(opline->op2.u.constant.value.str.val, ':')) { return; } if (do_bind_function_or_class(opline, CG(function_table), CG(class_table), 1)==FAILURE) { @@ -2029,6 +2042,7 @@ zend_hash_init(&new_class_entry->class_table, 10, NULL, ZEND_CLASS_DTOR, 0); zend_hash_init(&new_class_entry->default_properties, 10, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(&new_class_entry->private_properties, 10, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&new_class_entry->protected_properties, 10, NULL, ZVAL_PTR_DTOR, 0); ALLOC_HASHTABLE(new_class_entry->static_members); zend_hash_init(new_class_entry->static_members, 10, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(&new_class_entry->constants_table, 10, NULL, ZVAL_PTR_DTOR, 0); @@ -2043,7 +2057,7 @@ new_class_entry->handle_property_get = NULL; /* code for inheritance from parent class */ - if (parent_class_name) { + if (parent_class_name->op_type == IS_CONST) { zend_class_entry *parent_class, **parent_class_p; zend_function tmp_zend_function; zval *tmp; @@ -2052,7 +2066,8 @@ CG(active_ce_parent_class_name).value.str.val = estrndup(parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len); CG(active_ce_parent_class_name).value.str.len = parent_class_name->u.constant.value.str.len; - if (zend_hash_find(CG(active_class_entry)?&CG(active_class_entry)->class_table:CG(class_table), parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len+1, (void **) &parent_class_p)==SUCCESS) { + if ((CG(active_class_entry) && (zend_hash_find(&CG(active_class_entry)->class_table, parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len+1, (void **) &parent_class_p) == SUCCESS)) || + zend_hash_find(CG(class_table), parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len+1, (void **) &parent_class_p) == SUCCESS) { parent_class = *parent_class_p; /* copy functions */ zend_hash_copy(&new_class_entry->function_table, &parent_class->function_table, (copy_ctor_func_t) function_add_ref, &tmp_zend_function, sizeof(zend_function)); @@ -2139,19 +2154,19 @@ } } -void mangle_private_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length) +void mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length) { - char *priv_name; - int priv_name_length; - - priv_name_length = 1 + src1_length + 1 + src2_length; - priv_name = emalloc(priv_name_length+1); - priv_name[0] = '\0'; - memcpy(priv_name + 1, src1, src1_length+1); - memcpy(priv_name + 1 + src1_length + 1, src2, src2_length+1); + char *prop_name; + int prop_name_length; + + prop_name_length = 1 + src1_length + 1 + src2_length; + prop_name = emalloc(prop_name_length+1); + prop_name[0] = '\0'; + memcpy(prop_name + 1, src1, src1_length+1); + memcpy(prop_name + 1 + src1_length + 1, src2, src2_length+1); - *dest = priv_name; - *dest_length = priv_name_length; + *dest = prop_name; + *dest_length = prop_name_length; } void zend_do_declare_property(znode *var_name, znode *value, int declaration_type TSRMLS_DC) @@ -2172,15 +2187,43 @@ { char *priv_name; int priv_name_length; - - mangle_private_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len); + + mangle_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len); zend_hash_update(&CG(active_class_entry)->default_properties, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL); efree(priv_name); property->refcount++; + zend_hash_update(&CG(active_class_entry)->private_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); break; } + case T_PROTECTED: + { + char *prot_name; + int prot_name_length; + zval **found = NULL; + + if (CG(active_class_entry)->parent) { + zend_hash_find(&CG(active_class_entry)->parent->protected_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, (void **) &found); + } + + mangle_property_name(&prot_name, &prot_name_length, "*", 1, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len); + /* If we don't have a value and it exists in our parent then use the parent's value */ + if (!value && found) { + (*found)->refcount++; + zend_hash_update(&CG(active_class_entry)->default_properties, prot_name, prot_name_length+1, found, sizeof(zval *), NULL); + (*found)->refcount++; + zend_hash_update(&CG(active_class_entry)->protected_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, found, sizeof(zval *), NULL); + zval_ptr_dtor(&property); + } else { + zend_hash_update(&CG(active_class_entry)->default_properties, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL); + property->refcount++; + zend_hash_update(&CG(active_class_entry)->protected_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + + } + efree(prot_name); + break; + } case T_VAR: zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); break; @@ -2194,20 +2237,20 @@ FREE_PNODE(var_name); } - void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS_DC) { zend_op opline; zend_llist *fetch_list_ptr; - + zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr); - + if (fetch_list_ptr->count == 1) { zend_llist_element *le; zend_op *opline_ptr; le = fetch_list_ptr->head; opline_ptr = (zend_op *) le->data; + if ((opline_ptr->op1.op_type == IS_CONST) && (opline_ptr->op1.u.constant.type == IS_STRING) && (opline_ptr->op1.u.constant.value.str.len == (sizeof("this")-1)) && !memcmp(opline_ptr->op1.u.constant.value.str.val, "this", sizeof("this"))) { @@ -2215,17 +2258,26 @@ opline_ptr->op1 = *property; SET_UNUSED(opline_ptr->op2); opline_ptr->op2.u.EA.type = ZEND_FETCH_FROM_THIS; - - if (CG(active_class_entry)) { - if ((opline_ptr->op1.op_type == IS_CONST) && zend_hash_exists(&CG(active_class_entry)->private_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { + + if (CG(active_class_entry) && (opline_ptr->op1.op_type == IS_CONST)) { + if (zend_hash_exists(&CG(active_class_entry)->private_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { char *priv_name; int priv_name_length; - - mangle_private_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); + + mangle_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); STR_FREE(opline_ptr->op1.u.constant.value.str.val); opline_ptr->op1.u.constant.value.str.val = priv_name; opline_ptr->op1.u.constant.value.str.len = priv_name_length; + } else if (zend_hash_exists(&CG(active_class_entry)->protected_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { + char *prot_name; + int prot_name_length; + + mangle_property_name(&prot_name, &prot_name_length, "*", 1, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); + + STR_FREE(opline_ptr->op1.u.constant.value.str.val); + opline_ptr->op1.u.constant.value.str.val = prot_name; + opline_ptr->op1.u.constant.value.str.len = prot_name_length; } } *result = opline_ptr->result; @@ -2239,7 +2291,7 @@ opline.result.u.EA.type = 0; opline.result.u.var = get_temporary_variable(CG(active_op_array)); opline.op1 = *object; - opline. op2 = *property; + opline.op2 = *property; *result = opline.result; zend_llist_add_element(fetch_list_ptr, &opline); @@ -2625,7 +2677,7 @@ } -void zend_do_unset(znode *variable, int type TSRMLS_DC) +void zend_do_unset(znode *variable TSRMLS_DC) { zend_op *last_op; @@ -2643,7 +2695,6 @@ break; } - last_op->extended_value = type; } @@ -2673,6 +2724,28 @@ } +void zend_do_is_type(znode *result, znode *expr, znode *class, int type TSRMLS_DC) +{ + zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + + opline->opcode = ZEND_IS_TYPE; + opline->result.op_type = IS_TMP_VAR; + opline->result.u.var = get_temporary_variable(CG(active_op_array)); + opline->op1 = *expr; + + if (class) { + opline->op2 = *class; + opline->extended_value = 1; + } else { + opline->op2.u.constant.value.lval = type; + SET_UNUSED(opline->op2); + opline->extended_value = 0; + } + + *result = opline->result; +} + + void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable TSRMLS_DC) { zend_op *opline; @@ -2791,6 +2864,7 @@ void zend_do_declare_begin(TSRMLS_D) { zend_stack_push(&CG(declare_stack), &CG(declarables), sizeof(zend_declarables)); + CG(declarables).beginop = get_next_op_number(CG(active_op_array)); } @@ -2811,7 +2885,10 @@ zend_declarables *declarables; zend_stack_top(&CG(declare_stack), (void **) &declarables); - CG(declarables) = *declarables; + /* We should restore if there was more than (current - start) - (ticks?1:0) opcodes */ + if ((get_next_op_number(CG(active_op_array)) - CG(declarables).beginop) - ((CG(declarables).ticks.value.lval)?1:0)) { + CG(declarables) = *declarables; + } } 1.2.2.2 +7 -2 ZendEngine2/zend_compile.h Index: zend_compile.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_compile.h,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- zend_compile.h 9 May 2002 04:08:37 -0000 1.2.2.1 +++ zend_compile.h 3 Aug 2002 00:38:25 -0000 1.2.2.2 @@ -188,6 +188,7 @@ zend_function_state function_state; zend_function *fbc; /* Function Being Called */ zend_function *fbc_constructor; + zend_op_array *op_array; zval *object; union _temp_variable *Ts; zend_bool original_in_execution; @@ -354,9 +355,11 @@ void zend_do_cast(znode *result, znode *expr, int type TSRMLS_DC); void zend_do_include_or_eval(int type, znode *result, znode *op1 TSRMLS_DC); -void zend_do_unset(znode *variable, int type TSRMLS_DC); +void zend_do_unset(znode *variable TSRMLS_DC); void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC); +void zend_do_is_type(znode *result, znode *expr, znode *class, int type TSRMLS_DC); + void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable TSRMLS_DC); void zend_do_foreach_cont(znode *value, znode *key, znode *as_token TSRMLS_DC); void zend_do_foreach_end(znode *foreach_token, znode *open_brackets_token TSRMLS_DC); @@ -594,6 +597,9 @@ #define ZEND_ASSIGN_OBJ 136 #define ZEND_MAKE_VAR 137 + +#define ZEND_IS_TYPE 138 + /* end of block */ @@ -623,7 +629,6 @@ /* unset types */ #define ZEND_UNSET_REG 0 -#define ZEND_UNSET_OBJ 1 /* var status for backpatching */ #define BP_VAR_R 0 1.2.2.3 +27 -89 ZendEngine2/zend_execute.c Index: zend_execute.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend_execute.c 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend_execute.c 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -123,35 +123,6 @@ return NULL; } -static inline zval *_get_object_zval_ptr(znode *node, temp_variable *Ts, int *should_free TSRMLS_DC) -{ - switch(node->op_type) { - case IS_TMP_VAR: - *should_free = 1; - return &Ts[node->u.var].tmp_var; - break; - case IS_VAR: - if (Ts[node->u.var].var.ptr_ptr) { - PZVAL_UNLOCK(*Ts[node->u.var].var.ptr_ptr); - *should_free = 0; - return *Ts[node->u.var].var.ptr_ptr; - } else { - if (Ts[node->u.var].EA.type==IS_STRING_OFFSET) { - PZVAL_UNLOCK(Ts[node->u.var].EA.data.str_offset.str); - } - *should_free = 1; - return NULL; - } - break; - case IS_UNUSED: - return NULL; - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - return NULL; -} - - static inline zval **_get_zval_ptr_ptr(znode *node, temp_variable *Ts TSRMLS_DC) { if (node->op_type==IS_VAR) { @@ -820,7 +791,11 @@ zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) retval); + if (zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) retval) == FAILURE) { + zend_error(E_WARNING, "Cannot add element to the array as the nexxt element is already occupied"); + *retval = &EG(uninitialized_zval_ptr); + new_zval->refcount--; + } } else { *retval = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, type TSRMLS_CC); } @@ -1139,6 +1114,7 @@ EX(fbc) = NULL; EX(object) = NULL; EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable)*op_array->T); + EX(op_array) = op_array; EX(original_in_execution) = EG(in_execution); EX(prev_execute_data) = EG(current_execute_data); EG(current_execute_data) = &execute_data; @@ -1864,7 +1840,7 @@ } case ZEND_INIT_CTOR_CALL: { - zend_ptr_stack_n_push(&EG(arg_types_stack), 2, EX(fbc), EX(object)); + zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope)); if (EX(opline)->op1.op_type == IS_VAR) { SELECTIVE_PZVAL_LOCK(*EX(Ts)[EX(opline)->op1.u.var].var.ptr_ptr, &EX(opline)->op1); @@ -1901,7 +1877,7 @@ char *function_name_strval; int function_name_strlen; - zend_ptr_stack_n_push(&EG(arg_types_stack), 2, EX(fbc), EX(object)); + zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope)); function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); function_name_strval = function_name->value.str.val; @@ -1958,7 +1934,7 @@ char *function_name_strval; int function_name_strlen; - zend_ptr_stack_n_push(&EG(arg_types_stack), 2, EX(fbc), EX(object)); + zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope)); is_const = (EX(opline)->op2.op_type == IS_CONST); @@ -2007,7 +1983,7 @@ char *function_name_strval; int function_name_strlen; - zend_ptr_stack_n_push(&EG(arg_types_stack), 2, EX(fbc), EX(object)); + zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope)); is_const = (EX(opline)->op2.op_type == IS_CONST); @@ -2058,7 +2034,7 @@ case ZEND_DO_FCALL: { zval *fname = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); - zend_ptr_stack_push(&EG(arg_types_stack), EX(object)); + zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope)); do { if (EG(scope)) { @@ -2161,11 +2137,8 @@ zval_ptr_dtor(&EX(Ts)[EX(opline)->result.u.var].var.ptr); } } - if (EX(opline)->opcode == ZEND_DO_FCALL_BY_NAME) { - zend_ptr_stack_n_pop(&EG(arg_types_stack), 2, &EX(object), &EX(fbc)); - } else { - EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack)); - } + zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object), &EX(fbc)); + EX(function_state).function = (zend_function *) op_array; EG(function_state_ptr) = &EX(function_state); zend_ptr_stack_clear_multiple(TSRMLS_C); @@ -2787,11 +2760,7 @@ case ZEND_UNSET_VAR: { zval tmp, *variable = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); - zval **object; - zend_bool unset_object; - - unset_object = (EX(opline)->extended_value == ZEND_UNSET_OBJ); if (variable->type != IS_STRING) { tmp = *variable; zval_copy_ctor(&tmp); @@ -2799,16 +2768,6 @@ variable = &tmp; } - if (unset_object) { - if (zend_hash_find(EG(active_symbol_table), variable->value.str.val, variable->value.str.len+1, (void **)&object) == FAILURE) { - zend_error(E_ERROR, "Cannot delete non-existing object"); - } - if (Z_TYPE_PP(object) != IS_OBJECT) { - zend_error(E_ERROR, "Cannot call delete on non-object type"); - } - Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC); - } - zend_hash_del(EG(active_symbol_table), variable->value.str.val, variable->value.str.len+1); if (variable == &tmp) { @@ -2820,10 +2779,6 @@ case ZEND_UNSET_DIM_OBJ: { zval **container = get_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), BP_VAR_R); zval *offset = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); - zend_bool unset_object; - zval **object; - - unset_object = (EX(opline)->extended_value == ZEND_UNSET_OBJ); if (container) { HashTable *ht; @@ -2850,44 +2805,14 @@ } else { index = offset->value.lval; } - - if (unset_object) { - if (zend_hash_index_find(ht, index, (void **)&object) == FAILURE) { - zend_error(E_ERROR, "Cannot delete non-existing object"); - } - if (Z_TYPE_PP(object) != IS_OBJECT) { - zend_error(E_ERROR, "Cannot call delete on non-object type"); - } - Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC); - } zend_hash_index_del(ht, index); break; } case IS_STRING: - if (unset_object) { - if (zend_hash_find(ht, offset->value.str.val, offset->value.str.len+1, (void **)&object) == FAILURE) { - zend_error(E_ERROR, "Cannot delete non-existing object"); - } - if (Z_TYPE_PP(object) != IS_OBJECT) { - zend_error(E_ERROR, "Cannot call delete on non-object type"); - } - Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC); - } - zend_hash_del(ht, offset->value.str.val, offset->value.str.len+1); break; case IS_NULL: - if (unset_object) { - if (zend_hash_find(ht, "", sizeof(""), (void **)&object) == FAILURE) { - zend_error(E_ERROR, "Cannot delete non-existing object"); - } - if (Z_TYPE_PP(object) != IS_OBJECT) { - zend_error(E_ERROR, "Cannot call delete on non-object type"); - } - Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC); - } - zend_hash_del(ht, "", sizeof("")); break; default: @@ -3187,11 +3112,24 @@ do_bind_function_or_class(EX(opline), EG(function_table), EG(class_table), 0); NEXT_OPCODE(); case ZEND_TICKS: - if (++EG(ticks_count)==EX(opline)->op1.u.constant.value.lval) { + if (++EG(ticks_count)>=EX(opline)->op1.u.constant.value.lval) { EG(ticks_count)=0; if (zend_ticks_function) { zend_ticks_function(EX(opline)->op1.u.constant.value.lval); } + } + NEXT_OPCODE(); + case ZEND_IS_TYPE: { + zval *expr = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); + if (EX(opline)->extended_value) { + is_type_function(&EX(Ts)[EX(opline)->result.u.var].tmp_var, expr, + EX(Ts)[EX(opline)->op2.u.var].EA.class_entry, 0 TSRMLS_CC); + } else { + is_type_function(&EX(Ts)[EX(opline)->result.u.var].tmp_var, expr, + NULL, EX(opline)->op2.u.constant.value.lval TSRMLS_CC); + } + + FREE_OP(EX(Ts), &EX(opline)->op1, EG(free_op1)); } NEXT_OPCODE(); case ZEND_EXT_NOP: 1.2.2.3 +5 -0 ZendEngine2/zend_execute_API.c Index: zend_execute_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute_API.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend_execute_API.c 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend_execute_API.c 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -645,6 +645,11 @@ zval *retval_ptr; int retval; + if (EG(scope)) { + if (zend_hash_find(&EG(scope)->class_table, name, name_length+1, (void **) ce) == SUCCESS) { + return SUCCESS; + } + } if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { return SUCCESS; } 1.2.2.1 +61 -0 ZendEngine2/zend_extensions.c Index: zend_extensions.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_extensions.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- zend_extensions.c 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_extensions.c 3 Aug 2002 00:38:25 -0000 1.2.2.1 @@ -216,3 +216,64 @@ } return NULL; } + +/* + * Support for dynamic loading of MH_BUNDLEs on Darwin / Mac OS X + * + */ + +#if HAVE_MACH_O_DYLD_H + +void *zend_mh_bundle_load(char* bundle_path) +{ + NSObjectFileImage bundle_image; + NSModule bundle_handle; + NSSymbol bundle_init_nssymbol; + void (*bundle_init)(void); + + if (NSCreateObjectFileImageFromFile(bundle_path, &bundle_image) != NSObjectFileImageSuccess) { + return NULL; + } + + bundle_handle = NSLinkModule(bundle_image, bundle_path, NSLINKMODULE_OPTION_PRIVATE); + NSDestroyObjectFileImage(bundle_image); + + /* call the init function of the bundle */ + bundle_init_nssymbol = NSLookupSymbolInModule(bundle_handle, "__init"); + if (bundle_init_nssymbol != NULL) { + bundle_init = NSAddressOfSymbol(bundle_init_nssymbol); + bundle_init(); + } + + return bundle_handle; +} + +int zend_mh_bundle_unload(void *bundle_handle) +{ + NSSymbol bundle_fini_nssymbol; + void (*bundle_fini)(void); + + /* call the fini function of the bundle */ + bundle_fini_nssymbol = NSLookupSymbolInModule(bundle_handle, "__fini"); + if (bundle_fini_nssymbol != NULL) { + bundle_fini = NSAddressOfSymbol(bundle_fini_nssymbol); + bundle_fini(); + } + + return (int) NSUnLinkModule(bundle_handle, NULL); +} + +void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name) +{ + NSSymbol symbol; + symbol = NSLookupSymbolInModule(bundle_handle, symbol_name); + return NSAddressOfSymbol(symbol); +} + +const char *zend_mh_bundle_error(void) +{ + /* Witness the state of the art error reporting */ + return NULL; +} + +#endif /* HAVE_MACH_O_DYLD_H */ 1.2.2.3 +1 -0 ZendEngine2/zend_globals.h Index: zend_globals.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_globals.h,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend_globals.h 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend_globals.h 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -58,6 +58,7 @@ typedef struct _zend_declarables { zval ticks; + zend_uint beginop; } zend_declarables; 1.2.2.1 +4 -4 ZendEngine2/zend_hash.c Index: zend_hash.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_hash.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- zend_hash.c 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_hash.c 3 Aug 2002 00:38:25 -0000 1.2.2.1 @@ -84,7 +84,7 @@ if (ht->inconsistent==HT_OK) { return; } - switch (ht->inconsistent) { + switch (ht->inconsistent) { case HT_IS_DESTROYING: zend_output_debug_string(1, "%s(%d) : ht=0x%08x is being destroyed", file, line, ht); break; @@ -94,7 +94,7 @@ case HT_CLEANING: zend_output_debug_string(1, "%s(%d) : ht=0x%08x is being cleaned", file, line, ht); break; - } + } zend_bailout(); } #define IS_CONSISTENT(a) _zend_is_inconsistent(a, __FILE__, __LINE__); @@ -393,7 +393,7 @@ } UPDATE_DATA(ht, p, pData, nDataSize); HANDLE_UNBLOCK_INTERRUPTIONS(); - if (h >= ht->nNextFreeElement) { + if ((long)h >= (long)ht->nNextFreeElement) { ht->nNextFreeElement = h + 1; } if (pDest) { @@ -421,7 +421,7 @@ CONNECT_TO_GLOBAL_DLLIST(p, ht); HANDLE_UNBLOCK_INTERRUPTIONS(); - if (h >= ht->nNextFreeElement) { + if ((long)h >= (long)ht->nNextFreeElement) { ht->nNextFreeElement = h + 1; } ht->nNumOfElements++; 1.2.2.2 +34 -17 ZendEngine2/zend_language_parser.y Index: zend_language_parser.y =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_language_parser.y,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- zend_language_parser.y 9 Jul 2002 09:02:25 -0000 1.2.2.1 +++ zend_language_parser.y 3 Aug 2002 00:38:25 -0000 1.2.2.2 @@ -67,7 +67,7 @@ %left '*' '/' '%' %right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' %right '[' -%nonassoc T_NEW T_DELETE +%nonassoc T_NEW T_IS_TYPE %token T_EXIT %token T_IF %left T_ELSEIF @@ -94,6 +94,7 @@ %token T_ENDFOREACH %token T_DECLARE %token T_ENDDECLARE +%token T_IS_TYPE %token T_AS %token T_SWITCH %token T_ENDSWITCH @@ -112,6 +113,7 @@ %token T_GLOBAL %token T_STATIC %token T_PRIVATE +%token T_PROTECTED %token T_VAR %token T_UNSET %token T_ISSET @@ -211,7 +213,6 @@ T_CATCH '(' catch_or_import_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$1, &$8, &$9, 1 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); } additional_catches | T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); } - | T_DELETE variable ';' { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$2, ZEND_UNSET_OBJ TSRMLS_CC); } | T_IMPORT { zend_do_begin_import(TSRMLS_C); } import_rule T_FROM catch_or_import_class_entry { zend_do_end_import(&$5 TSRMLS_CC); } ';' ; @@ -252,7 +253,7 @@ ; unset_variable: - variable { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1, ZEND_UNSET_REG TSRMLS_CC); } + variable { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); } ; use_filename: @@ -271,11 +272,15 @@ '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } | T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type TSRMLS_CC); } parameter_list '(' inner_statement_list ')' ';' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } - | T_CLASS decleration_class_name { zend_do_begin_class_declaration(&$1, &$2, NULL TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); } - | T_CLASS T_STRING T_EXTENDS T_STRING { zend_do_begin_class_declaration(&$1, &$2, &$4 TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); } + | T_CLASS declaration_class_name extends_from { zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); } ; -decleration_class_name: +extends_from: + /* empty */ { $$.op_type = IS_UNUSED; } + | T_EXTENDS T_STRING { $$ = $2; } +; + +declaration_class_name: | parse_class_name_entry T_STRING { do_fetch_class_name(&$$, &$1, &$2, 0 TSRMLS_CC); } | T_STRING { $$ = $1; zend_str_tolower($$.u.constant.value.str.val, $$.u.constant.value.str.len); } ; @@ -426,14 +431,13 @@ class_statement: - class_variable_decleration ';' - | class_constant_decleration ';' + class_variable_declaration ';' + | class_constant_declaration ';' | T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); } '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } | T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); } parameter_list '(' inner_statement_list ')' ';' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } - | T_CLASS T_STRING { zend_do_begin_class_declaration(&$1, &$2, NULL TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); } - | T_CLASS T_STRING T_EXTENDS T_STRING { zend_do_begin_class_declaration(&$1, &$2, &$4 TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); } + | T_CLASS T_STRING extends_from { zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); } ; is_reference: @@ -441,20 +445,21 @@ | '&' { $$.op_type = ZEND_RETURN_REF; } ; -class_variable_decleration: - class_variable_decleration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL, $1.op_type TSRMLS_CC); } - | class_variable_decleration ',' T_VARIABLE '=' static_scalar { zend_do_declare_property(&$3, &$5, $1.op_type TSRMLS_CC); } - | class_decleration_type T_VARIABLE { $$ = $1; zend_do_declare_property(&$2, NULL, $1.op_type TSRMLS_CC); } - | class_decleration_type T_VARIABLE '=' static_scalar { $$ = $1; zend_do_declare_property(&$2, &$4, $1.op_type TSRMLS_CC); } +class_variable_declaration: + class_variable_declaration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL, $1.op_type TSRMLS_CC); } + | class_variable_declaration ',' T_VARIABLE '=' static_scalar { zend_do_declare_property(&$3, &$5, $1.op_type TSRMLS_CC); } + | class_declaration_type T_VARIABLE { $$ = $1; zend_do_declare_property(&$2, NULL, $1.op_type TSRMLS_CC); } + | class_declaration_type T_VARIABLE '=' static_scalar { $$ = $1; zend_do_declare_property(&$2, &$4, $1.op_type TSRMLS_CC); } ; -class_decleration_type: +class_declaration_type: T_VAR { $$.op_type = T_VAR; } | T_STATIC { $$.op_type = T_STATIC; } | T_PRIVATE { $$.op_type = T_PRIVATE; } + | T_PROTECTED { $$.op_type = T_PROTECTED; } ; -class_constant_decleration: +class_constant_declaration: | T_CONST ',' T_STRING '=' static_scalar { zend_do_declare_property(&$3, &$5, T_CONST TSRMLS_CC); } | T_CONST T_STRING '=' static_scalar { zend_do_declare_property(&$2, &$4, T_CONST TSRMLS_CC); } ; @@ -524,6 +529,14 @@ | expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 TSRMLS_CC); } | expr '>' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); } | expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); } + | expr T_IS_TYPE is_type_expr { zend_do_is_type(&$$, &$1, &$3, 0 TSRMLS_CC); } + | expr T_IS_TYPE T_INT_CAST { zend_do_is_type(&$$, &$1, NULL, IS_LONG TSRMLS_CC); } + | expr T_IS_TYPE T_DOUBLE_CAST { zend_do_is_type(&$$, &$1, NULL, IS_DOUBLE TSRMLS_CC); } + | expr T_IS_TYPE T_STRING_CAST { zend_do_is_type(&$$, &$1, NULL, IS_STRING TSRMLS_CC); } + | expr T_IS_TYPE T_ARRAY_CAST { zend_do_is_type(&$$, &$1, NULL, IS_ARRAY TSRMLS_CC); } + | expr T_IS_TYPE T_OBJECT_CAST { zend_do_is_type(&$$, &$1, NULL, IS_OBJECT TSRMLS_CC); } + | expr T_IS_TYPE T_BOOL_CAST { zend_do_is_type(&$$, &$1, NULL, IS_BOOL TSRMLS_CC); } + | expr T_IS_TYPE T_UNSET_CAST { zend_do_is_type(&$$, &$1, NULL, IS_NULL TSRMLS_CC); } | '(' expr ')' { $$ = $2; } | expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); } expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); } @@ -581,6 +594,10 @@ | r_variable_without_static_member { $$ = $1; } ; +is_type_expr: + parse_class_entry T_STRING { do_fetch_class(&$$, &$1, &$2 TSRMLS_CC); } + | T_STRING { do_fetch_class(&$$, NULL, &$1 TSRMLS_CC); } +; exit_expr: /* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; } 1.2.2.1 +13 -4 ZendEngine2/zend_language_scanner.l Index: zend_language_scanner.l =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_language_scanner.l,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- zend_language_scanner.l 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_language_scanner.l 3 Aug 2002 00:38:25 -0000 1.2.2.1 @@ -555,6 +555,10 @@ return T_ENDDECLARE; } +<ST_IN_SCRIPTING>"is" { + return T_IS_TYPE; +} + <ST_IN_SCRIPTING>"as" { return T_AS; } @@ -625,10 +629,6 @@ return T_NEW; } -<ST_IN_SCRIPTING>"delete" { - return T_DELETE; -} - <ST_IN_SCRIPTING>"var" { return T_VAR; } @@ -712,6 +712,15 @@ <ST_IN_SCRIPTING>"private" { return T_PRIVATE; } + +<ST_IN_SCRIPTING>"protected" { + return T_PROTECTED; +} + +<ST_IN_SCRIPTING>"public" { + return T_VAR; +} + <ST_IN_SCRIPTING>"unset" { return T_UNSET; 1.1.2.2 +5 -16 ZendEngine2/zend_mm.c Index: zend_mm.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_mm.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- zend_mm.c 10 Jul 2002 01:42:50 -0000 1.1.2.1 +++ zend_mm.c 3 Aug 2002 00:38:25 -0000 1.1.2.2 @@ -19,6 +19,7 @@ #include <stdlib.h> #include <string.h> +#include "zend.h" #include "zend_mm.h" #if WIN32|WINNT @@ -34,26 +35,14 @@ #define MAX(a, b) (((a)>(b))?(a):(b)) #endif -/* Platform alignment test */ -typedef union _mm_align_test { - void *ptr; - double dbl; - long lng; -} mm_align_test; - -#if (defined (__GNUC__) && __GNUC__ >= 2) -#define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test)) -#else -#define ZEND_MM_ALIGNMENT (sizeof(mm_align_test)) -#endif - -/* We're going to need some kind of configure test for this */ -#undef ZEND_MM_ALIGNMENT +#ifndef ZEND_MM_ALIGNMENT #define ZEND_MM_ALIGNMENT 8 +#define ZEND_MM_ALIGNMENT_LOG2 3 +#endif #define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-1) -#define ZEND_MM_BUCKET_INDEX(true_size) (true_size >> 3) +#define ZEND_MM_BUCKET_INDEX(true_size) (true_size >> ZEND_MM_ALIGNMENT_LOG2) #define ZEND_MM_GET_FREE_LIST_BUCKET(index, free_list_bucket) \ if (index < ZEND_MM_NUM_BUCKETS) { \ 1.2.2.3 +1 -1 ZendEngine2/zend_object_handlers.c Index: zend_object_handlers.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_object_handlers.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- zend_object_handlers.c 9 Jul 2002 09:02:25 -0000 1.2.2.2 +++ zend_object_handlers.c 3 Aug 2002 00:38:25 -0000 1.2.2.3 @@ -77,7 +77,7 @@ member = &tmp_member; } - if (zend_hash_find(zobj->properties, Z_STRVAL_P(member), Z_STRLEN_P(member), (void **) &variable_ptr) == SUCCESS) { + if (zend_hash_find(zobj->properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &variable_ptr) == SUCCESS) { if (*variable_ptr == EG(error_zval_ptr) || member == EG(error_zval_ptr)) { /* variable_ptr = EG(uninitialized_zval_ptr); */ /* } else if (variable_ptr==&EG(uninitialized_zval) || variable_ptr!=value_ptr) { */ 1.1.2.2 +8 -3 ZendEngine2/zend_objects_API.c Index: zend_objects_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_objects_API.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- zend_objects_API.c 10 Jul 2002 01:42:50 -0000 1.1.2.1 +++ zend_objects_API.c 3 Aug 2002 00:38:25 -0000 1.1.2.2 @@ -115,12 +115,17 @@ if (--obj->refcount == 0) { if (EG(objects_store).object_buckets[handle].valid) { - if(obj->dtor && !EG(objects_store).object_buckets[handle].destructor_called) { + if(!EG(objects_store).object_buckets[handle].destructor_called) { EG(objects_store).object_buckets[handle].destructor_called = 1; - obj->dtor(obj->object, handle TSRMLS_CC); + if (obj->dtor) { + obj->dtor(obj->object, handle TSRMLS_CC); + } + EG(objects_store).object_buckets[handle].valid = 0; + if (obj->refcount == 0) { + ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(); + } } } - ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(); #if ZEND_DEBUG_OBJECTS fprintf(stderr, "Deallocated object id #%d\n", handle); #endif 1.2.2.1 +2 -0 ZendEngine2/zend_opcode.c Index: zend_opcode.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_opcode.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- zend_opcode.c 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_opcode.c 3 Aug 2002 00:38:25 -0000 1.2.2.1 @@ -119,6 +119,7 @@ case ZEND_USER_CLASS: zend_hash_destroy(&ce->default_properties); zend_hash_destroy(&ce->private_properties); + zend_hash_destroy(&ce->protected_properties); zend_hash_destroy(ce->static_members); efree(ce->name); zend_hash_destroy(&ce->function_table); @@ -130,6 +131,7 @@ case ZEND_INTERNAL_CLASS: zend_hash_destroy(&ce->default_properties); zend_hash_destroy(&ce->private_properties); + zend_hash_destroy(&ce->protected_properties); zend_hash_destroy(ce->static_members); free(ce->name); zend_hash_destroy(&ce->function_table); 1.2.2.2 +54 -0 ZendEngine2/zend_operators.c Index: zend_operators.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_operators.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- zend_operators.c 9 Jul 2002 09:02:25 -0000 1.2.2.1 +++ zend_operators.c 3 Aug 2002 00:38:25 -0000 1.2.2.2 @@ -1365,6 +1365,60 @@ } +ZEND_API int is_type_function(zval *result, zval *op1, zend_class_entry *class, int type TSRMLS_DC) +{ + if (class) { + if (Z_TYPE_P(op1) == IS_OBJECT) { + zend_class_entry *ce; + for (ce = Z_OBJCE_P(op1); ce != NULL; ce = ce->parent) { + if (ce == class) { + ZVAL_BOOL(result, 1); + return SUCCESS; + } + } + ZVAL_BOOL(result, 0); + } else { + ZVAL_BOOL(result, 0); + } + return SUCCESS; + } + + switch (type) { + case IS_NULL: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_NULL); + break; + + case IS_LONG: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_LONG); + break; + + case IS_DOUBLE: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_DOUBLE); + break; + + case IS_STRING: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_STRING); + break; + + case IS_ARRAY: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_ARRAY); + break; + + case IS_OBJECT: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_OBJECT); + break; + + case IS_BOOL: + ZVAL_BOOL(result, Z_TYPE_P(op1) == IS_BOOL); + break; + + default: + zend_error(E_ERROR, "Unknown operand type"); + return FAILURE; + } + return SUCCESS; +} + #define LOWER_CASE 1 #define UPPER_CASE 2 #define NUMERIC 3 1.2.2.2 +2 -0 ZendEngine2/zend_operators.h Index: zend_operators.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_operators.h,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- zend_operators.h 2 May 2002 15:47:55 -0000 1.2.2.1 +++ zend_operators.h 3 Aug 2002 00:38:25 -0000 1.2.2.2 @@ -58,6 +58,8 @@ ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); +ZEND_API int is_type_function(zval *result, zval *op1, zend_class_entry *ce, int type TSRMLS_DC); + static inline zend_bool is_numeric_string(char *str, int length, long *lval, double *dval, zend_bool allow_errors) { long local_lval;