working on the block expression compilation
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-11-10 00:03:03 +09:00
parent 9110a083eb
commit 5a28ab3749
36 changed files with 1108 additions and 1044 deletions

View File

@ -136,7 +136,7 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, const hcl_vmprim_t* vmprim)
* routine still function despite some side-effects when
* reallocation fails */
/* +1 required for consistency with put_oocs and put_ooch in logfmt.c */
hcl->log.ptr = (hcl_ooch_t*)hcl_allocmem(hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr));
hcl->log.ptr = (hcl_ooch_t*)hcl_allocmem(hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr));
if (HCL_UNLIKELY(!hcl->log.ptr)) goto oops;
hcl->gci.stack.capa = HCL_ALIGN_POW2(1, 1024); /* TODO: is this a good initial size? */
@ -208,7 +208,7 @@ void hcl_fini (hcl_t* hcl)
if (hcl->log.len > 0)
{
/* flush pending log message that could be generated by the fini
/* flush pending log message that could be generated by the fini
* callbacks. however, the actual logging might not be produced at
* this point because one of the callbacks could arrange to stop
* logging */
@ -312,7 +312,7 @@ void hcl_fini (hcl_t* hcl)
if (hcl->heap) hcl_killheap (hcl, hcl->heap);
if (hcl->log.ptr)
if (hcl->log.ptr)
{
hcl_freemem (hcl, hcl->log.ptr);
hcl->log.capa = 0;
@ -362,7 +362,7 @@ void hcl_reset (hcl_t* hcl)
hcl_oop_t v;
hcl_oow_t i;
/* delete all literals shown in the literal frame from the system dictionary
/* delete all literals shown in the literal frame from the system dictionary
* excluding special kernel symbols. */
for (i = 0; i < hcl->code.lit.len; i++)
{
@ -519,7 +519,7 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
hcl->option.dfl_procstk_size = *(hcl_oow_t*)value;
break;
}
case HCL_MOD_INCTX:
hcl->option.mod_inctx = *(void**)value;
break;
@ -529,13 +529,13 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
goto einval;
}
for (cb = hcl->cblist; cb; cb = cb->next)
for (cb = hcl->cblist; cb; cb = cb->next)
{
if (cb->opt_set) cb->opt_set (hcl, id, value);
}
return 0;
einval:
hcl_seterrnum (hcl, HCL_EINVAL);
return -1;
@ -608,7 +608,7 @@ hcl_cb_t* hcl_regcb (hcl_t* hcl, hcl_cb_t* tmpl)
actual->next = hcl->cblist;
actual->prev = HCL_NULL;
hcl->cblist = actual;
/* vm_checkbc is invoked very frequently.
* and there might be multiple vm_checkbc callbacks registered.
* keeping the count of vm_checkbc callbacks registered
@ -631,7 +631,7 @@ void hcl_deregcb (hcl_t* hcl, hcl_cb_t* cb)
if (cb->prev) cb->prev->next = cb->next;
}
if (cb->vm_checkbc)
if (cb->vm_checkbc)
{
HCL_ASSERT (hcl, hcl->vm_checkbc_cb_count > 0);
hcl->vm_checkbc_cb_count--;
@ -688,7 +688,7 @@ static struct
const hcl_bch_t* modname;
int (*modload) (hcl_t* hcl, hcl_mod_t* mod);
}
static_modtab[] =
static_modtab[] =
{
{ "arr", hcl_mod_arr },
{ "dic", hcl_mod_dic },
@ -707,17 +707,17 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
int n;
#endif
/* maximum module name length is HCL_MOD_NAME_LEN_MAX.
/* maximum module name length is HCL_MOD_NAME_LEN_MAX.
* MOD_PREFIX_LEN for MOD_PREFIX
* 1 for _ at the end when hcl_mod_xxx_ is attempted.
* 1 for the terminating '\0'.
*/
hcl_ooch_t buf[MOD_PREFIX_LEN + HCL_MOD_NAME_LEN_MAX + 1 + 1];
hcl_ooch_t buf[MOD_PREFIX_LEN + HCL_MOD_NAME_LEN_MAX + 1 + 1];
/* copy instead of encoding conversion. MOD_PREFIX must not
* include a character that requires encoding conversion.
* note the terminating null isn't needed in buf here. */
hcl_copy_bchars_to_oochars (buf, MOD_PREFIX, MOD_PREFIX_LEN);
hcl_copy_bchars_to_oochars (buf, MOD_PREFIX, MOD_PREFIX_LEN);
if (namelen > HCL_COUNTOF(buf) - (MOD_PREFIX_LEN + 1 + 1))
{
@ -735,7 +735,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
/* TODO: binary search ... */
for (n = 0; n < HCL_COUNTOF(static_modtab); n++)
{
if (hcl_comp_oochars_bcstr(name, namelen, static_modtab[n].modname) == 0)
if (hcl_comp_oochars_bcstr(name, namelen, static_modtab[n].modname) == 0)
{
load = static_modtab[n].modload;
break;
@ -797,7 +797,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
md.handle = hcl->vmprim.dl_open(hcl, &buf[MOD_PREFIX_LEN], HCL_VMPRIM_DLOPEN_PFMOD);
}
if (md.handle == HCL_NULL)
if (md.handle == HCL_NULL)
{
HCL_DEBUG2 (hcl, "Cannot open a module [%.*js]\n", namelen, name);
hcl_seterrbfmt (hcl, HCL_ENOENT, "unable to open a module [%.*js]", namelen, name);
@ -806,7 +806,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
/* attempt to get hcl_mod_xxx where xxx is the module name*/
load = (hcl_mod_load_t)hcl->vmprim.dl_getsym(hcl, md.handle, buf);
if (!load)
if (!load)
{
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "unable to get module symbol [%js] in [%.*js]", buf, namelen, name);
HCL_DEBUG3 (hcl, "Cannot get a module symbol [%js] in [%.*js]\n", buf, namelen, name);
@ -829,7 +829,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
if (load(hcl, &mdp->mod) <= -1)
{
const hcl_ooch_t* oldmsg = hcl_backuperrmsg (hcl);
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "module initializer [%js] returned failure in [%.*js] - %js", buf, namelen, name, oldmsg);
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "module initializer [%js] returned failure in [%.*js] - %js", buf, namelen, name, oldmsg);
HCL_DEBUG3 (hcl, "Module function [%js] returned failure in [%.*js]\n", buf, namelen, name);
hcl_rbt_delete (&hcl->modtab, name, namelen);
hcl->vmprim.dl_close (hcl, mdp->handle);
@ -850,7 +850,7 @@ void hcl_closemod (hcl_t* hcl, hcl_mod_data_t* mdp)
{
if (mdp->mod.unload) mdp->mod.unload (hcl, &mdp->mod);
if (mdp->handle)
if (mdp->handle)
{
hcl->vmprim.dl_close (hcl, mdp->handle);
HCL_DEBUG2 (hcl, "Closed a module [%js] - %p\n", mdp->mod.name, mdp->handle);
@ -884,7 +884,7 @@ hcl_pfbase_t* hcl_querymod (hcl_t* hcl, const hcl_ooch_t* pfid, hcl_oow_t pfidle
sep = hcl_rfind_oochar(pfid, pfidlen, '.');
if (!sep)
{
/* i'm writing a conservative code here. the compiler should
/* i'm writing a conservative code here. the compiler should
* guarantee that a period is included in an primitive function identifer.
* what if the compiler is broken? imagine a buggy compiler rewritten
* in hcl itself? */
@ -912,7 +912,7 @@ hcl_pfbase_t* hcl_querymod (hcl_t* hcl, const hcl_ooch_t* pfid, hcl_oow_t pfidle
if (!mdp) return HCL_NULL;
}
if ((pfbase = mdp->mod.query(hcl, &mdp->mod, sep + 1, pfidlen - mod_name_len - 1)) == HCL_NULL)
if ((pfbase = mdp->mod.query(hcl, &mdp->mod, sep + 1, pfidlen - mod_name_len - 1)) == HCL_NULL)
{
/* the primitive function is not found. but keep the module open even if it's opened above */
HCL_DEBUG3 (hcl, "Cannot find a primitive function [%.*js] in a module [%js]\n", pfidlen - mod_name_len - 1, sep + 1, mdp->mod.name);