summaryrefslogtreecommitdiff
path: root/py/compile.c
diff options
context:
space:
mode:
authorRachel Dowdall <rjdowdall@gmail.com>2014-03-22 17:29:27 +0000
committerRachel Dowdall <rjdowdall@gmail.com>2014-03-22 17:29:27 +0000
commitcde8631f15db9941986f8d04534e52462a76094b (patch)
tree56651a2b887a7bfdfef37df391b24d28dac36fc4 /py/compile.c
parent721c55dced099a797f0910839c7c4f9ac7599ed4 (diff)
Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py.
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/py/compile.c b/py/compile.c
index bb688d5d8..4eab09423 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -15,6 +15,7 @@
#include "obj.h"
#include "compile.h"
#include "runtime.h"
+#include "intdivmod.h"
// TODO need to mangle __attr names
@@ -141,7 +142,8 @@ mp_parse_node_t fold_constants(mp_parse_node_t pn) {
; // pass
} else if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_PERCENT)) {
// XXX implement this properly as Python's % operator acts differently to C's
- pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0 % arg1);
+ //pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0 % arg1);
+ pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, python_modulo(arg0, arg1));
} else if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_DBL_SLASH)) {
// XXX implement this properly as Python's // operator acts differently to C's
pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0 / arg1);