From 5004b3912591095ee2bc852a35ea7811417fb728 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sat, 26 Oct 2019 14:34:19 +0000 Subject: [PATCH] removed MOO_BQ(). changed the primitive value load method --- moo/lib/bigint.c | 2 +- moo/lib/comp.c | 19 ++++++++----------- moo/lib/moo-cmn.h | 7 ------- moo/lib/moo.h | 8 ++++---- moo/mod/io-file.c | 19 +++++++++---------- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/moo/lib/bigint.c b/moo/lib/bigint.c index 1c47b3f..76205a5 100644 --- a/moo/lib/bigint.c +++ b/moo/lib/bigint.c @@ -3273,7 +3273,7 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y) v3 = v1 | v2; if (MOO_IN_SMOOI_RANGE(v3)) return MOO_SMOOI_TO_OOP(v3); - return make_bigint_with_ooi (moo, v3); + return make_bigint_with_ooi(moo, v3); } else if (MOO_OOP_IS_SMOOI(x)) { diff --git a/moo/lib/comp.c b/moo/lib/comp.c index f6227e4..6f30a4b 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -10296,22 +10296,19 @@ static int __compile_pooldic_definition (moo_t* moo) switch (pvbase->type) { - case MOO_PV_INT: + case MOO_PV_OOI: { - moo_oocs_t x; - - x.ptr = moo_dupbtooocstr(moo, pvbase->vstr, &x.len); - if (!x.ptr) goto oops; - - tmp = string_to_int(moo, &x, 0); - moo_freemem (moo, x.ptr); - if (tmp && MOO_OOP_IS_POINTER(tmp)) MOO_OBJ_SET_FLAGS_RDONLY (tmp, 1); + tmp = moo_ooitoint(moo, (moo_ooi_t)pvbase->value); break; } - /* case MOO_PV_STR: - */ + case MOO_PV_OOW: + { + tmp = moo_oowtoint(moo, (moo_oow_t)pvbase->value); + break; + } + /* TODO: support more types... MOO_PV_OOI_BCSTR, MOO_PV_OOI_UCSTR, MOO_PV_FPDEC_BCSTR, MOO_PV_BCSTR, MOO_PV_UCSTR, etc */ default: moo_setsynerrbfmt (moo, MOO_SYNERR_STRING, TOKEN_LOC(moo), TOKEN_NAME(moo), "unsupported primitive value type - %d", pvbase->type); goto oops; diff --git a/moo/lib/moo-cmn.h b/moo/lib/moo-cmn.h index 624a133..d996a2e 100644 --- a/moo/lib/moo-cmn.h +++ b/moo/lib/moo-cmn.h @@ -1049,11 +1049,4 @@ typedef struct moo_t moo_t; #define MOO_STATIC_ASSERT_EXPR(expr) ((void)MOO_SIZEOF(char[(expr)? 1: -1])) - -/* ========================================================================= - * QUOTING - * =========================================================================*/ -#define MOO_BQ_(val) #val -#define MOO_BQ(val) MOO_BQ_(val) - #endif diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 0475154..0d81942 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1334,16 +1334,16 @@ struct moo_pfinfo_t enum moo_pvtype_t { - MOO_PV_INT, - MOO_PV_STR, - MOO_PV_SYM + MOO_PV_OOI, + MOO_PV_OOW + /* TODO: more types */ }; typedef enum moo_pvtype_t moo_pvtype_t; struct moo_pvbase_t { moo_pvtype_t type; - const void* vstr; + const void* value; }; typedef struct moo_pvbase_t moo_pvbase_t; diff --git a/moo/mod/io-file.c b/moo/mod/io-file.c index 6677771..3c90f56 100644 --- a/moo/mod/io-file.c +++ b/moo/mod/io-file.c @@ -126,21 +126,20 @@ static moo_pfinfo_t pfinfos[] = static moo_pvinfo_t pvinfos[] = { - { "O_CLOEXEC", { MOO_PV_INT, MOO_BQ(O_CLOEXEC) } }, - { "O_CREAT", { MOO_PV_INT, MOO_BQ(O_CREAT) } }, - { "O_EXCL", { MOO_PV_INT, MOO_BQ(O_EXCL) } }, - { "O_NOFOLLOW", { MOO_PV_INT, MOO_BQ(O_NOFOLLOW) } }, - { "O_NONBLOCK", { MOO_PV_INT, MOO_BQ(O_NONBLOCK) } }, - { "O_RDONLY", { MOO_PV_INT, MOO_BQ(O_RDONLY) } }, - { "O_RDWR", { MOO_PV_INT, MOO_BQ(O_RDWR) } }, - { "O_TRUNC", { MOO_PV_INT, MOO_BQ(O_TRUNC) } }, - { "O_WRONLY", { MOO_PV_INT, MOO_BQ(O_WRONLY) } }, + { "O_CLOEXEC", { MOO_PV_OOI, (const void*)O_CLOEXEC } }, + { "O_CREAT", { MOO_PV_OOI, (const void*)O_CREAT } }, + { "O_EXCL", { MOO_PV_OOI, (const void*)O_EXCL } }, + { "O_NOFOLLOW", { MOO_PV_OOI, (const void*)O_NOFOLLOW } }, + { "O_NONBLOCK", { MOO_PV_OOI, (const void*)O_NONBLOCK } }, + { "O_RDONLY", { MOO_PV_OOI, (const void*)O_RDONLY } }, + { "O_RDWR", { MOO_PV_OOI, (const void*)O_RDWR } }, + { "O_TRUNC", { MOO_PV_OOI, (const void*)O_TRUNC } }, + { "O_WRONLY", { MOO_PV_OOI, (const void*)O_WRONLY } } }; /* ------------------------------------------------------------------------ */ static int import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class) { - /*if (moo_setclasstrsize(moo, _class, MOO_SIZEOF(io_t), MOO_NULL) <= -1) return -1;*/ return 0; }