#include "calc.h"
#include "marshal.h"
-size_t psi_t_alignment(token_t t)
-{
-#define PSI_ALIGNOF(T) case PSI_T_## T: return ALIGNOF_## T ##_T;
- switch (t) {
- PSI_ALIGNOF(INT8);
- PSI_ALIGNOF(UINT8);
- PSI_ALIGNOF(INT16);
- PSI_ALIGNOF(UINT16);
- PSI_ALIGNOF(INT32);
- PSI_ALIGNOF(UINT32);
- PSI_ALIGNOF(INT64);
- PSI_ALIGNOF(UINT64);
- case PSI_T_FLOAT:
- return ALIGNOF_FLOAT;
- case PSI_T_DOUBLE:
- return ALIGNOF_DOUBLE;
- case PSI_T_POINTER:
- case PSI_T_FUNCTION:
- return ALIGNOF_VOID_P;
- case PSI_T_ENUM:
- return ALIGNOF_INT;
- EMPTY_SWITCH_DEFAULT_CASE();
- }
- return 0;
-}
-
-size_t psi_t_size(token_t t)
-{
-#define PSI_SIZEOF(T) case PSI_T_## T : return SIZEOF_## T ##_T;
- switch (t) {
- PSI_SIZEOF(INT8);
- PSI_SIZEOF(UINT8);
- PSI_SIZEOF(INT16);
- PSI_SIZEOF(UINT16);
- PSI_SIZEOF(INT32);
- PSI_SIZEOF(UINT32);
- PSI_SIZEOF(INT64);
- PSI_SIZEOF(UINT64);
- case PSI_T_FLOAT:
- return SIZEOF_FLOAT;
- case PSI_T_DOUBLE:
- return SIZEOF_DOUBLE;
- case PSI_T_POINTER:
- case PSI_T_FUNCTION:
- return SIZEOF_VOID_P;
- case PSI_T_ENUM:
- return SIZEOF_INT;
- EMPTY_SWITCH_DEFAULT_CASE();
- }
- return 0;
-}
int psi_internal_type(impl_type *type)
{
return mem;
}
-static inline impl_val *psi_let_val(token_t let_func, impl_arg *iarg, impl_val *arg_val, decl_struct *strct, void **to_free)
-{
- abort();
- return arg_val;
-}
-
static inline impl_val *psi_let_func(let_func *func, decl_arg *darg) {
return darg->ptr = func->handler(darg->ptr, darg->type, func->var->arg, &darg->mem);
}
}
/* FIXME: check in validate_* that free functions return scalar */
- PSI_ContextCall(&PSI_G(context), &f->decl->call, NULL);
+ psi_context_call(&PSI_G(context), &f->decl->call, NULL);
}
}
while (*ptr) {
efree(*ptr++);
}
+ } else if (type->type == PSI_T_STRUCT) {
+ void **ptr = (void **) ((char *) darg->mem + type->real.unn->size);
+
+ if (*ptr) {
+ efree(*ptr);
+ }
}
}
}
case PSI_T_STRUCT:
impl->decl->func->ptr = psi_array_to_struct(real->real.strct, NULL);
break;
+ case PSI_T_UNION:
+ impl->decl->func->ptr = psi_array_to_union(real->real.unn, NULL);
+ break;
}
}
}
}
}
- PSI_ContextCall(&PSI_G(context), &impl->decl->call, va);
+ psi_context_call(&PSI_G(context), &impl->decl->call, va);
psi_do_return(return_value, impl->stmts->ret.list[0]);
for (i = 0; i < impl->stmts->set.count; ++i) {