added hcl_executefromip()
This commit is contained in:
parent
08d6f4b4ad
commit
49363231a1
13
lib/exec.c
13
lib/exec.c
@ -1148,7 +1148,7 @@ static hcl_oop_process_t start_initial_process (hcl_t* hcl, hcl_oop_context_t ct
|
|||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_initial_process_and_context (hcl_t* hcl)
|
static int start_initial_process_and_context (hcl_t* hcl, hcl_ooi_t initial_ip)
|
||||||
{
|
{
|
||||||
hcl_oop_context_t ctx;
|
hcl_oop_context_t ctx;
|
||||||
hcl_oop_process_t proc;
|
hcl_oop_process_t proc;
|
||||||
@ -1161,7 +1161,7 @@ static int start_initial_process_and_context (hcl_t* hcl)
|
|||||||
* and is not really worked on except that it is used to call the
|
* and is not really worked on except that it is used to call the
|
||||||
* initial method. so it doesn't really require any extra stack space. */
|
* initial method. so it doesn't really require any extra stack space. */
|
||||||
/* TODO: verify this theory of mine. */
|
/* TODO: verify this theory of mine. */
|
||||||
hcl->ip = 0;
|
hcl->ip = initial_ip;
|
||||||
hcl->sp = -1;
|
hcl->sp = -1;
|
||||||
|
|
||||||
ctx->ip = HCL_SMOOI_TO_OOP(0); /* point to the beginning */
|
ctx->ip = HCL_SMOOI_TO_OOP(0); /* point to the beginning */
|
||||||
@ -2416,14 +2416,14 @@ oops:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hcl_execute (hcl_t* hcl)
|
int hcl_executefromip (hcl_t* hcl, hcl_ooi_t initial_ip)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
HCL_ASSERT (hcl, hcl->initial_context == HCL_NULL);
|
HCL_ASSERT (hcl, hcl->initial_context == HCL_NULL);
|
||||||
HCL_ASSERT (hcl, hcl->active_context == HCL_NULL);
|
HCL_ASSERT (hcl, hcl->active_context == HCL_NULL);
|
||||||
|
|
||||||
if (start_initial_process_and_context (hcl) <= -1) return -1;
|
if (start_initial_process_and_context(hcl, initial_ip) <= -1) return -1;
|
||||||
hcl->initial_context = hcl->processor->active->initial_context;
|
hcl->initial_context = hcl->processor->active->initial_context;
|
||||||
|
|
||||||
n = execute (hcl);
|
n = execute (hcl);
|
||||||
@ -2434,3 +2434,8 @@ int hcl_execute (hcl_t* hcl)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int hcl_execute (hcl_t* hcl)
|
||||||
|
{
|
||||||
|
return hcl_executefromip (hcl, 0);
|
||||||
|
}
|
||||||
|
@ -1557,6 +1557,11 @@ HCL_EXPORT int hcl_execute (
|
|||||||
hcl_t* hcl
|
hcl_t* hcl
|
||||||
);
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_executefromip (
|
||||||
|
hcl_t* hcl,
|
||||||
|
hcl_ooi_t initial_ip
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hcl_invoke() function sends a message named \a mthname to an object
|
* The hcl_invoke() function sends a message named \a mthname to an object
|
||||||
* named \a objname.
|
* named \a objname.
|
||||||
|
@ -1029,6 +1029,10 @@ int main (int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
hcl_oow_t code_offset;
|
||||||
|
|
||||||
|
code_offset = hcl->code.bc.len;
|
||||||
|
|
||||||
hcl_proutbfmt (hcl, 0, "\n");
|
hcl_proutbfmt (hcl, 0, "\n");
|
||||||
if (hcl_compile(hcl, obj) <= -1)
|
if (hcl_compile(hcl, obj) <= -1)
|
||||||
{
|
{
|
||||||
@ -1041,6 +1045,8 @@ 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));
|
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot compile object - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
||||||
}
|
}
|
||||||
/* carry on? */
|
/* carry on? */
|
||||||
|
|
||||||
|
hcl->code.bc.len = code_offset; /* just in case */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1048,7 +1054,7 @@ int main (int argc, char* argv[])
|
|||||||
HCL_LOG0 (hcl, HCL_LOG_MNEMONIC, "------------------------------------------\n");
|
HCL_LOG0 (hcl, HCL_LOG_MNEMONIC, "------------------------------------------\n");
|
||||||
g_hcl = hcl;
|
g_hcl = hcl;
|
||||||
//setup_tick ();
|
//setup_tick ();
|
||||||
if (hcl_execute(hcl) <= -1)
|
if (hcl_executefromip(hcl, code_offset) <= -1)
|
||||||
{
|
{
|
||||||
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot execute - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot execute - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user