scmno****@osdn*****
scmno****@osdn*****
Fri Jan 26 12:45:58 JST 2018
changeset 74378167fc6c in quipu/quipu details: http://hg.osdn.jp/view/quipu/quipu?cmd=changeset;node=74378167fc6c user: Agustina Arzille <avarz****@riseu*****> date: Fri Jan 26 03:45:44 2018 +0000 description: Redid function registration diffstat: builtins.cpp | 18 ++++++++++-------- cons.cpp | 5 +---- defs.h | 1 + function.cpp | 26 +++++++++++++++----------- function.h | 7 +++++-- misc.cpp | 13 ++++++++++++- 6 files changed, 44 insertions(+), 26 deletions(-) diffs (140 lines): diff -r 7529a30c9710 -r 74378167fc6c builtins.cpp --- a/builtins.cpp Thu Jan 25 18:10:13 2018 -0300 +++ b/builtins.cpp Fri Jan 26 03:45:44 2018 +0000 @@ -816,12 +816,7 @@ } symval(*argv) = argv[2]; - - if (qp_likely (singlethr_p ())) - as_varobj(*argv)->flags |= eflags; - else - as_varobj(*argv)->set_flag (eflags); - + as_varobj(*argv)->set_flag (eflags); qp_return (argv[2]); } @@ -1132,8 +1127,15 @@ bool init_builtins (interpreter *interp) { - native_function::add_sbatch (interp, BUILTIN_NAMES, - BUILTINS, global_builtins); + const char *names = BUILTIN_NAMES; + const native_function::fn_type *fcts = BUILTINS; + native_function *outp = global_builtins; + + for (; *names; ++fcts, ++outp) + { + native_function::add_fct (interp, names, *fcts, 0, outp); + names += strlen (names) + 1; + } return (true); } diff -r 7529a30c9710 -r 74378167fc6c cons.cpp --- a/cons.cpp Thu Jan 25 18:10:13 2018 -0300 +++ b/cons.cpp Fri Jan 26 03:45:44 2018 +0000 @@ -78,11 +78,8 @@ shallow_copy_L (interpreter *interp, object& obj, object& obr, object*& tailp) { - while (true) + while (obj != NIL) { - if (obj == NIL) - break; - *tailp = cons::make (interp, obr = xcar (obj), NIL); tailp = &xcdr(*tailp); diff -r 7529a30c9710 -r 74378167fc6c defs.h --- a/defs.h Thu Jan 25 18:10:13 2018 -0300 +++ b/defs.h Fri Jan 26 03:45:44 2018 +0000 @@ -169,6 +169,7 @@ } void set_flag (uint32_t __flg); + void clr_flag (uint32_t __flg); } __attribute__ ((aligned (8))); diff -r 7529a30c9710 -r 74378167fc6c function.cpp --- a/function.cpp Thu Jan 25 18:10:13 2018 -0300 +++ b/function.cpp Fri Jan 26 03:45:44 2018 +0000 @@ -19,19 +19,23 @@ return (interp->alval); } -void native_function::add_sbatch (interpreter *interp, const char *names, - const fn_type *fcts, native_function *outp) +void native_function::add_fct (interpreter *interp, const char *name, + fn_type fct, uint32_t flag, native_function *outp) { - for (; *names; ++fcts, ++outp) - { - outp->flags = native_function::native_flag; - outp->type = typecode::FCT; - outp->fct = *fcts; - outp->name = names; + outp->flags = native_function::native_flag; + outp->type = typecode::FCT; + outp->fct = fct; + outp->name = name; - symval(intern (interp, names)) = outp->as_obj (); - names += strlen (names) + 1; - } + object sym = intern (interp, name); + symval(sym) = outp->as_obj (); + as_varobj(sym)->set_flag (flag); +} + +void native_function::add_macro (interpreter *interp, const char *name, + fn_type fct, uint32_t flag, native_function *outp) +{ + add_fct (interp, name, fct, symbol::ctv_flag, outp); } bool eq_xx (interpreter *interp, object x, object y) diff -r 7529a30c9710 -r 74378167fc6c function.h --- a/function.h Thu Jan 25 18:10:13 2018 -0300 +++ b/function.h Fri Jan 26 03:45:44 2018 +0000 @@ -19,8 +19,11 @@ return (this->fct (__interp, __argv, __argc)); } - static void add_sbatch (interpreter *__interp, - const char *__names, const fn_type *__fcts, native_function *__outp); + static void add_fct (interpreter *__interp, const char *__name, + fn_type __fct, uint32_t __flags, native_function *__outp); + + static void add_macro (interpreter *__interp, const char *__name, + fn_type __fct, uint32_t __flags, native_function *__outp); }; class function : public varobj diff -r 7529a30c9710 -r 74378167fc6c misc.cpp --- a/misc.cpp Thu Jan 25 18:10:13 2018 -0300 +++ b/misc.cpp Fri Jan 26 03:45:44 2018 +0000 @@ -58,7 +58,18 @@ void varobj::set_flag (uint32_t flg) { - atomic_or ((atomic_t *)&this->full, (atomic_t)flg); + if (singlethr_p ()) + this->flags |= flg; + else + atomic_or ((atomic_t *)&this->full, (atomic_t)flg); +} + +void varobj::clr_flag (uint32_t flg) +{ + if (singlethr_p ()) + this->flags &= ~flg; + else + atomic_and ((atomic_t *)&this->full, (atomic_t)flg); } QP_DECLS_END