added respondsTo and related functions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-08 01:52:50 +09:00
parent 433744c33a
commit 5ddc29dc5b
5 changed files with 178 additions and 62 deletions

View File

@ -2266,6 +2266,32 @@ static hcl_oop_block_t find_cmethod_noseterr (hcl_t* hcl, hcl_oop_class_t _class
return find_imethod_in_class_noseterr(hcl, (hcl_oop_class_t)HCL_CLASSOF(hcl, _class), &name, ivaroff, owner);
}
int hcl_class_responds_to (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg)
{
hcl_oop_block_t mth_blk;
hcl_oop_class_t owner;
hcl_ooi_t ivaroff;
HCL_ASSERT (hcl, HCL_IS_CLASS(hcl, rcv));
mth_blk = find_cmethod_noseterr(hcl, (hcl_oop_class_t)rcv, msg, 0, &ivaroff, &owner);
return mth_blk != HCL_NULL;
}
int hcl_inst_responds_to (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg)
{
hcl_oop_block_t mth_blk;
hcl_oop_class_t _class, owner;
hcl_ooi_t ivaroff;
_class = (hcl_oop_class_t)HCL_CLASSOF(hcl, rcv);
HCL_ASSERT (hcl, _class != HCL_NULL);
HCL_ASSERT (hcl, HCL_IS_CLASS(hcl, _class));
mth_blk = find_imethod_noseterr(hcl, _class, msg, 0, &ivaroff, &owner);
return mth_blk != HCL_NULL;
}
static HCL_INLINE int send_message (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg, int to_super, hcl_ooi_t nargs, hcl_ooi_t nrvars)
{
hcl_oop_block_t mth_blk;

View File

@ -1992,6 +1992,9 @@ int hcl_is_binop_char (hcl_ooci_t c);
/* ========================================================================= */
/* exec.c */
/* ========================================================================= */
int hcl_class_responds_to (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg);
int hcl_inst_responds_to (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg);
hcl_pfrc_t hcl_pf_process_current (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
hcl_pfrc_t hcl_pf_process_fork (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
hcl_pfrc_t hcl_pf_process_resume (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);

View File

@ -2239,6 +2239,7 @@ static int flx_hmarked_token (hcl_t* hcl, hcl_ooci_t c)
* #b[ ] byte array
* #( ) qlist
* #{ } dictionary
* #"..." symbol literal
*/
switch (c)
@ -2300,7 +2301,13 @@ static int flx_hmarked_token (hcl_t* hcl, hcl_ooci_t c)
case '{': /* #{ */
FEED_WRAP_UP_WITH_CHAR (hcl, c, HCL_TOK_DLPAREN);
goto consumed;
goto consumed;
#if 0
case '"': /* #" */
FEED_CONTINUE_WITH_CHAR (hcl, c, HCL_TOK_HMARKED_SYMBOL); /* symbol lieral */
goto consumed;
#endif
/* --------------------------- */
default: