pike.git/
src/
pike_types.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2021-01-01
2021-01-01 14:39:46 by Henrik Grubbström (Grubba) <grubba@grubba.org>
0c2a764425d4f40aab43e0a19e8b400aa5e16594 (
31
lines) (+
31
/-
0
)
[
Show
|
Annotate
]
Branch:
master
Compiler
[Typechecker]
: Support PT_BINOP_XOR and PT_BINOP_XNOR.
4245:
push_type(T_OR); return pop_unfinished_type();
+
case PT_BINOP_XOR:
+
/* A XOR B == (A OR B) - (A AND B) */
+
tmp = low_type_binop(PT_BINOP_OR, a, b, remap,
+
aflags, bflags, remap_flags);
+
if (!tmp) return NULL;
+
+
tmp2 = low_type_binop(PT_BINOP_AND, a, b, remap,
+
aflags, bflags, remap_flags);
+
if (!tmp2) return tmp;
+
+
ret = low_type_binop(PT_BINOP_MINUS, tmp, tmp2, NULL, 0, 0, 0);
+
free_type(tmp);
+
free_type(tmp2);
+
return ret;
+
+
case PT_BINOP_XNOR:
+
/* A XNOR B == (A NAND B) - (A NOR B) */
+
tmp = low_type_binop(PT_BINOP_NAND, a, b, remap,
+
aflags, bflags, remap_flags);
+
if (!tmp) return NULL;
+
+
tmp2 = low_type_binop(PT_BINOP_NOR, a, b, remap,
+
aflags, bflags, remap_flags);
+
if (!tmp2) return tmp;
+
+
ret = low_type_binop(PT_BINOP_MINUS, tmp, tmp2, NULL, 0, 0, 0);
+
free_type(tmp);
+
free_type(tmp2);
+
return ret;
+
#ifdef PIKE_DEBUG default: Pike_fatal("Unsupported binary type operation: 0x%02x\n", op);