pike.git/
src/
pike_types.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2021-01-04
2021-01-04 17:36:22 by Henrik Grubbström (Grubba) <grubba@grubba.org>
3136e5ccad0d96b9728771ae38ee27c8ea29012d (
71
lines) (+
66
/-
5
)
[
Show
|
Annotate
]
Branch:
master
Compiler
[Typechecker]
: Improve tracing of low_type_binop().
4192:
* * The internal mode is indicated via the remap state being NULL. */
+
static struct pike_type *lower_type_binop(enum pt_binop op,
+
struct pike_type *a,
+
struct pike_type *b,
+
struct remap_state *remap,
+
enum pt_cmp_flags aflags,
+
enum pt_cmp_flags bflags,
+
enum pt_remap_flags remap_flags);
static struct pike_type *low_type_binop(enum pt_binop op, struct pike_type *a, struct pike_type *b,
4200:
enum pt_cmp_flags bflags, enum pt_remap_flags remap_flags) {
-
struct pike_type *
tmp
,
*tmp2
, *
ret;
-
struct pike_type *
aret = NULL,
*
bret
=
NULL
;
-
enum
pt
_
cmp
_
flags
avoidable
;
-
enum
pt
_
cmp_flags
bvoidable
;
+
#ifdef
DEBUG_MALLOC
+
#define
low_type_binop(OP, A, B, REMAP, AFLAGS, BFLAGS, REMAP_FLAGS) \
+
((
struct pike_type *
) \
+
debug_malloc_pass(low_type_binop(OP
,
debug_malloc_pass(A)
,
\
+
debug_malloc_pass(B), \
+
debug_malloc_pass(REMAP), \
+
AFLAGS, BFLAGS, REMAP_FLAGS)))
+
#endif /
*
DEBUG_MALLOC */
+
#ifdef
PIKE_DEBUG
+
struct pike_type **
save_type_stackp
=
Pike_compiler->type_stackp
;
+
struct
pike
_
type ***save
_
mark_stackp
= Pike_compiler->pike_type_mark_stackp
;
+
#endif
+
struct
pike
_
type
*ret
;
-
recur:
+
if (remap_flags & PT_FLAG_REMAP_TRACE) { fprintf(stderr, "low_type_binop(0x%04x, ", op); simple_describe_type(a);
4215:
remap, aflags, bflags, remap_flags); }
+
ret = lower_type_binop(op, a, b, remap,
+
aflags, bflags, remap_flags);
+
+
if (remap_flags & PT_FLAG_REMAP_TRACE) {
+
fprintf(stderr, "ret: ");
+
simple_describe_type(ret);
+
fprintf(stderr, "\n");
+
}
+
+
#ifdef PIKE_DEBUG
+
if ((save_type_stackp != Pike_compiler->type_stackp) ||
+
(save_mark_stackp != Pike_compiler->pike_type_mark_stackp)) {
+
fprintf(stderr, "low_type_binop stack level corruption!\n"
+
"op : 0x%x\na: ", op);
+
simple_describe_type(a);
+
fprintf(stderr, "\nb: ");
+
simple_describe_type(b);
+
fprintf(stderr, "\nret: ");
+
simple_describe_type(ret);
+
fprintf(stderr, "\n\n");
+
+
Pike_fatal("Stack level corruption!\n"
+
"type stack: %p (expected: %p)\n"
+
"mark stack: %p (expected: %p)\n",
+
Pike_compiler->type_stackp, save_type_stackp,
+
Pike_compiler->pike_type_mark_stackp, save_mark_stackp);
+
}
+
#endif
+
+
return ret;
+
}
+
static struct pike_type *lower_type_binop(enum pt_binop op,
+
struct pike_type *a,
+
struct pike_type *b,
+
struct remap_state *remap,
+
enum pt_cmp_flags aflags,
+
enum pt_cmp_flags bflags,
+
enum pt_remap_flags remap_flags)
+
{
+
struct pike_type *tmp, *tmp2, *ret;
+
struct pike_type *aret = NULL, *bret = NULL;
+
enum pt_cmp_flags avoidable;
+
enum pt_cmp_flags bvoidable;
+
+
recur:
switch(op) { case PT_BINOP_AND: case PT_BINOP_MINUS: