X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcalc.h;h=0c2678cde2daf48ca431443c1aab8bbd34d09b47;hp=db8fd7cc1d7101688342fe595b368d30f24a0601;hb=a7ac1c0a3c855321f21682c127a4b707de33a303;hpb=2f5af21b263403997e154658635d6b6e6eaab453 diff --git a/src/calc.h b/src/calc.h index db8fd7c..0c2678c 100644 --- a/src/calc.h +++ b/src/calc.h @@ -1,33 +1,46 @@ -#ifndef _PSI_CALC_H -#define _PSI_CALC_H - -#include "num_exp.h" -#include "impl_val.h" - -int psi_calc_num_exp(num_exp *exp, impl_val *strct, impl_val *res); - -static inline zend_long psi_long_num_exp(num_exp *exp, impl_val *strct) { - impl_val val = {0}; - - switch (psi_calc_num_exp(exp, strct, &val)) { - case PSI_T_UINT8: return val.u8; - case PSI_T_UINT16: return val.u16; - case PSI_T_UINT32: return val.u32; - case PSI_T_UINT64: return val.u64; /* FIXME */ - case PSI_T_INT8: return val.i8; - case PSI_T_INT16: return val.i16; - case PSI_T_INT32: return val.i32; - case PSI_T_INT64: return val.i64; - case PSI_T_FLOAT: return val.fval; - case PSI_T_DOUBLE: return val.dval; - EMPTY_SWITCH_DEFAULT_CASE(); - } - return 0; -} - -int psi_calc_add(int t1, impl_val *v1, int t2, impl_val *v2, impl_val *res); -int psi_calc_sub(int t1, impl_val *v1, int t2, impl_val *v2, impl_val *res); -int psi_calc_mul(int t1, impl_val *v1, int t2, impl_val *v2, impl_val *res); -int psi_calc_div(int t1, impl_val *v1, int t2, impl_val *v2, impl_val *res); +/******************************************************************************* + Copyright (c) 2016, Michael Wallner . + 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. +*******************************************************************************/ + +#ifndef PSI_CALC_H +#define PSI_CALC_H + +#include "token.h" +#include "types/impl_val.h" + +#define PRIfval ".13gF" +#define PRIdval ".53g" +#define PRIldval ".64LgL" + +typedef token_t (*psi_calc)(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res); + +#include "calc/basic.h" +#include "calc/bin.h" +#include "calc/bool.h" +#include "calc/unary.h" +#include "calc/cast.h" +#include "calc/cmp.h" +#include "calc/oper.h" #endif