home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Magazine / HomeAutomation / Apache / include / php / Zend / zend_execute.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-16  |  5.8 KB  |  233 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | Zend Engine                                                          |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 0.92 of the Zend license,     |
  8.    | that is bundled with this package in the file LICENSE, and is        | 
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.zend.com/license/0_92.txt.                                |
  11.    | If you did not receive a copy of the Zend license and are unable to  |
  12.    | obtain it through the world-wide-web, please send a note to          |
  13.    | license@zend.com so we can mail you a copy immediately.              |
  14.    +----------------------------------------------------------------------+
  15.    | Authors: Andi Gutmans <andi@zend.com>                                |
  16.    |          Zeev Suraski <zeev@zend.com>                                |
  17.    +----------------------------------------------------------------------+
  18. */
  19.  
  20.  
  21. #ifndef _EXECUTE_H
  22. #define _EXECUTE_H
  23.  
  24. #include "zend_compile.h"
  25. #include "zend_hash.h"
  26. #include "zend_variables.h"
  27. #include "zend_execute_locks.h"
  28.  
  29. typedef union _temp_variable {
  30.     zval tmp_var;
  31.     struct {
  32.         zval **ptr_ptr;
  33.         zval *ptr;
  34.     } var;
  35.     struct {
  36.         zval tmp_var; /* a dummy */
  37.  
  38.         union {
  39.             struct {
  40.                 zval *str;
  41.                 int offset;
  42.             } str_offset;
  43.             zend_property_reference overloaded_element;
  44.         } data;
  45.             
  46.         unsigned char type;
  47.     } EA;
  48. } temp_variable;
  49.  
  50.  
  51. ZEND_API extern void (*zend_execute)(zend_op_array *op_array ELS_DC);
  52.  
  53. void init_executor(CLS_D ELS_DC);
  54. void shutdown_executor(ELS_D);
  55. void execute(zend_op_array *op_array ELS_DC);
  56. ZEND_API int zend_is_true(zval *op);
  57. ZEND_API inline void safe_free_zval_ptr(zval *p)
  58. #if defined(C9X_INLINE_SEMANTICS)
  59. {
  60.     ELS_FETCH();
  61.  
  62.     if (p!=EG(uninitialized_zval_ptr)) {
  63.         FREE_ZVAL(p);
  64.     }
  65. }
  66. #else
  67. ;
  68. #endif
  69.  
  70. ZEND_API int zend_eval_string(char *str, zval *retval_ptr CLS_DC ELS_DC);
  71. ZEND_API inline int i_zend_is_true(zval *op)
  72. #if defined(C9X_INLINE_SEMANTICS)
  73. {
  74.     int result;
  75.  
  76.     switch (op->type) {
  77.         case IS_NULL:
  78.             result = 0;
  79.             break;
  80.         case IS_LONG:
  81.         case IS_BOOL:
  82.         case IS_RESOURCE:
  83.             result = (op->value.lval?1:0);
  84.             break;
  85.         case IS_DOUBLE:
  86.             result = (op->value.dval ? 1 : 0);
  87.             break;
  88.         case IS_STRING:
  89.             if (op->value.str.len == 0
  90.                 || (op->value.str.len==1 && op->value.str.val[0]=='0')) {
  91.                 result = 0;
  92.             } else {
  93.                 result = 1;
  94.             }
  95.             break;
  96.         case IS_ARRAY:
  97.             result = (zend_hash_num_elements(op->value.ht)?1:0);
  98.             break;
  99.         case IS_OBJECT:
  100.             result = (zend_hash_num_elements(op->value.obj.properties)?1:0);
  101.             break;
  102.         default:
  103.             result = 0;
  104.             break;
  105.     }
  106.     return result;
  107. }
  108. #else
  109. ;
  110. #endif
  111.  
  112. ZEND_API int zval_update_constant(zval **pp, void *arg);
  113.  
  114. /* dedicated Zend executor functions - do not use! */
  115. ZEND_API inline void zend_ptr_stack_clear_multiple(ELS_D)
  116. #if defined(C9X_INLINE_SEMANTICS)
  117. {
  118.     void **p = EG(argument_stack).top_element-2;
  119.     int delete_count = (ulong) *p;
  120.  
  121.     EG(argument_stack).top -= (delete_count+2);
  122.     while (--delete_count>=0) {
  123.         zval_ptr_dtor((zval **) --p);
  124.     }
  125.     EG(argument_stack).top_element = p;
  126. }
  127. #else
  128. ;
  129. #endif
  130.  
  131. ZEND_API inline int zend_ptr_stack_get_arg(int requested_arg, void **data ELS_DC)
  132. #if defined(C9X_INLINE_SEMANTICS)
  133. {
  134.     void **p = EG(argument_stack).top_element-2;
  135.     int arg_count = (ulong) *p;
  136.  
  137.     if (requested_arg>arg_count) {
  138.         return FAILURE;
  139.     }
  140.     *data = (p-arg_count+requested_arg-1);
  141.     return SUCCESS;
  142. }
  143. #else
  144. ;
  145. #endif
  146.  
  147. #if SUPPORT_INTERACTIVE
  148. void execute_new_code(CLS_D);
  149. #endif
  150.  
  151.  
  152. /* services */
  153. ZEND_API char *get_active_function_name(void);
  154. ZEND_API char *zend_get_executed_filename(ELS_D);
  155. ZEND_API uint zend_get_executed_lineno(ELS_D);
  156. ZEND_API zend_bool zend_is_executing(void);
  157.  
  158. void zend_set_timeout(long seconds);
  159. void zend_unset_timeout(void);
  160. void zend_timeout(int dummy);
  161.  
  162. #ifdef ZEND_WIN32
  163. void zend_init_timeout_thread();
  164. void zend_shutdown_timeout_thread();
  165. #define WM_REGISTER_ZEND_TIMEOUT        (WM_USER+1)
  166. #define WM_UNREGISTER_ZEND_TIMEOUT        (WM_USER+2)
  167. #endif
  168.  
  169. #define zendi_zval_copy_ctor(p) zval_copy_ctor(&(p))
  170. #define zendi_zval_dtor(p) zval_dtor(&(p))
  171.  
  172. #define active_opline (*EG(opline_ptr))
  173.  
  174. ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts ELS_DC)
  175. #if defined(C9X_INLINE_SEMANTICS)
  176. {
  177.     zval *variable_ptr = *variable_ptr_ptr;
  178.     zval *value_ptr;
  179.     
  180.  
  181.     if (!value_ptr_ptr) {
  182.         zend_error(E_ERROR, "Cannot create references to string offsets nor overloaded objects");
  183.         return;
  184.     }
  185.  
  186.     value_ptr = *value_ptr_ptr;
  187.     if (variable_ptr == EG(error_zval_ptr) || value_ptr==EG(error_zval_ptr)) {
  188.         variable_ptr_ptr = &EG(uninitialized_zval_ptr);
  189. /*    } else if (variable_ptr==&EG(uninitialized_zval) || variable_ptr!=value_ptr) { */
  190.     } else if (variable_ptr_ptr != value_ptr_ptr) {
  191.         variable_ptr->refcount--;
  192.         if (variable_ptr->refcount==0) {
  193.             zendi_zval_dtor(*variable_ptr);
  194.             FREE_ZVAL(variable_ptr);
  195.         }
  196.  
  197.         if (!PZVAL_IS_REF(value_ptr)) {
  198.             /* break it away */
  199.             value_ptr->refcount--;
  200.             if (value_ptr->refcount>0) {
  201.                 ALLOC_ZVAL(*value_ptr_ptr);
  202.                 **value_ptr_ptr = *value_ptr;
  203.                 value_ptr = *value_ptr_ptr;
  204.                 zendi_zval_copy_ctor(*value_ptr);
  205.             }
  206.             value_ptr->refcount = 1;
  207.             value_ptr->is_ref = 1;
  208.         }
  209.  
  210.         *variable_ptr_ptr = value_ptr;
  211.         value_ptr->refcount++;
  212.     } else {
  213.         if (variable_ptr->refcount>1) { /* we need to break away */
  214.             SEPARATE_ZVAL(variable_ptr_ptr);
  215.         }
  216.         (*variable_ptr_ptr)->is_ref = 1;
  217.     }
  218.  
  219.     if (result && (result->op_type != IS_UNUSED)) {
  220.         Ts[result->u.var].var.ptr_ptr = variable_ptr_ptr;
  221.         SELECTIVE_PZVAL_LOCK(*variable_ptr_ptr, result);
  222.         AI_USE_PTR(Ts[result->u.var].var);
  223.     }
  224. }
  225. #else
  226. ;
  227. #endif
  228.  
  229. #define IS_OVERLOADED_OBJECT 1
  230. #define IS_STRING_OFFSET 2
  231.  
  232. #endif /* _EXECUTE_H */
  233.