-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "php.h"
-#include "php_psi.h"
-
-static inline int psi_calc_num_exp_value(num_exp *exp, impl_val *strct, impl_val *res) {
- impl_val *ref, *tmp = NULL;
-
- switch (exp->t) {
- case PSI_T_NUMBER:
- switch (is_numeric_string(exp->u.numb, strlen(exp->u.numb), (zend_long *) res, (double *) res, 0)) {
- case IS_LONG:
- return PSI_T_INT64;
- case IS_DOUBLE:
- return PSI_T_DOUBLE;
- }
- break;
-
- case PSI_T_NSNAME:
- switch (exp->u.cnst->type->type) {
- case PSI_T_INT:
- res->i64 = zend_get_constant_str(exp->u.cnst->name, strlen(exp->u.cnst->name))->value.lval;
- return PSI_T_INT64;
- case PSI_T_FLOAT:
- res->dval = zend_get_constant_str(exp->u.cnst->name, strlen(exp->u.cnst->name))->value.dval;
- return PSI_T_DOUBLE;
- default:
- return 0;
- }
- break;
-
- case PSI_T_NAME:
- if (strct) {
- ref = struct_member_ref(exp->u.dvar->arg, strct, &tmp);
- } else if (exp->u.dvar->arg->let) {
- ref = exp->u.dvar->arg->let->ptr;
- } else {
- ref = exp->u.dvar->arg->ptr;
- }
- switch (real_decl_type(exp->u.dvar->arg->type)->type) {
- case PSI_T_INT8:
- case PSI_T_UINT8:
- case PSI_T_INT16:
- case PSI_T_UINT16:
- case PSI_T_INT32:
- case PSI_T_UINT32:
- case PSI_T_INT64:
- case PSI_T_UINT64:
- memcpy(res, deref_impl_val(ref, exp->u.dvar), sizeof(*res));
- if (tmp) {
- free(tmp);
- }
- return real_decl_type(exp->u.dvar->arg->type)->type;
-
- case PSI_T_FLOAT:
- case PSI_T_DOUBLE:
- memcpy(res, deref_impl_val(ref, exp->u.dvar), sizeof(*res));
- if (tmp) {
- free(tmp);
- }
- return real_decl_type(exp->u.dvar->arg->type)->type;
-
- EMPTY_SWITCH_DEFAULT_CASE();
- }
- break;
-
- EMPTY_SWITCH_DEFAULT_CASE();
- }
- return 0;
-}
-
-int psi_calc_num_exp(num_exp *exp, impl_val *strct, impl_val *res) {
- impl_val num = {0};
- int num_type = psi_calc_num_exp_value(exp, strct, &num);
-
- if (exp->operand) {
- impl_val tmp = {0};
- int tmp_type = psi_calc_num_exp(exp->operand, strct, &tmp);
-
- return exp->calculator(num_type, &num, tmp_type, &tmp, res);
- }
-
- memcpy(res, &num, sizeof(*res));
- return num_type;
-}
+/*******************************************************************************
+ Copyright (c) 2016, Michael Wallner <mike@php.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+
+#include "php_psi_stdinc.h"
+
+#include "token.h"
+#include "calc.h"