removed some unneeded code holding class-level variables
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0b65671adb
commit
001472fe4f
68
lib/comp.c
68
lib/comp.c
@ -241,16 +241,21 @@ static void kill_temporary_variable_at_offset (hcl_t* hcl, hcl_oow_t offset)
|
||||
hcl->c->tv.s.ptr[offset] = '('; /* HACK!! put a special character which can't form a variable name */
|
||||
}
|
||||
|
||||
static int init_class_level_variable_buffer (hcl_t* hcl, hcl_oocsc_t* dst)
|
||||
static int init_class_level_variable_buffer (hcl_t* hcl, hcl_oocsc_t* dst, const hcl_ooch_t* ivptr, hcl_oow_t ivlen)
|
||||
{
|
||||
hcl_ooch_t* tmp;
|
||||
hcl_oow_t capa = 128;
|
||||
|
||||
tmp = (hcl_ooch_t*)hcl_allocmem(hcl, 1 * HCL_SIZEOF(*dst->ptr));
|
||||
if (ivlen > capa) capa = ivlen;
|
||||
|
||||
tmp = (hcl_ooch_t*)hcl_allocmem(hcl, (capa + 1) * HCL_SIZEOF(*dst->ptr));
|
||||
if (HCL_UNLIKELY(!tmp)) return -1;
|
||||
|
||||
dst->ptr = tmp;
|
||||
dst->len = 0;
|
||||
dst->capa = 0;
|
||||
dst->len = ivlen;
|
||||
dst->capa = capa;
|
||||
|
||||
if (ivlen > 0) hcl_copy_oochars_to_oocstr(dst->ptr, dst->capa + 1, ivptr, ivlen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -355,15 +360,10 @@ static int find_variable_backward_with_word (hcl_t* hcl, const hcl_oocs_t* name,
|
||||
#endif
|
||||
cbi = &hcl->c->clsblk.info[fbi->clsblk_top];
|
||||
|
||||
#if 0
|
||||
if (cbi->ivars_str)
|
||||
{
|
||||
haystack.ptr = cbi->ivars_str;
|
||||
haystack.len = hcl_count_oocstr(cbi->ivars_str);
|
||||
#else
|
||||
/* find the name in the instance variables */
|
||||
haystack.ptr = cbi->ivars.ptr;
|
||||
haystack.len = cbi->ivars.len;
|
||||
#endif
|
||||
|
||||
if (__find_word_in_string(&haystack, name, 1, &index) >= 0)
|
||||
{
|
||||
hcl_oow_t fi;
|
||||
@ -399,19 +399,10 @@ HCL_INFO6 (hcl, "FOUND INST VAR [%.*js]...[%.*js]................ ===> ctx_offse
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (cbi->cvars_str)
|
||||
{
|
||||
haystack.ptr = cbi->cvars_str;
|
||||
haystack.len = hcl_count_oocstr(cbi->cvars_str);
|
||||
#else
|
||||
/* find the name in the class variables */
|
||||
haystack.ptr = cbi->cvars.ptr;
|
||||
haystack.len = cbi->cvars.len;
|
||||
#endif
|
||||
if (__find_word_in_string(&haystack, name, 1, &index) >= 0)
|
||||
{
|
||||
/* TODO: VAR_CLASS_CM vs VAR_CLASS_IM, need to know if it's an instance method or a class method */
|
||||
@ -427,9 +418,6 @@ HCL_INFO6 (hcl, "FOUND CLASS VAR [%.*js]...[%.*js]................ ===> ctx_offs
|
||||
}
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
}
|
||||
|
||||
if (i == hcl->c->funblk.depth)
|
||||
{
|
||||
@ -1123,25 +1111,8 @@ static int push_clsblk (
|
||||
ci->nivars = nivars;
|
||||
ci->ncvars = ncvars;
|
||||
|
||||
if (init_class_level_variable_buffer(hcl, &ci->ivars) <= -1) return -1;
|
||||
if (init_class_level_variable_buffer(hcl, &ci->cvars) <= -1) return -1;
|
||||
|
||||
if (nivars > 0)
|
||||
{
|
||||
HCL_ASSERT (hcl, ivars_str != HCL_NULL);
|
||||
ci->ivars_str = hcl_dupoochars(hcl, ivars_str, ivars_strlen);
|
||||
if (HCL_UNLIKELY(!ci->ivars_str)) return -1;
|
||||
}
|
||||
if (ncvars > 0)
|
||||
{
|
||||
HCL_ASSERT (hcl, cvars_str != HCL_NULL);
|
||||
ci->cvars_str = hcl_dupoochars(hcl, cvars_str, cvars_strlen);
|
||||
if (HCL_UNLIKELY(!ci->cvars_str))
|
||||
{
|
||||
if (ci->ivars_str) hcl_freemem (hcl, ci->ivars_str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (init_class_level_variable_buffer(hcl, &ci->ivars, ivars_str, ivars_strlen) <= -1) return -1;
|
||||
if (init_class_level_variable_buffer(hcl, &ci->cvars, cvars_str, cvars_strlen) <= -1) return -1;
|
||||
|
||||
/* remember the function block depth before the class block is entered */
|
||||
ci->funblk_base = hcl->c->funblk.depth;
|
||||
@ -1178,17 +1149,6 @@ static void pop_clsblk (hcl_t* hcl)
|
||||
}
|
||||
|
||||
cbi = &hcl->c->clsblk.info[hcl->c->clsblk.depth];
|
||||
if (cbi->cvars_str)
|
||||
{
|
||||
hcl_freemem (hcl, cbi->cvars_str);
|
||||
cbi->cvars_str = HCL_NULL;
|
||||
}
|
||||
if (cbi->ivars_str)
|
||||
{
|
||||
hcl_freemem (hcl, cbi->ivars_str);
|
||||
cbi->ivars_str = HCL_NULL;
|
||||
}
|
||||
|
||||
fini_class_level_variable_buffer (hcl, &cbi->ivars);
|
||||
fini_class_level_variable_buffer (hcl, &cbi->cvars);
|
||||
hcl->c->clsblk.depth--;
|
||||
|
@ -746,8 +746,6 @@ struct hcl_clsblk_info_t
|
||||
|
||||
hcl_oow_t nivars;
|
||||
hcl_oow_t ncvars;
|
||||
hcl_ooch_t* ivars_str;
|
||||
hcl_ooch_t* cvars_str;
|
||||
hcl_oow_t spec; /* TODO: byte indexed, word indexed? */
|
||||
|
||||
hcl_ooi_t funblk_base;
|
||||
|
Loading…
Reference in New Issue
Block a user