aboutsummaryrefslogtreecommitdiff
path: root/py/parse.h
diff options
context:
space:
mode:
authorDamien <damien.p.george@gmail.com>2013-10-12 16:16:56 +0100
committerDamien <damien.p.george@gmail.com>2013-10-12 16:16:56 +0100
commit0efb3a1b66278f31da3e36223bc1429ab5fa7e2c (patch)
tree4b471947f0b654a78956d5ef92f079e3211eb71e /py/parse.h
parent3a205179ea36cb0380366465d517ca27ecb0e400 (diff)
Tidy up SMALL_INT optimisations and CPython compatibility.
Diffstat (limited to 'py/parse.h')
-rw-r--r--py/parse.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/parse.h b/py/parse.h
index 07d553c14..a87ee08b9 100644
--- a/py/parse.h
+++ b/py/parse.h
@@ -11,6 +11,11 @@ struct _py_lexer_t;
// - xxxx...1101: a token; bits 4 and above are py_token_kind_t
// - xxxx...xxx0: pointer to py_parse_node_struct_t
+// makes sure the top 5 bits of x are all cleared (positive number) or all set (negavite number)
+// these macros can probably go somewhere else because they are used more than just in the parser
+#define PY_UINT_HIGH_5_BITS (~((~((machine_uint_t)0)) >> 5))
+#define PY_FIT_SMALL_INT(x) (((((machine_uint_t)(x)) & PY_UINT_HIGH_5_BITS) == 0) || ((((machine_uint_t)(x)) & PY_UINT_HIGH_5_BITS) == PY_UINT_HIGH_5_BITS))
+
#define PY_PARSE_NODE_NULL (0)
#define PY_PARSE_NODE_ID (0x1)
#define PY_PARSE_NODE_SMALL_INT (0x3)