X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Ftypes.h;h=220793c902652f9f1bb78ea8dd84623fb9d17ac5;hp=a4e5dadcaae1552221911338a70f975b9ba3b8b4;hb=c9384515a81cb64d345b299908b2852f51bb8e6e;hpb=e5103bb1ce17ef734e1329da9a13d9a2cbc40ad9 diff --git a/src/types.h b/src/types.h index a4e5dad..220793c 100644 --- a/src/types.h +++ b/src/types.h @@ -1,90 +1,76 @@ -#ifndef _PSI_TYPES_H -#define _PSI_TYPES_H +/******************************************************************************* + Copyright (c) 2016, Michael Wallner . + All rights reserved. -#include "Zend/zend_API.h" -typedef struct zend_fcall { - zend_fcall_info fci; - zend_fcall_info_cache fcc; -} zend_fcall; + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: -#include "token.h" + * 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_TYPES_H +#define PSI_TYPES_H + +#include "token.h" #include "types/impl_val.h" #include "types/decl_type.h" #include "types/decl_var.h" -#include "types/decl_struct_layout.h" #include "types/decl_arg.h" -#include "types/decl_typedefs.h" -#include "types/decl_vars.h" -#include "types/decl_args.h" #include "types/decl_abi.h" -#include "types/decl_callinfo.h" #include "types/decl.h" -#include "types/decls.h" +#include "types/decl_extvar.h" #include "types/decl_struct.h" -#include "types/decl_structs.h" #include "types/decl_union.h" -#include "types/decl_unions.h" #include "types/impl_type.h" #include "types/impl_var.h" #include "types/impl_def_val.h" -#include "types/const_type.h" -#include "types/constant.h" -#include "types/constants.h" +#include "types/const.h" #include "types/impl_arg.h" -#include "types/impl_args.h" #include "types/impl_func.h" +#include "types/number.h" #include "types/num_exp.h" #include "types/decl_enum_item.h" -#include "types/decl_enum_items.h" #include "types/decl_enum.h" -#include "types/decl_enums.h" #include "types/let_calloc.h" #include "types/let_callback.h" #include "types/let_func.h" -#include "types/let_val.h" -#include "types/let_vals.h" +#include "types/let_exp.h" #include "types/let_stmt.h" #include "types/set_func.h" -#include "types/set_value.h" -#include "types/set_values.h" +#include "types/set_exp.h" #include "types/set_stmt.h" #include "types/return_stmt.h" -#include "types/free_call.h" -#include "types/free_calls.h" +#include "types/return_exp.h" #include "types/free_stmt.h" -#include "types/impl_stmt.h" -#include "types/impl_stmts.h" #include "types/impl.h" -#include "types/impls.h" #include "types/decl_file.h" -#include "types/decl_libs.h" - - -static inline int weak_decl_type(decl_type *type) { - switch (type->type) { - case PSI_T_CHAR: - case PSI_T_SHORT: - case PSI_T_INT: - case PSI_T_LONG: - case PSI_T_NAME: - return type->type; - default: - return 0; - } -} - -static inline decl_type *real_decl_type(decl_type *type) { - while (weak_decl_type(type)) { - type = type->real.def->type; - } - return type; -} +#include "types/free_exp.h" +#include "types/free_stmt.h" +#include "types/assert_stmt.h" +#include "types/layout.h" +#include "types/cpp_exp.h" +#include "types/cpp_macro_call.h" +#include "types/cpp_macro_decl.h" -static inline impl_val *deref_impl_val(impl_val *ret_val, decl_var *var) { +static inline impl_val *deref_impl_val(impl_val *ret_val, struct psi_decl_var *var) { unsigned i; - ZEND_ASSERT(var->arg->var != var); + ZEND_ASSERT(!var->arg || var->arg->var != var); #if 0 fprintf(stderr, "deref: %s pl=%u:%u as=%u:%u %p\n", var->name, var->pointer_level, var->arg->var->pointer_level, @@ -99,7 +85,7 @@ static inline impl_val *deref_impl_val(impl_val *ret_val, decl_var *var) { return ret_val; } -static inline impl_val *enref_impl_val(void *ptr, decl_var *var) { +static inline impl_val *enref_impl_val(void *ptr, struct psi_decl_var *var) { impl_val *val, *val_ptr; unsigned i; @@ -113,7 +99,8 @@ static inline impl_val *enref_impl_val(void *ptr, decl_var *var) { return ptr; } - val = val_ptr = calloc(var->pointer_level + 1, sizeof(void *)); + val = calloc(var->pointer_level + 1, sizeof(void *)); + val_ptr = val; for (i = !var->arg->var->array_size; i < var->pointer_level; ++i) { #if 0 fprintf(stderr, "++\n"); @@ -125,7 +112,7 @@ static inline impl_val *enref_impl_val(void *ptr, decl_var *var) { return val; } -static inline impl_val *struct_member_ref(decl_arg *set_arg, impl_val *struct_ptr, impl_val **to_free) { +static inline impl_val *struct_member_ref(struct psi_decl_arg *set_arg, impl_val *struct_ptr, impl_val **to_free) { void *ptr = (char *) struct_ptr + set_arg->layout->pos; #if 0 fprintf(stderr, "struct member %s: %p\n", set_arg->var->name, ptr); @@ -133,9 +120,4 @@ static inline impl_val *struct_member_ref(decl_arg *set_arg, impl_val *struct_pt return ptr; } - -#define PSI_ERROR 16 -#define PSI_WARNING 32 -typedef void (*psi_error_cb)(void *context, struct psi_token *token, int type, const char *msg, ...); - #endif