set default type mask in moo_compile() and moo_executefromip().
changed the main program a little bit
This commit is contained in:
parent
d78714432a
commit
f27ae54982
10
lib/comp.c
10
lib/comp.c
@ -2242,16 +2242,20 @@ static HCL_INLINE int emit_set (hcl_t* hcl)
|
||||
int hcl_compile (hcl_t* hcl, hcl_oop_t obj)
|
||||
{
|
||||
hcl_oow_t saved_bc_len, saved_lit_len;
|
||||
int log_default_type_mask;
|
||||
|
||||
HCL_ASSERT (hcl, GET_TOP_CFRAME_INDEX(hcl) < 0);
|
||||
|
||||
saved_bc_len = hcl->code.bc.len;
|
||||
saved_lit_len = hcl->code.lit.len;
|
||||
|
||||
log_default_type_mask = hcl->log.default_type_mask;
|
||||
hcl->log.default_type_mask |= HCL_LOG_COMPILER;
|
||||
|
||||
HCL_ASSERT (hcl, hcl->c->tv.size == 0);
|
||||
HCL_ASSERT (hcl, hcl->c->blk.depth == -1);
|
||||
|
||||
/* TODO: in case i implement all global variables as block arguments at the top level... */
|
||||
/* TODO: in case i implement all global variables as block arguments at the top level...what should i do? */
|
||||
hcl->c->blk.depth++;
|
||||
if (store_temporary_variable_count_for_block(hcl, hcl->c->tv.size) <= -1) return -1;
|
||||
|
||||
@ -2379,11 +2383,15 @@ int hcl_compile (hcl_t* hcl, hcl_oop_t obj)
|
||||
HCL_ASSERT (hcl, hcl->c->tv.size == 0);
|
||||
HCL_ASSERT (hcl, hcl->c->blk.depth == 0);
|
||||
hcl->c->blk.depth--;
|
||||
|
||||
hcl ->log.default_type_mask = log_default_type_mask;
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
POP_ALL_CFRAMES (hcl);
|
||||
|
||||
hcl->log.default_type_mask = log_default_type_mask;
|
||||
|
||||
/* rollback any bytecodes or literals emitted so far */
|
||||
hcl->code.bc.len = saved_bc_len;
|
||||
hcl->code.lit.len = saved_lit_len;
|
||||
|
10
lib/exec.c
10
lib/exec.c
@ -117,7 +117,7 @@ static HCL_INLINE const char* proc_state_to_string (int state)
|
||||
|
||||
static int vm_startup (hcl_t* hcl)
|
||||
{
|
||||
HCL_DEBUG0 (hcl, "VM started up\n");
|
||||
HCL_DEBUG1 (hcl, "VM started up at IP %zd\n", hcl->ip);
|
||||
|
||||
if (hcl->vmprim.vm_startup(hcl) <= -1) return -1;
|
||||
hcl->vmprim.vm_gettime (hcl, &hcl->exec_start_time); /* raw time. no adjustment */
|
||||
@ -129,7 +129,7 @@ static void vm_cleanup (hcl_t* hcl)
|
||||
{
|
||||
hcl->vmprim.vm_gettime (hcl, &hcl->exec_end_time); /* raw time. no adjustment */
|
||||
hcl->vmprim.vm_cleanup (hcl);
|
||||
HCL_DEBUG0 (hcl, "VM started up\n");
|
||||
HCL_DEBUG1 (hcl, "VM cleaned up at IP %zd\n", hcl->ip);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -2270,6 +2270,10 @@ oops:
|
||||
int hcl_executefromip (hcl_t* hcl, hcl_ooi_t initial_ip)
|
||||
{
|
||||
int n;
|
||||
int log_default_type_mask;
|
||||
|
||||
log_default_type_mask = hcl->log.default_type_mask;
|
||||
hcl->log.default_type_mask |= HCL_LOG_VM;
|
||||
|
||||
HCL_ASSERT (hcl, hcl->initial_context == HCL_NULL);
|
||||
HCL_ASSERT (hcl, hcl->active_context == HCL_NULL);
|
||||
@ -2282,6 +2286,8 @@ int hcl_executefromip (hcl_t* hcl, hcl_ooi_t initial_ip)
|
||||
/* TODO: reset processor fields. set processor->tally to zero. processor->active to nil_process... */
|
||||
hcl->initial_context = HCL_NULL;
|
||||
hcl->active_context = HCL_NULL;
|
||||
|
||||
hcl->log.default_type_mask = log_default_type_mask;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
44
lib/main.c
44
lib/main.c
@ -93,6 +93,8 @@ struct xtn_t
|
||||
int logfd;
|
||||
int logmask;
|
||||
int logfd_istty;
|
||||
|
||||
int reader_istty;
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
@ -201,6 +203,11 @@ static HCL_INLINE hcl_ooi_t open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (!arg->includer)
|
||||
{
|
||||
xtn->reader_istty = isatty(fileno(bb->fp));
|
||||
}
|
||||
|
||||
arg->handle = bb;
|
||||
return 0;
|
||||
|
||||
@ -1235,7 +1242,6 @@ int main (int argc, char* argv[])
|
||||
|
||||
{
|
||||
hcl_oow_t tab_size;
|
||||
|
||||
tab_size = 5000;
|
||||
hcl_setoption (hcl, HCL_SYMTAB_SIZE, &tab_size);
|
||||
tab_size = 5000;
|
||||
@ -1361,12 +1367,10 @@ int main (int argc, char* argv[])
|
||||
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot compile object - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
||||
}
|
||||
/* carry on? */
|
||||
|
||||
hcl->code.bc.len = code_offset; /* just in case */
|
||||
}
|
||||
else
|
||||
else if (xtn->reader_istty)
|
||||
{
|
||||
hcl_decode (hcl, 0, hcl->code.bc.len);
|
||||
hcl_decode (hcl, code_offset, hcl->code.bc.len - code_offset);
|
||||
HCL_LOG0 (hcl, HCL_LOG_MNEMONIC, "------------------------------------------\n");
|
||||
g_hcl = hcl;
|
||||
//setup_tick ();
|
||||
@ -1378,27 +1382,25 @@ int main (int argc, char* argv[])
|
||||
g_hcl = HCL_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
HCL_LOG0 (hcl, HCL_LOG_MNEMONIC, "------------------------------------------\n");
|
||||
HCL_LOG2 (hcl, HCL_LOG_MNEMONIC, "BYTECODES hcl->code.bc.len = > %lu hcl->code.lit.len => %lu\n",
|
||||
if (!xtn->reader_istty)
|
||||
{
|
||||
hcl_decode (hcl, 0, hcl->code.bc.len);
|
||||
HCL_LOG2 (hcl, HCL_LOG_MNEMONIC, "BYTECODES hcl->code.bc.len = > %lu hcl->code.lit.len => %lu\n",
|
||||
(unsigned long int)hcl->code.bc.len, (unsigned long int)hcl->code.lit.len);
|
||||
hcl_decode (hcl, 0, hcl->code.bc.len);
|
||||
|
||||
/*hcl_dumpsymtab (hcl);*/
|
||||
}
|
||||
|
||||
g_hcl = hcl;
|
||||
//setup_tick ();
|
||||
if (hcl_execute(hcl) <= -1)
|
||||
{
|
||||
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot execute - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
||||
}
|
||||
//cancel_tick();
|
||||
g_hcl = HCL_NULL;
|
||||
/*hcl_dumpsymtab (hcl);*/
|
||||
}
|
||||
|
||||
hcl_close (hcl);
|
||||
|
||||
#if defined(_WIN32) && defined(_DEBUG)
|
||||
getchar();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user