aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-03-10 19:57:07 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 19:15:34 +0100
commit2fadbefc264d33da526ec61cffc9847f724d8d92 (patch)
tree5359fe987ea2a5e991ffe4fe0298ac264dde0ae3 /erts/emulator/beam
parent27e57aa05354b743b735a41716c0e3af18f2843e (diff)
downloadotp-2fadbefc264d33da526ec61cffc9847f724d8d92.tar.gz
otp-2fadbefc264d33da526ec61cffc9847f724d8d92.tar.bz2
otp-2fadbefc264d33da526ec61cffc9847f724d8d92.zip
erts: Reintroduce is_map macro
as shorthand for is_flatmap || is_hashmap
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/beam_emu.c2
-rw-r--r--erts/emulator/beam/erl_bif_op.c2
-rw-r--r--erts/emulator/beam/erl_db_util.c6
-rw-r--r--erts/emulator/beam/erl_map.c12
-rw-r--r--erts/emulator/beam/erl_term.h3
5 files changed, 14 insertions, 11 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index 10ae3ed77c..289b60e1f9 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -699,7 +699,7 @@ void** beam_ops;
Fail; \
}
-#define IsMap(Src, Fail) if (is_not_flatmap(Src) && is_not_hashmap(Src)) { Fail; }
+#define IsMap(Src, Fail) if (!is_map(Src)) { Fail; }
#define HasMapField(Src, Key, Fail) if (has_not_map_field(Src, Key)) { Fail; }
diff --git a/erts/emulator/beam/erl_bif_op.c b/erts/emulator/beam/erl_bif_op.c
index af9b7bd908..37dd6457db 100644
--- a/erts/emulator/beam/erl_bif_op.c
+++ b/erts/emulator/beam/erl_bif_op.c
@@ -324,7 +324,7 @@ BIF_RETTYPE is_record_3(BIF_ALIST_3)
BIF_RETTYPE is_map_1(BIF_ALIST_1)
{
- if (is_flatmap(BIF_ARG_1) || is_hashmap(BIF_ARG_1)) {
+ if (is_map(BIF_ARG_1)) {
BIF_RET(am_true);
}
BIF_RET(am_false);
diff --git a/erts/emulator/beam/erl_db_util.c b/erts/emulator/beam/erl_db_util.c
index cca3f381a1..efbefb7492 100644
--- a/erts/emulator/beam/erl_db_util.c
+++ b/erts/emulator/beam/erl_db_util.c
@@ -2004,7 +2004,7 @@ restart:
++ep;
break;
case matchMap:
- if (!is_flatmap_rel(*ep, base) && !is_hashmap_rel(*ep,base)) {
+ if (!is_map_rel(*ep, base)) {
FAIL();
}
n = *pc++;
@@ -2021,7 +2021,7 @@ restart:
ep = flatmap_val_rel(*ep, base);
break;
case matchPushM:
- if (!is_flatmap_rel(*ep, base) && !is_hashmap_rel(*ep, base)) {
+ if (!is_map_rel(*ep, base)) {
FAIL();
}
n = *pc++;
@@ -4915,7 +4915,7 @@ static DMCRet dmc_expr(DMCContext *context,
return ret;
break;
case TAG_PRIMARY_BOXED:
- if (is_flatmap(t) || is_hashmap(t)) {
+ if (is_map(t)) {
return dmc_map(context, heap, text, t, constant);
}
if (!is_tuple(t)) {
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c
index ca43baf1a6..16293668ad 100644
--- a/erts/emulator/beam/erl_map.c
+++ b/erts/emulator/beam/erl_map.c
@@ -202,7 +202,7 @@ erts_maps_get(Eterm key, Eterm map)
}
BIF_RETTYPE maps_find_2(BIF_ALIST_2) {
- if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_map(BIF_ARG_2)) {
Eterm *hp, res;
const Eterm *value;
@@ -226,7 +226,7 @@ BIF_RETTYPE maps_find_2(BIF_ALIST_2) {
*/
BIF_RETTYPE maps_get_2(BIF_ALIST_2) {
- if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_map(BIF_ARG_2)) {
Eterm *hp;
Eterm error;
const Eterm *value;
@@ -877,7 +877,7 @@ static int hxnodecmp(hxnode_t *a, hxnode_t *b) {
/* maps:is_key/2 */
BIF_RETTYPE maps_is_key_2(BIF_ALIST_2) {
- if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_map(BIF_ARG_2)) {
BIF_RET(erts_maps_get(BIF_ARG_1, BIF_ARG_2) ? am_true : am_false);
}
BIF_ERROR(BIF_P, BADARG);
@@ -1360,7 +1360,7 @@ BIF_RETTYPE maps_new_0(BIF_ALIST_0) {
/* maps:put/3 */
BIF_RETTYPE maps_put_3(BIF_ALIST_3) {
- if (is_flatmap(BIF_ARG_3) || is_hashmap(BIF_ARG_3)) {
+ if (is_map(BIF_ARG_3)) {
BIF_RET(erts_maps_put(BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3));
}
BIF_ERROR(BIF_P, BADARG);
@@ -1451,7 +1451,7 @@ found_key:
}
BIF_RETTYPE maps_remove_2(BIF_ALIST_2) {
- if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_map(BIF_ARG_2)) {
Eterm res;
if (erts_maps_remove(BIF_P, BIF_ARG_1, BIF_ARG_2, &res)) {
BIF_RET(res);
@@ -1653,7 +1653,7 @@ Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
/* maps:update/3 */
BIF_RETTYPE maps_update_3(BIF_ALIST_3) {
- if (is_flatmap(BIF_ARG_3) || is_hashmap(BIF_ARG_3)) {
+ if (is_map(BIF_ARG_3)) {
Eterm res;
if (erts_maps_update(BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3, &res)) {
BIF_RET(res);
diff --git a/erts/emulator/beam/erl_term.h b/erts/emulator/beam/erl_term.h
index 6d97344868..1625a4ec15 100644
--- a/erts/emulator/beam/erl_term.h
+++ b/erts/emulator/beam/erl_term.h
@@ -1019,6 +1019,9 @@ _ET_DECLARE_CHECKED(struct erl_node_*,external_ref_node,Eterm)
#define hashmap_val(x) _unchecked_boxed_val((x))
#define hashmap_val_rel(RTERM, BASE) hashmap_val(rterm2wterm(RTERM, BASE))
+#define is_map(x) (is_flatmap(x) || is_hashmap(x))
+#define is_map_rel(x,BASE) (is_flatmap_rel(x,BASE) || is_hashmap_rel(x,BASE))
+
/* number tests */
#define is_integer(x) (is_small(x) || is_big(x))