updatecd basicAt and basicAtPut to cater for fixed fields
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
hyung-hwan 2024-08-11 02:17:52 +09:00
parent 151653aaf4
commit 185f72381a
2 changed files with 25 additions and 15 deletions

View File

@ -730,7 +730,6 @@ int main (int argc, char* argv[])
hcl_oow_t heapsize = DEFAULT_HEAPSIZE; hcl_oow_t heapsize = DEFAULT_HEAPSIZE;
int verbose = 0; int verbose = 0;
int show_info = 0; int show_info = 0;
int nl_terminator = 0;
const char* modlibdirs = HCL_NULL; const char* modlibdirs = HCL_NULL;
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
@ -745,7 +744,7 @@ int main (int argc, char* argv[])
print_usage: print_usage:
fprintf (stderr, "Usage: %s [options] script-filename [output-filename]\n", argv[0]); fprintf (stderr, "Usage: %s [options] script-filename [output-filename]\n", argv[0]);
fprintf (stderr, "Options are:\n"); fprintf (stderr, "Options are:\n");
fprintf (stderr, " -n enable line-break as expression terminator\n"); fprintf (stderr, " -v show verbose messages\n");
return -1; return -1;
} }
@ -757,10 +756,6 @@ int main (int argc, char* argv[])
logopt = opt.arg; logopt = opt.arg;
break; break;
case 'n':
nl_terminator = 1;
break;
case 'v': case 'v':
verbose = 1; verbose = 1;
break; break;
@ -831,11 +826,7 @@ int main (int argc, char* argv[])
/*trait |= HCL_TRAIT_NOGC;*/ /*trait |= HCL_TRAIT_NOGC;*/
trait |= HCL_TRAIT_AWAIT_PROCS; trait |= HCL_TRAIT_AWAIT_PROCS;
#if 0
if (nl_terminator) trait |= HCL_TRAIT_LANG_ENABLE_EOL;
#else
trait |= HCL_TRAIT_LANG_ENABLE_EOL; trait |= HCL_TRAIT_LANG_ENABLE_EOL;
#endif
hcl_setoption (hcl, HCL_TRAIT, &trait); hcl_setoption (hcl, HCL_TRAIT, &trait);
} }

View File

@ -65,7 +65,9 @@ static hcl_pfrc_t pf_core_basic_at (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
{ {
hcl_oop_t obj, val; hcl_oop_t obj, val;
hcl_oop_t pos; hcl_oop_t pos;
hcl_ooi_t index; hcl_oow_t index;
hcl_oop_class_t _class;
hcl_oow_t fixed, flexi;
obj = HCL_STACK_GETARG(hcl, nargs, 0); obj = HCL_STACK_GETARG(hcl, nargs, 0);
pos = HCL_STACK_GETARG(hcl, nargs, 1); pos = HCL_STACK_GETARG(hcl, nargs, 1);
@ -84,11 +86,16 @@ static hcl_pfrc_t pf_core_basic_at (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
hcl_seterrbfmt (hcl, HCL_EINVAL, "position not valid - %O", pos); hcl_seterrbfmt (hcl, HCL_EINVAL, "position not valid - %O", pos);
return HCL_PF_FAILURE; return HCL_PF_FAILURE;
} }
if (index >= HCL_OBJ_GET_SIZE(obj))
_class = (hcl_oop_class_t)HCL_CLASSOF(hcl, obj);
fixed = HCL_CLASS_SPEC_NAMED_INSTVARS(_class->spec);
flexi = HCL_OBJ_GET_SIZE(obj) - fixed;
if (index >= flexi)
{ {
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj)); hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
return HCL_PF_FAILURE; return HCL_PF_FAILURE;
} }
index += fixed;
switch (HCL_OBJ_GET_FLAGS_TYPE(obj)) switch (HCL_OBJ_GET_FLAGS_TYPE(obj))
{ {
@ -135,7 +142,9 @@ static hcl_pfrc_t pf_core_basic_at_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t na
{ {
hcl_oop_t obj, val; hcl_oop_t obj, val;
hcl_oop_t pos; hcl_oop_t pos;
hcl_ooi_t index; hcl_oow_t index;
hcl_oop_class_t _class;
hcl_oow_t fixed, flexi;
obj = HCL_STACK_GETARG(hcl, nargs, 0); obj = HCL_STACK_GETARG(hcl, nargs, 0);
pos = HCL_STACK_GETARG(hcl, nargs, 1); pos = HCL_STACK_GETARG(hcl, nargs, 1);
@ -154,6 +163,16 @@ static hcl_pfrc_t pf_core_basic_at_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t na
hcl_seterrbfmt (hcl, HCL_EINVAL, "position not valid - %O", pos); hcl_seterrbfmt (hcl, HCL_EINVAL, "position not valid - %O", pos);
return HCL_PF_FAILURE; return HCL_PF_FAILURE;
} }
_class = (hcl_oop_class_t)HCL_CLASSOF(hcl, obj);
fixed = HCL_CLASS_SPEC_NAMED_INSTVARS(_class->spec);
flexi = HCL_OBJ_GET_SIZE(obj) - fixed;
if (index >= flexi)
{
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
return HCL_PF_FAILURE;
}
index += fixed;
if (index >= HCL_OBJ_GET_SIZE(obj)) if (index >= HCL_OBJ_GET_SIZE(obj))
{ {
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj)); hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));