renamed clear_io_names() to moo_clearcionames().
attempting to write a fucntion that gives a source line for an instruction pointer
This commit is contained in:
parent
b3eb804f87
commit
4afe4b459d
@ -2352,7 +2352,7 @@ retry:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_io_names (moo_t* moo)
|
void moo_clearcionames (moo_t* moo)
|
||||||
{
|
{
|
||||||
moo_iolink_t* cur;
|
moo_iolink_t* cur;
|
||||||
|
|
||||||
@ -7026,7 +7026,13 @@ static int add_compiled_method (moo_t* moo)
|
|||||||
if (moo_addmethodtodbgi(moo, file_offset, cc->dbgi_class_offset, cc->mth.name.ptr, cc->mth.code.locptr, cc->mth.code.len, &method_offset) <= -1)
|
if (moo_addmethodtodbgi(moo, file_offset, cc->dbgi_class_offset, cc->mth.name.ptr, cc->mth.code.locptr, cc->mth.code.len, &method_offset) <= -1)
|
||||||
{
|
{
|
||||||
/* TODO: warning. no debug information about this method will be available */
|
/* TODO: warning. no debug information about this method will be available */
|
||||||
|
method_offset = 0;
|
||||||
}
|
}
|
||||||
|
else if (method_offset > MOO_SMOOI_MAX)
|
||||||
|
{
|
||||||
|
method_offset = 90;
|
||||||
|
}
|
||||||
|
/* TODO mth->code_sline = MOO_SMOOI_TO_OOP(method_offset); */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*TODO: preserve source??? mth->text = cc->mth.text
|
/*TODO: preserve source??? mth->text = cc->mth.text
|
||||||
@ -9681,7 +9687,7 @@ static void fini_compiler (moo_t* moo)
|
|||||||
/* called before the moo object is closed */
|
/* called before the moo object is closed */
|
||||||
if (moo->c)
|
if (moo->c)
|
||||||
{
|
{
|
||||||
clear_io_names (moo);
|
moo_clearcionames (moo);
|
||||||
|
|
||||||
if (moo->c->tok.name.ptr) moo_freemem (moo, moo->c->tok.name.ptr);
|
if (moo->c->tok.name.ptr) moo_freemem (moo, moo->c->tok.name.ptr);
|
||||||
if (moo->c->balit.ptr) moo_freemem (moo, moo->c->balit.ptr);
|
if (moo->c->balit.ptr) moo_freemem (moo, moo->c->balit.ptr);
|
||||||
@ -9731,7 +9737,7 @@ static MOO_INLINE int _compile (moo_t* moo, moo_ioimpl_t io)
|
|||||||
* I clear such names before i begin this function. i don't clear it
|
* I clear such names before i begin this function. i don't clear it
|
||||||
* at the end of this function because i may be referenced as an error
|
* at the end of this function because i may be referenced as an error
|
||||||
* location */
|
* location */
|
||||||
clear_io_names (moo);
|
moo_clearcionames (moo);
|
||||||
|
|
||||||
/* reset pragma flags */
|
/* reset pragma flags */
|
||||||
moo->c->pragma_flags = 0;
|
moo->c->pragma_flags = 0;
|
||||||
|
@ -2217,15 +2217,16 @@ static moo_pfrc_t pf_context_find_exception_handler (moo_t* moo, moo_mod_t* mod,
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
static moo_pfrc_t pf_method_get_source_file (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
static moo_pfrc_t pf_method_get_source_file (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||||
{
|
|
||||||
moo_oop_t retv = moo->_nil;
|
|
||||||
|
|
||||||
if (moo->dbgi)
|
|
||||||
{
|
{
|
||||||
moo_oop_method_t rcv;
|
moo_oop_method_t rcv;
|
||||||
|
moo_oop_t retv = moo->_nil;
|
||||||
|
|
||||||
/* TODO: return something else lighter-weight than a string? */
|
/* TODO: return something else lighter-weight than a string? */
|
||||||
rcv = (moo_oop_method_t)MOO_STACK_GETRCV(moo, nargs);
|
rcv = (moo_oop_method_t)MOO_STACK_GETRCV(moo, nargs);
|
||||||
|
MOO_PF_CHECK_RCV (moo, MOO_CLASSOF(moo, rcv) == moo->_method);
|
||||||
|
|
||||||
|
if (moo->dbgi)
|
||||||
|
{
|
||||||
if (MOO_OOP_IS_SMOOI(rcv->source_file) && MOO_OOP_TO_SMOOI(rcv->source_file) > 0)
|
if (MOO_OOP_IS_SMOOI(rcv->source_file) && MOO_OOP_TO_SMOOI(rcv->source_file) > 0)
|
||||||
{
|
{
|
||||||
moo_dbgi_file_t* di;
|
moo_dbgi_file_t* di;
|
||||||
@ -2246,6 +2247,38 @@ static moo_pfrc_t pf_method_get_source_file (moo_t* moo, moo_mod_t* mod, moo_ooi
|
|||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static moo_pfrc_t pf_method_get_code_source_line (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||||
|
{
|
||||||
|
/* get source line of the given instruction pointer */
|
||||||
|
moo_oop_method_t rcv;
|
||||||
|
|
||||||
|
rcv = (moo_oop_method_t)MOO_STACK_GETRCV(moo, nargs);
|
||||||
|
MOO_PF_CHECK_RCV (moo, MOO_CLASSOF(moo, rcv) == moo->_method);
|
||||||
|
|
||||||
|
if (moo->dbgi && MOO_OOP_IS_SMOOI(rcv->source_line))
|
||||||
|
{
|
||||||
|
moo_oop_t ip;
|
||||||
|
moo_ooi_t source_line, ipv;
|
||||||
|
|
||||||
|
ip = MOO_STACK_GETARG(moo, nargs, 0);
|
||||||
|
MOO_PF_CHECK_ARGS (moo, nargs, MOO_OOP_IS_SMOOI(ip));
|
||||||
|
|
||||||
|
source_line = MOO_OOP_TO_SMOOI(rcv->source_line);
|
||||||
|
ipv = MOO_OOP_TO_SMOOI(ip);
|
||||||
|
#if 0
|
||||||
|
if (MOO_OOP_IS_SMOOI(rcv->code_sline))
|
||||||
|
{
|
||||||
|
moo_dbgi_method_t* di;
|
||||||
|
|
||||||
|
di = (moo_dbgi_method_t*)&((moo_uint8_t*)moo->dbgi)[MOO_OOP_TO_SMOOI(rcv->code_sline)];
|
||||||
|
/* ... TODO .. */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return MOO_PF_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_ooi_t nargs, moo_ooi_t num_first_arg_elems, moo_oop_context_t* pblkctx)
|
static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_ooi_t nargs, moo_ooi_t num_first_arg_elems, moo_oop_context_t* pblkctx)
|
||||||
|
@ -1679,6 +1679,7 @@ int moo_addmethodtodbgi (moo_t* moo, moo_oow_t file_offset, moo_oow_t class_offs
|
|||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
#if defined(MOO_INCLUDE_COMPILER)
|
#if defined(MOO_INCLUDE_COMPILER)
|
||||||
const moo_ooch_t* moo_addcioname (moo_t* moo, const moo_oocs_t* name);
|
const moo_ooch_t* moo_addcioname (moo_t* moo, const moo_oocs_t* name);
|
||||||
|
void moo_clearcionames (moo_t* moo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
@ -586,8 +586,9 @@ struct moo_method_t
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
moo_oop_t source_text; /* source text. String if available. nil if not */
|
moo_oop_t source_text; /* source text. String if available. nil if not */
|
||||||
moo_oop_t source_file; /* SmallInteger. source file path that contains the definition of this method. offset from moo->dbgi. 0 for the main stream. */
|
moo_oop_t source_file; /* SmallInteger. source file path that contains the definition of this method. offset from moo->dbgi. 0 if unavailable */
|
||||||
moo_oop_t source_line; /* SmallInteger. line of the source file where the method definition begins. valid only if source_file is not nil */
|
moo_oop_t source_line; /* SmallInteger. line of the source file where the method definition begins. valid only if source_file is greater than 0 */
|
||||||
|
//moo_oop_t code_line; /* SmallInteger */
|
||||||
|
|
||||||
/* == variable indexed part == */
|
/* == variable indexed part == */
|
||||||
moo_oop_t literal_frame[1]; /* it stores literals */
|
moo_oop_t literal_frame[1]; /* it stores literals */
|
||||||
|
Loading…
Reference in New Issue
Block a user