reorganized moo_duputobcstr(), moo_dupbtoucstr(), moo_dupbtouchars(), moo_duputobchars().
renamed add_io_name() to moo_addcioname(). changed input_handler in std.c to set arg->name when opening a file with moo_addcioname(). shortened dbginfo to dbgi. enhanced the compiler to record the class location in dbgi
This commit is contained in:
parent
b4c6e6a9de
commit
b3eb804f87
@ -241,8 +241,8 @@ int main (int argc, char* argv[])
|
||||
}
|
||||
|
||||
/* TODO: don't initialize debug information if debug info is not requested.
|
||||
* call moo_loaddbginfo() if loading a compiled image... */
|
||||
if (moo_initdbginfo(moo, 102400) <= -1) /* TODO: set initial debug information size from a configurable value */
|
||||
* call moo_loaddbgi() if loading a compiled image... */
|
||||
if (moo_initdbgi(moo, 102400) <= -1) /* TODO: set initial debug information size from a configurable value */
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot initialize debug information - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo));
|
||||
moo_close (moo);
|
||||
|
@ -69,12 +69,18 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
|
||||
//thisContext unwindTo: nil return: nil.
|
||||
//thisContext unwindTo: (Processor activeProcess initialContext) return: nil.
|
||||
|
||||
// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE...
|
||||
// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... MOVE THIS TO System>>backtrace and skip the first method context for backtrace itself.
|
||||
System logNl: "== BACKTRACE ==".
|
||||
ctx := thisContext.
|
||||
while (ctx notNil)
|
||||
{
|
||||
if (ctx class == MethodContext) { System logNl: (" " & ctx method owner name & ">>" & ctx method name & " (" & ctx method sourceFile & " " & ctx method sourceLine asString & ")"). }.
|
||||
if (ctx class == MethodContext)
|
||||
{
|
||||
System logNl: (" " & ctx method owner name & ">>" & ctx method name &
|
||||
" (" & ctx method sourceFile & " " & ctx method sourceLine asString & ")").
|
||||
// TODO: get location of the current pc and include it... (ctx method sourceLine: ctx pc) asString dump.
|
||||
|
||||
}.
|
||||
// TODO: include blockcontext???
|
||||
ctx := ctx sender.
|
||||
}.
|
||||
|
@ -92,6 +92,7 @@ class MyObject(Object)
|
||||
tb := tc at: idx.
|
||||
System log(System.Log.INFO, idx asString, (if (tb value) { " PASS" } else { " FAIL" }), "\n").
|
||||
].
|
||||
Exception signal: 'xxx'.
|
||||
|
||||
// TODO:
|
||||
String format("%s", " 나 는\\\"") dump.
|
||||
|
@ -246,6 +246,8 @@ enum voca_id_t
|
||||
};
|
||||
typedef enum voca_id_t voca_id_t;
|
||||
|
||||
static moo_ooch_t _nul = '\0';
|
||||
|
||||
static int compile_pooldic_definition (moo_t* moo);
|
||||
static int compile_interface_definition (moo_t* moo);
|
||||
static int compile_class_definition (moo_t* moo, int class_type);
|
||||
@ -452,22 +454,23 @@ static int copy_string_to (moo_t* moo, const moo_oocs_t* src, moo_oocs_t* dst, m
|
||||
len = src->len;
|
||||
}
|
||||
|
||||
if (len > *dst_capa)
|
||||
if (len >= *dst_capa)
|
||||
{
|
||||
moo_ooch_t* tmp;
|
||||
moo_oow_t capa;
|
||||
|
||||
capa = MOO_ALIGN(len, CLASS_BUFFER_ALIGN);
|
||||
capa = MOO_ALIGN(len + 1, CLASS_BUFFER_ALIGN);
|
||||
|
||||
tmp = (moo_ooch_t*)moo_reallocmem(moo, dst->ptr, MOO_SIZEOF(*tmp) * capa);
|
||||
if (!tmp) return -1;
|
||||
|
||||
dst->ptr = tmp;
|
||||
*dst_capa = capa;
|
||||
*dst_capa = capa - 1;
|
||||
}
|
||||
|
||||
if (append && delim_char != '\0') dst->ptr[pos++] = delim_char;
|
||||
moo_copy_oochars (&dst->ptr[pos], src->ptr, src->len);
|
||||
dst->ptr[len] = '\0';
|
||||
dst->len = len;
|
||||
return 0;
|
||||
}
|
||||
@ -556,7 +559,7 @@ static int add_oop_to_oopbuf (moo_t* moo, moo_oopbuf_t* oopbuf, moo_oop_t item)
|
||||
moo_oop_t* tmp;
|
||||
moo_oow_t new_capa;
|
||||
|
||||
new_capa = MOO_ALIGN (oopbuf->count + 1, ARLIT_BUFFER_ALIGN);
|
||||
new_capa = MOO_ALIGN(oopbuf->count + 1, ARLIT_BUFFER_ALIGN);
|
||||
tmp = (moo_oop_t*)moo_reallocmem(moo, oopbuf->ptr, new_capa * MOO_SIZEOF(*tmp));
|
||||
if (!tmp) return -1;
|
||||
|
||||
@ -2363,12 +2366,12 @@ static void clear_io_names (moo_t* moo)
|
||||
}
|
||||
}
|
||||
|
||||
static const moo_ooch_t* add_io_name (moo_t* moo, const moo_oocs_t* name)
|
||||
const moo_ooch_t* moo_addcioname (moo_t* moo, const moo_oocs_t* name)
|
||||
{
|
||||
moo_iolink_t* link;
|
||||
moo_ooch_t* ptr;
|
||||
|
||||
link = (moo_iolink_t*) moo_callocmem (moo, MOO_SIZEOF(*link) + MOO_SIZEOF(moo_ooch_t) * (name->len + 1));
|
||||
link = (moo_iolink_t*)moo_callocmem(moo, MOO_SIZEOF(*link) + MOO_SIZEOF(moo_ooch_t) * (name->len + 1));
|
||||
if (!link) return MOO_NULL;
|
||||
|
||||
ptr = (moo_ooch_t*)(link + 1);
|
||||
@ -2387,10 +2390,10 @@ static int begin_include (moo_t* moo)
|
||||
moo_ioarg_t* arg;
|
||||
const moo_ooch_t* io_name;
|
||||
|
||||
io_name = add_io_name (moo, TOKEN_NAME(moo));
|
||||
io_name = moo_addcioname(moo, TOKEN_NAME(moo));
|
||||
if (!io_name) return -1;
|
||||
|
||||
arg = (moo_ioarg_t*) moo_callocmem (moo, MOO_SIZEOF(*arg));
|
||||
arg = (moo_ioarg_t*)moo_callocmem(moo, MOO_SIZEOF(*arg));
|
||||
if (!arg) goto oops;
|
||||
|
||||
arg->name = io_name;
|
||||
@ -2399,7 +2402,7 @@ static int begin_include (moo_t* moo)
|
||||
/*arg->nl = '\0';*/
|
||||
arg->includer = moo->c->curinp;
|
||||
|
||||
if (moo->c->impl (moo, MOO_IO_OPEN, arg) <= -1)
|
||||
if (moo->c->impl(moo, MOO_IO_OPEN, arg) <= -1)
|
||||
{
|
||||
moo_setsynerr (moo, MOO_SYNERR_INCLUDE, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
goto oops;
|
||||
@ -4158,7 +4161,6 @@ static int compile_method_name (moo_t* moo, moo_method_data_t* mth)
|
||||
* unary-selector := identifier
|
||||
*/
|
||||
int n;
|
||||
static moo_ooch_t _nul = '\0';
|
||||
moo_oocs_t dummy;
|
||||
|
||||
MOO_ASSERT (moo, mth->tmpr_count == 0);
|
||||
@ -4187,12 +4189,6 @@ static int compile_method_name (moo_t* moo, moo_method_data_t* mth)
|
||||
|
||||
if (n <= -1) return -1;
|
||||
|
||||
/* null terminate it for convenience */
|
||||
dummy.ptr = &_nul;
|
||||
dummy.len = 1;
|
||||
if (add_method_name_fragment(moo, mth, &dummy) <= -1) return -1;
|
||||
mth->name.len--; /* restore the method name length back */
|
||||
|
||||
if (method_exists(moo, &mth->name))
|
||||
{
|
||||
moo_setsynerr (moo, MOO_SYNERR_MTHNAMEDUPL, &mth->name_loc, &mth->name);
|
||||
@ -7006,36 +7002,28 @@ static int add_compiled_method (moo_t* moo)
|
||||
mth->source_line = MOO_SMOOI_TO_OOP(0);
|
||||
}
|
||||
|
||||
if (moo->dbginfo)
|
||||
if (moo->dbgi)
|
||||
{
|
||||
moo_oow_t file_offset;
|
||||
moo_oow_t class_offset;
|
||||
moo_oow_t method_offset;
|
||||
const moo_ooch_t* file_name;
|
||||
|
||||
if (cc->mth.code_start_loc.file)
|
||||
{
|
||||
if (moo_addfiletodbginfo(moo, cc->mth.code_start_loc.file, &file_offset) <= -1)
|
||||
file_name = cc->mth.code_start_loc.file;
|
||||
if (!file_name) file_name = &_nul;
|
||||
|
||||
if (moo_addfiletodbgi(moo, file_name, &file_offset) <= -1)
|
||||
{
|
||||
/* TODO: warning */
|
||||
file_offset = 0;
|
||||
}
|
||||
else if (file_offset > MOO_SMOOI_MAX)
|
||||
{
|
||||
/* TODO: warnign */
|
||||
file_offset = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* main stream */
|
||||
/* TODO: warning */
|
||||
file_offset = 0;
|
||||
}
|
||||
mth->source_file = MOO_SMOOI_TO_OOP(file_offset);
|
||||
|
||||
/* TODO: call moo_addclasstodbginfo() */
|
||||
class_offset = 0;
|
||||
|
||||
if (moo_addmethodtodbginfo(moo, file_offset, 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 */
|
||||
}
|
||||
@ -8517,6 +8505,33 @@ static int __compile_class_definition (moo_t* moo, int class_type)
|
||||
|
||||
GET_TOKEN (moo);
|
||||
|
||||
if (moo->dbgi)
|
||||
{
|
||||
moo_oow_t file_offset;
|
||||
moo_oow_t class_offset;
|
||||
const moo_ooch_t* file_name;
|
||||
|
||||
file_name = cc->fqn_loc.file;
|
||||
if (!file_name) file_name = &_nul;
|
||||
|
||||
if (moo_addfiletodbgi(moo, file_name, &file_offset) <= -1)
|
||||
{
|
||||
/* TODO: warning */
|
||||
file_offset = 0;
|
||||
}
|
||||
else if (file_offset > MOO_SMOOI_MAX)
|
||||
{
|
||||
/* TODO: warning */
|
||||
file_offset = 0;
|
||||
}
|
||||
|
||||
if (moo_addclasstodbgi(moo, cc->fqn.ptr, file_offset, cc->fqn_loc.line, &cc->dbgi_class_offset) <= -1)
|
||||
{
|
||||
/* TODO: warning. no debug information about this method will be available */
|
||||
}
|
||||
/* TODO: store source file offset and class offset in the class object only for NORMAL. make_defined_class is a good candidate to do this in. */
|
||||
}
|
||||
|
||||
if (class_type == CLASS_TYPE_EXTEND)
|
||||
{
|
||||
moo_oop_char_t pds;
|
||||
@ -9674,6 +9689,8 @@ static void fini_compiler (moo_t* moo)
|
||||
|
||||
while (moo->c->cunit) pop_cunit (moo);
|
||||
|
||||
if (moo->c->iid) moo_freemem (moo, moo->c->iid);
|
||||
|
||||
moo_freemem (moo, moo->c);
|
||||
moo->c = MOO_NULL;
|
||||
}
|
||||
@ -9730,7 +9747,7 @@ static MOO_INLINE int _compile (moo_t* moo, moo_ioimpl_t io)
|
||||
moo->c->arg.colm = 1;
|
||||
|
||||
/* open the top-level stream */
|
||||
n = moo->c->impl (moo, MOO_IO_OPEN, &moo->c->arg);
|
||||
n = moo->c->impl(moo, MOO_IO_OPEN, &moo->c->arg);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
/* the stream is open. set it as the current input stream */
|
||||
@ -9773,7 +9790,7 @@ int moo_compile (moo_t* moo, moo_ioimpl_t io)
|
||||
|
||||
log_default_type_mask = moo->log.default_type_mask;
|
||||
moo->log.default_type_mask |= MOO_LOG_COMPILER;
|
||||
n = _compile (moo, io);
|
||||
n = _compile(moo, io);
|
||||
moo->log.default_type_mask = log_default_type_mask;
|
||||
|
||||
return n;
|
||||
|
114
moo/lib/debug.c
114
moo/lib/debug.c
@ -68,18 +68,18 @@ void moo_dumpdic (moo_t* moo, moo_oop_dic_t dic, const moo_bch_t* title)
|
||||
}
|
||||
|
||||
|
||||
/* TODO: moo_loaddbginfofromimage() -> load debug information from compiled image?
|
||||
moo_storedbginfotoimage()? -> store debug information to compiled image?
|
||||
moo_compactdbginfo()? -> compact debug information by scaning dbginfo data. find class and method. if not found, drop the portion.
|
||||
/* TODO: moo_loaddbgifromimage() -> load debug information from compiled image?
|
||||
moo_storedbgitoimage()? -> store debug information to compiled image?
|
||||
moo_compactdbgi()? -> compact debug information by scaning dbgi data. find class and method. if not found, drop the portion.
|
||||
*/
|
||||
|
||||
int moo_initdbginfo (moo_t* moo, moo_oow_t capa)
|
||||
int moo_initdbgi (moo_t* moo, moo_oow_t capa)
|
||||
{
|
||||
moo_dbginfo_t* tmp;
|
||||
moo_dbgi_t* tmp;
|
||||
|
||||
if (capa < MOO_SIZEOF(*tmp)) capa = MOO_SIZEOF(*tmp);
|
||||
|
||||
tmp = (moo_dbginfo_t*)moo_callocmem(moo, capa);
|
||||
tmp = (moo_dbgi_t*)moo_callocmem(moo, capa);
|
||||
if (!tmp) return -1;
|
||||
|
||||
tmp->_capa = capa;
|
||||
@ -87,57 +87,57 @@ int moo_initdbginfo (moo_t* moo, moo_oow_t capa)
|
||||
tmp->_last_class = 0;
|
||||
tmp->_last_file = 0;
|
||||
|
||||
moo->dbginfo = tmp;
|
||||
moo->dbgi = tmp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void moo_finidbginfo (moo_t* moo)
|
||||
void moo_finidbgi (moo_t* moo)
|
||||
{
|
||||
if (moo->dbginfo)
|
||||
if (moo->dbgi)
|
||||
{
|
||||
moo_freemem (moo, moo->dbginfo);
|
||||
moo->dbginfo = MOO_NULL;
|
||||
moo_freemem (moo, moo->dbgi);
|
||||
moo->dbgi = MOO_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static MOO_INLINE moo_uint8_t* secure_dbginfo_space (moo_t* moo, moo_oow_t req_bytes)
|
||||
static MOO_INLINE moo_uint8_t* secure_dbgi_space (moo_t* moo, moo_oow_t req_bytes)
|
||||
{
|
||||
if (moo->dbginfo->_capa - moo->dbginfo->_len < req_bytes)
|
||||
if (moo->dbgi->_capa - moo->dbgi->_len < req_bytes)
|
||||
{
|
||||
moo_dbginfo_t* tmp;
|
||||
moo_dbgi_t* tmp;
|
||||
moo_oow_t newcapa;
|
||||
|
||||
newcapa = moo->dbginfo->_len + req_bytes;
|
||||
newcapa = moo->dbgi->_len + req_bytes;
|
||||
newcapa = MOO_ALIGN_POW2(newcapa, 65536); /* TODO: make the align value configurable */
|
||||
tmp = moo_reallocmem(moo, moo->dbginfo, newcapa);
|
||||
tmp = moo_reallocmem(moo, moo->dbgi, newcapa);
|
||||
if (!tmp) return MOO_NULL;
|
||||
|
||||
moo->dbginfo = tmp;
|
||||
moo->dbginfo->_capa = newcapa;
|
||||
moo->dbgi = tmp;
|
||||
moo->dbgi->_capa = newcapa;
|
||||
}
|
||||
|
||||
return &((moo_uint8_t*)moo->dbginfo)[moo->dbginfo->_len];
|
||||
return &((moo_uint8_t*)moo->dbgi)[moo->dbgi->_len];
|
||||
}
|
||||
|
||||
int moo_addfiletodbginfo (moo_t* moo, const moo_ooch_t* file_name, moo_oow_t* start_offset)
|
||||
int moo_addfiletodbgi (moo_t* moo, const moo_ooch_t* file_name, moo_oow_t* start_offset)
|
||||
{
|
||||
moo_oow_t name_len, name_bytes, name_bytes_aligned, req_bytes;
|
||||
moo_dbginfo_file_t* di;
|
||||
moo_dbgi_file_t* di;
|
||||
|
||||
if (!moo->dbginfo)
|
||||
if (!moo->dbgi)
|
||||
{
|
||||
if (start_offset) *start_offset = MOO_NULL;
|
||||
return 0; /* debug information is disabled*/
|
||||
}
|
||||
|
||||
if (moo->dbginfo->_last_file > 0)
|
||||
if (moo->dbgi->_last_file > 0)
|
||||
{
|
||||
/* TODO: avoid linear search. need indexing for speed up */
|
||||
moo_oow_t offset = moo->dbginfo->_last_file;
|
||||
moo_oow_t offset = moo->dbgi->_last_file;
|
||||
do
|
||||
{
|
||||
di = &((moo_uint8_t*)moo->dbginfo)[offset];
|
||||
if (moo_comp_oocstr(di + 1, file_name) == 0)
|
||||
di = (moo_dbgi_file_t*)&((moo_uint8_t*)moo->dbgi)[offset];
|
||||
if (moo_comp_oocstr((moo_ooch_t*)(di + 1), file_name) == 0)
|
||||
{
|
||||
if (start_offset) *start_offset = offset;
|
||||
return 0;
|
||||
@ -150,38 +150,38 @@ int moo_addfiletodbginfo (moo_t* moo, const moo_ooch_t* file_name, moo_oow_t* st
|
||||
name_len = moo_count_oocstr(file_name);
|
||||
name_bytes = (name_len + 1) * MOO_SIZEOF(*file_name);
|
||||
name_bytes_aligned = MOO_ALIGN_POW2(name_bytes, MOO_SIZEOF_OOW_T);
|
||||
req_bytes = MOO_SIZEOF(moo_dbginfo_file_t) + name_bytes_aligned;
|
||||
req_bytes = MOO_SIZEOF(moo_dbgi_file_t) + name_bytes_aligned;
|
||||
|
||||
di = (moo_dbginfo_file_t*)secure_dbginfo_space(moo, req_bytes);
|
||||
di = (moo_dbgi_file_t*)secure_dbgi_space(moo, req_bytes);
|
||||
if (!di) return -1;
|
||||
|
||||
di->_type = MOO_DBGINFO_MAKE_TYPE(MOO_DBGINFO_TYPE_CODE_FILE, 0);
|
||||
di->_len = req_bytes;
|
||||
di->_next = moo->dbginfo->_last_file;
|
||||
moo_copy_oocstr (di + 1, name_len + 1, file_name);
|
||||
di->_next = moo->dbgi->_last_file;
|
||||
moo_copy_oocstr ((moo_ooch_t*)(di + 1), name_len + 1, file_name);
|
||||
|
||||
moo->dbginfo->_last_file = moo->dbginfo->_len;
|
||||
moo->dbginfo->_len += req_bytes;
|
||||
moo->dbgi->_last_file = moo->dbgi->_len;
|
||||
moo->dbgi->_len += req_bytes;
|
||||
|
||||
if (start_offset) *start_offset = moo->dbginfo->_last_file;
|
||||
if (start_offset) *start_offset = moo->dbgi->_last_file;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int moo_addclasstodbginfo (moo_t* moo, const moo_ooch_t* class_name, moo_oow_t file_offset, moo_oow_t file_line, moo_oow_t* start_offset)
|
||||
int moo_addclasstodbgi (moo_t* moo, const moo_ooch_t* class_name, moo_oow_t file_offset, moo_oow_t file_line, moo_oow_t* start_offset)
|
||||
{
|
||||
moo_oow_t name_len, name_bytes, name_bytes_aligned, req_bytes;
|
||||
moo_dbginfo_class_t* di;
|
||||
moo_dbgi_class_t* di;
|
||||
|
||||
if (!moo->dbginfo) return 0; /* debug information is disabled*/
|
||||
if (!moo->dbgi) return 0; /* debug information is disabled*/
|
||||
|
||||
if (moo->dbginfo->_last_class > 0)
|
||||
if (moo->dbgi->_last_class > 0)
|
||||
{
|
||||
/* TODO: avoid linear search. need indexing for speed up */
|
||||
moo_oow_t offset = moo->dbginfo->_last_class;
|
||||
moo_oow_t offset = moo->dbgi->_last_class;
|
||||
do
|
||||
{
|
||||
di = &((moo_uint8_t*)moo->dbginfo)[offset];
|
||||
if (moo_comp_oocstr(di + 1, class_name) == 0 && di->_file == file_offset && di->_line == file_line)
|
||||
di = (moo_dbgi_class_t*)&((moo_uint8_t*)moo->dbgi)[offset];
|
||||
if (moo_comp_oocstr((moo_ooch_t*)(di + 1), class_name) == 0 && di->_file == file_offset && di->_line == file_line)
|
||||
{
|
||||
if (start_offset) *start_offset = offset;
|
||||
return 0;
|
||||
@ -194,55 +194,55 @@ int moo_addclasstodbginfo (moo_t* moo, const moo_ooch_t* class_name, moo_oow_t f
|
||||
name_len = moo_count_oocstr(class_name);
|
||||
name_bytes = (name_len + 1) * MOO_SIZEOF(*class_name);
|
||||
name_bytes_aligned = MOO_ALIGN_POW2(name_bytes, MOO_SIZEOF_OOW_T);
|
||||
req_bytes = MOO_SIZEOF(moo_dbginfo_class_t) + name_bytes_aligned;
|
||||
req_bytes = MOO_SIZEOF(moo_dbgi_class_t) + name_bytes_aligned;
|
||||
|
||||
di = (moo_dbginfo_class_t*)secure_dbginfo_space(moo, req_bytes);
|
||||
di = (moo_dbgi_class_t*)secure_dbgi_space(moo, req_bytes);
|
||||
if (!di) return -1;
|
||||
|
||||
di->_type = MOO_DBGINFO_MAKE_TYPE(MOO_DBGINFO_TYPE_CODE_CLASS, 0);
|
||||
di->_len = req_bytes;
|
||||
di->_next = moo->dbginfo->_last_class;
|
||||
di->_next = moo->dbgi->_last_class;
|
||||
di->_file = file_offset;
|
||||
di->_line = file_line;
|
||||
moo_copy_oocstr (di + 1, name_len + 1, class_name);
|
||||
moo_copy_oocstr ((moo_ooch_t*)(di + 1), name_len + 1, class_name);
|
||||
|
||||
moo->dbginfo->_last_class = moo->dbginfo->_len;
|
||||
moo->dbginfo->_len += req_bytes;
|
||||
moo->dbgi->_last_class = moo->dbgi->_len;
|
||||
moo->dbgi->_len += req_bytes;
|
||||
|
||||
if (start_offset) *start_offset = moo->dbginfo->_last_class;
|
||||
if (start_offset) *start_offset = moo->dbgi->_last_class;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int moo_addmethodtodbginfo (moo_t* moo, moo_oow_t file_offset, moo_oow_t class_offset, const moo_ooch_t* method_name, const moo_oow_t* code_loc_ptr, moo_oow_t code_loc_len, moo_oow_t* start_offset)
|
||||
int moo_addmethodtodbgi (moo_t* moo, moo_oow_t file_offset, moo_oow_t class_offset, const moo_ooch_t* method_name, const moo_oow_t* code_loc_ptr, moo_oow_t code_loc_len, moo_oow_t* start_offset)
|
||||
{
|
||||
moo_oow_t name_len, name_bytes, name_bytes_aligned, code_loc_bytes, code_loc_bytes_aligned, req_bytes;
|
||||
moo_dbginfo_method_t* di;
|
||||
moo_dbgi_method_t* di;
|
||||
|
||||
if (!moo->dbginfo) return 0; /* debug information is disabled*/
|
||||
if (!moo->dbgi) return 0; /* debug information is disabled*/
|
||||
|
||||
name_len = moo_count_oocstr(method_name);
|
||||
name_bytes = (name_len + 1) * MOO_SIZEOF(*method_name);
|
||||
name_bytes_aligned = MOO_ALIGN_POW2(name_bytes, MOO_SIZEOF_OOW_T);
|
||||
code_loc_bytes = code_loc_len * MOO_SIZEOF(*code_loc_ptr);
|
||||
code_loc_bytes_aligned = MOO_ALIGN_POW2(code_loc_bytes, MOO_SIZEOF_OOW_T);
|
||||
req_bytes = MOO_SIZEOF(moo_dbginfo_method_t) + name_bytes_aligned + code_loc_bytes_aligned;
|
||||
req_bytes = MOO_SIZEOF(moo_dbgi_method_t) + name_bytes_aligned + code_loc_bytes_aligned;
|
||||
|
||||
di = (moo_dbginfo_method_t*)secure_dbginfo_space(moo, req_bytes);
|
||||
di = (moo_dbgi_method_t*)secure_dbgi_space(moo, req_bytes);
|
||||
if (!di) return -1;
|
||||
|
||||
di->_type = MOO_DBGINFO_MAKE_TYPE(MOO_DBGINFO_TYPE_CODE_METHOD, 0);
|
||||
di->_len = req_bytes;
|
||||
di->_next = moo->dbginfo->_last_method;
|
||||
di->_next = moo->dbgi->_last_method;
|
||||
di->_file = file_offset;
|
||||
di->_class = class_offset;
|
||||
di->code_loc_len = code_loc_len;
|
||||
|
||||
moo_copy_oocstr (di + 1, name_len + 1, method_name);
|
||||
moo_copy_oocstr ((moo_ooch_t*)(di + 1), name_len + 1, method_name);
|
||||
MOO_MEMCPY ((moo_uint8_t*)(di + 1) + name_bytes_aligned, code_loc_ptr, code_loc_bytes);
|
||||
|
||||
moo->dbginfo->_last_method = moo->dbginfo->_len;
|
||||
moo->dbginfo->_len += req_bytes;
|
||||
moo->dbgi->_last_method = moo->dbgi->_len;
|
||||
moo->dbgi->_len += req_bytes;
|
||||
|
||||
if (start_offset) *start_offset = moo->dbginfo->_last_method;
|
||||
if (start_offset) *start_offset = moo->dbgi->_last_method;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2179,7 +2179,7 @@ static moo_pfrc_t pf_context_find_exception_handler (moo_t* moo, moo_mod_t* mod,
|
||||
rcv = (moo_oop_context_t)MOO_STACK_GETRCV(moo, nargs);
|
||||
MOO_PF_CHECK_RCV (moo, MOO_CLASSOF(moo,rcv) == moo->_method_context);
|
||||
|
||||
except_class = MOO_STACK_GETARG(moo, nargs, 0);
|
||||
except_class = (moo_oop_class_t)MOO_STACK_GETARG(moo, nargs, 0);
|
||||
MOO_PF_CHECK_ARGS (moo, nargs, MOO_CLASSOF(moo,rcv) == moo->_class);
|
||||
|
||||
preamble = MOO_OOP_TO_SMOOI(((moo_oop_method_t)rcv->method_or_nargs)->preamble);
|
||||
@ -2218,33 +2218,31 @@ 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)
|
||||
{
|
||||
moo_oop_t retv = moo->_nil;
|
||||
|
||||
if (moo->dbgi)
|
||||
{
|
||||
moo_oop_method_t rcv;
|
||||
moo_oop_t tmp;
|
||||
|
||||
if (moo->dbginfo)
|
||||
/* TODO: return something else lighter-weight than a string? */
|
||||
rcv = (moo_oop_method_t)MOO_STACK_GETRCV(moo, nargs);
|
||||
if (MOO_OOP_IS_SMOOI(rcv->source_file) && MOO_OOP_TO_SMOOI(rcv->source_file) > 0)
|
||||
{
|
||||
/* TODO: return sothing else lighter-weight than a string? */
|
||||
rcv = (moo_oop_method_t*)MOO_STACK_GETRCV(moo, nargs);
|
||||
if (rcv->source_file == MOO_SMOOI_TO_OOP(0))
|
||||
{
|
||||
/* TOOD: use the actual name as given by the caller ? */
|
||||
tmp = moo_makestringwithbchars(moo, "<MAIN>", 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
moo_dbginfo_file_t* di;
|
||||
di = (moo_dbginfo_file_t*)&((moo_uint8_t*)moo->dbginfo)[MOO_OOP_TO_SMOOI(rcv->source_file)];
|
||||
tmp = moo_makestring(moo, di + 1, moo_count_oocstr(di + 1));
|
||||
}
|
||||
if (!tmp) return MOO_PF_FAILURE;
|
||||
moo_dbgi_file_t* di;
|
||||
const moo_ooch_t* file_name;
|
||||
|
||||
MOO_STACK_SETRET (moo, nargs, tmp);
|
||||
di = (moo_dbgi_file_t*)&((moo_uint8_t*)moo->dbgi)[MOO_OOP_TO_SMOOI(rcv->source_file)];
|
||||
/* TODO: check if di is the file type... otherwise, it's internal corruption */
|
||||
|
||||
file_name = (const moo_ooch_t*)(di + 1);
|
||||
moo_pushvolat (moo, &retv);
|
||||
retv = moo_makestring(moo, file_name, moo_count_oocstr(file_name));
|
||||
moo_popvolat (moo);
|
||||
if (!retv) return MOO_PF_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
MOO_STACK_SETRET (moo, nargs, moo->_nil);
|
||||
}
|
||||
|
||||
MOO_STACK_SETRET (moo, nargs, retv);
|
||||
return MOO_PF_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -595,6 +595,8 @@ struct moo_cunit_class_t
|
||||
moo_oow_t initv_count;
|
||||
} var[3];
|
||||
|
||||
moo_oow_t dbgi_class_offset;
|
||||
|
||||
moo_pooldic_import_data_t pdimp;
|
||||
moo_method_data_t mth;
|
||||
};
|
||||
@ -620,6 +622,7 @@ struct moo_compiler_t
|
||||
|
||||
/* input handler */
|
||||
moo_ioimpl_t impl;
|
||||
moo_ooch_t* iid; /* input id that represents the current main input file */
|
||||
|
||||
/* information about the last meaningful character read.
|
||||
* this is a copy of curinp->lxc if no ungetting is performed.
|
||||
@ -1658,18 +1661,26 @@ moo_pfrc_t moo_pf_utf8_seqlen (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
|
||||
moo_pfrc_t moo_pf_utf8_to_uc (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
|
||||
moo_pfrc_t moo_pf_uc_to_utf8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
|
||||
|
||||
/* TODO: remove the following debugging functions */
|
||||
|
||||
/* ========================================================================= */
|
||||
/* debug.c */
|
||||
/* ========================================================================= */
|
||||
/* TODO: remove the following dump functions */
|
||||
void moo_dumpsymtab (moo_t* moo);
|
||||
void moo_dumpdic (moo_t* moo, moo_oop_dic_t dic, const moo_bch_t* title);
|
||||
|
||||
int moo_addfiletodbginfo (moo_t* moo, const moo_ooch_t* file_name, moo_oow_t* start_offset);
|
||||
int moo_addclasstodbginfo (moo_t* moo, const moo_ooch_t* class_name, moo_oow_t file_offset, moo_oow_t file_line, moo_oow_t* start_offset);
|
||||
int moo_addmethodtodbginfo (moo_t* moo, moo_oow_t file_offset, moo_oow_t class_offset, const moo_ooch_t* method_name, const moo_oow_t* code_loc_ptr, moo_oow_t code_loc_len, moo_oow_t* start_offset);
|
||||
int moo_addfiletodbgi (moo_t* moo, const moo_ooch_t* file_name, moo_oow_t* start_offset);
|
||||
int moo_addclasstodbgi (moo_t* moo, const moo_ooch_t* class_name, moo_oow_t file_offset, moo_oow_t file_line, moo_oow_t* start_offset);
|
||||
int moo_addmethodtodbgi (moo_t* moo, moo_oow_t file_offset, moo_oow_t class_offset, const moo_ooch_t* method_name, const moo_oow_t* code_loc_ptr, moo_oow_t code_loc_len, moo_oow_t* start_offset);
|
||||
|
||||
|
||||
/* ========================================================================= */
|
||||
/* comp.c */
|
||||
/* ========================================================================= */
|
||||
#if defined(MOO_INCLUDE_COMPILER)
|
||||
const moo_ooch_t* moo_addcioname (moo_t* moo, const moo_oocs_t* name);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -108,11 +108,13 @@ MOO_EXPORT void moo_abortstd (
|
||||
moo_t* moo
|
||||
);
|
||||
|
||||
#if defined(MOO_INCLUDE_COMPILER)
|
||||
MOO_EXPORT int moo_compilestd(
|
||||
moo_t* moo,
|
||||
const moo_iostd_t* in,
|
||||
moo_oow_t count
|
||||
);
|
||||
#endif
|
||||
|
||||
MOO_EXPORT void moo_rcvtickstd (
|
||||
moo_t* moo,
|
||||
|
@ -249,7 +249,7 @@ void moo_fini (moo_t* moo)
|
||||
* the heap may not exist */
|
||||
if (moo->heap) moo_killheap (moo, moo->heap);
|
||||
|
||||
moo_finidbginfo (moo);
|
||||
moo_finidbgi (moo);
|
||||
|
||||
for (i = 0; i < MOO_COUNTOF(moo->sbuf); i++)
|
||||
{
|
||||
|
132
moo/lib/moo.h
132
moo/lib/moo.h
@ -586,7 +586,7 @@ struct moo_method_t
|
||||
#endif
|
||||
|
||||
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->dbginfo. 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 for the main stream. */
|
||||
moo_oop_t source_line; /* SmallInteger. line of the source file where the method definition begins. valid only if source_file is not nil */
|
||||
|
||||
/* == variable indexed part == */
|
||||
@ -944,8 +944,8 @@ struct moo_heap_t
|
||||
moo_space_t newspace;
|
||||
};
|
||||
|
||||
typedef struct moo_dbginfo_t moo_dbginfo_t;
|
||||
struct moo_dbginfo_t
|
||||
typedef struct moo_dbgi_t moo_dbgi_t;
|
||||
struct moo_dbgi_t
|
||||
{
|
||||
moo_oow_t _capa;
|
||||
moo_oow_t _len;
|
||||
@ -955,7 +955,7 @@ struct moo_dbginfo_t
|
||||
/* actual information is recorded here */
|
||||
};
|
||||
|
||||
enum moo_dbginfo_type_t
|
||||
enum moo_dbgi_type_t
|
||||
{
|
||||
/* bit 8 to bit 15 */
|
||||
MOO_DBGINFO_TYPE_CODE_FILE = 0,
|
||||
@ -966,12 +966,12 @@ enum moo_dbginfo_type_t
|
||||
/* low 8 bits */
|
||||
MOO_DBGINFO_TYPE_FLAG_INVALID = (1 << 0)
|
||||
};
|
||||
typedef enum moo_dbginfo_type_t moo_dbginfo_type_t;
|
||||
typedef enum moo_dbgi_type_t moo_dbgi_type_t;
|
||||
|
||||
#define MOO_DBGINFO_MAKE_TYPE(code,flags) (((code) << 8) | (flags))
|
||||
|
||||
typedef struct moo_dbginfo_file_t moo_dbginfo_file_t;
|
||||
struct moo_dbginfo_file_t
|
||||
typedef struct moo_dbgi_file_t moo_dbgi_file_t;
|
||||
struct moo_dbgi_file_t
|
||||
{
|
||||
moo_oow_t _type;
|
||||
moo_oow_t _len;
|
||||
@ -979,8 +979,8 @@ struct moo_dbginfo_file_t
|
||||
/* ... file path here ... */
|
||||
};
|
||||
|
||||
typedef struct moo_dbginfo_class_t moo_dbginfo_class_t;
|
||||
struct moo_dbginfo_class_t
|
||||
typedef struct moo_dbgi_class_t moo_dbgi_class_t;
|
||||
struct moo_dbgi_class_t
|
||||
{
|
||||
moo_oow_t _type;
|
||||
moo_oow_t _len;
|
||||
@ -990,8 +990,8 @@ struct moo_dbginfo_class_t
|
||||
/* ... class name here ... */
|
||||
};
|
||||
|
||||
typedef struct moo_dbginfo_method_t moo_dbginfo_method_t;
|
||||
struct moo_dbginfo_method_t
|
||||
typedef struct moo_dbgi_method_t moo_dbgi_method_t;
|
||||
struct moo_dbgi_method_t
|
||||
{
|
||||
moo_oow_t _type;
|
||||
moo_oow_t _len;
|
||||
@ -1482,7 +1482,7 @@ struct moo_t
|
||||
/* ========================= */
|
||||
|
||||
moo_heap_t* heap;
|
||||
moo_dbginfo_t* dbginfo;
|
||||
moo_dbgi_t* dbgi;
|
||||
|
||||
/* =============================================================
|
||||
* nil, true, false
|
||||
@ -1901,7 +1901,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MOO_HAVE_INLINE)
|
||||
static MOO_INLINE void MOO_STORE_OOP (moo_t* moo, moo_oop_t* rcvaddr, moo_oop_t val) { *rcvaddr = val; }
|
||||
static MOO_INLINE void MOO_STORE_OOP (moo_t* moo, moo_oop_t* rcvaddr, moo_oop_t val) { *rcvaddr = val; }
|
||||
#else
|
||||
# define MOO_STORE_OOP(moo,rcvaddr,val) (*(rcvaddr) = val)
|
||||
#endif
|
||||
@ -2124,7 +2124,7 @@ MOO_EXPORT void moo_abort (
|
||||
|
||||
|
||||
#if defined(MOO_HAVE_INLINE)
|
||||
static MOO_INLINE void moo_switchprocess(moo_t* moo) { moo->switch_proc = 1; }
|
||||
static MOO_INLINE void moo_switchprocess(moo_t* moo) { moo->switch_proc = 1; }
|
||||
#else
|
||||
# define moo_switchprocess(moo) ((moo)->switch_proc = 1)
|
||||
#endif
|
||||
@ -2133,17 +2133,17 @@ MOO_EXPORT void moo_abort (
|
||||
* DEBUG SUPPORT
|
||||
* ========================================================================= */
|
||||
|
||||
MOO_EXPORT int moo_initdbginfo (
|
||||
MOO_EXPORT int moo_initdbgi (
|
||||
moo_t* moo,
|
||||
moo_oow_t init_capa
|
||||
);
|
||||
|
||||
/**
|
||||
* The moo_finidbginfo() function deletes the debug information.
|
||||
* The moo_finidbgi() function deletes the debug information.
|
||||
* It is called by moo_close(). Unless you want the debug information to
|
||||
* be deleted earlier, you need not call this function explicitly.
|
||||
*/
|
||||
MOO_EXPORT void moo_finidbginfo (
|
||||
MOO_EXPORT void moo_finidbgi (
|
||||
moo_t* moo
|
||||
);
|
||||
/* =========================================================================
|
||||
@ -2365,29 +2365,6 @@ MOO_EXPORT int moo_convutobcstr (
|
||||
* STRING DUPLICATION
|
||||
* ========================================================================= */
|
||||
|
||||
#if defined(MOO_OOCH_IS_UCH)
|
||||
# define moo_dupootobcharswithheadroom(moo,hrb,oocs,oocslen,bcslen) moo_duputobcharswithheadroom(moo,hrb,oocs,oocslen,bcslen)
|
||||
# define moo_dupbtooocharswithheadroom(moo,hrb,bcs,bcslen,oocslen) moo_dupbtoucharswithheadroom(moo,hrb,bcs,bcslen,oocslen)
|
||||
# define moo_dupootobchars(moo,oocs,oocslen,bcslen) moo_duputobchars(moo,oocs,oocslen,bcslen)
|
||||
# define moo_dupbtooochars(moo,bcs,bcslen,oocslen) moo_dupbtouchars(moo,bcs,bcslen,oocslen)
|
||||
|
||||
# define moo_dupootobcstrwithheadroom(moo,hrb,oocs,bcslen) moo_duputobcstrwithheadroom(moo,hrb,oocs,bcslen)
|
||||
# define moo_dupbtooocstrwithheadroom(moo,hrb,bcs,oocslen) moo_dupbtoucstrwithheadroom(moo,hrb,bcs,oocslen)
|
||||
# define moo_dupootobcstr(moo,oocs,bcslen) moo_duputobcstr(moo,oocs,bcslen)
|
||||
# define moo_dupbtooocstr(moo,bcs,oocslen) moo_dupbtoucstr(moo,bcs,oocslen)
|
||||
#else
|
||||
# define moo_dupootoucharswithheadroom(moo,hrb,oocs,oocslen,ucslen) moo_dupbtoucharswithheadroom(moo,hrb,oocs,oocslen,ucslen)
|
||||
# define moo_duputooocharswithheadroom(moo,hrb,ucs,ucslen,oocslen) moo_duputobcharswithheadroom(moo,hrb,ucs,ucslen,oocslen)
|
||||
# define moo_dupootouchars(moo,oocs,oocslen,ucslen) moo_dupbtouchars(moo,oocs,oocslen,ucslen)
|
||||
# define moo_duputooochars(moo,ucs,ucslen,oocslen) moo_duputobchars(moo,ucs,ucslen,oocslen)
|
||||
|
||||
# define moo_dupootoucstrwithheadroom(moo,hrb,oocs,ucslen) moo_dupbtoucstrwithheadroom(moo,hrb,oocs,ucslen)
|
||||
# define moo_duputooocstrwithheadroom(moo,hrb,ucs,oocslen) moo_duputobcstrwithheadroom(moo,hrb,ucs,oocslen)
|
||||
# define moo_dupootoucstr(moo,oocs,ucslen) moo_dupbtoucstr(moo,oocs,ucslen)
|
||||
# define moo_duputooocstr(moo,ucs,oocslen) moo_duputobcstr(moo,ucs,oocslen)
|
||||
#endif
|
||||
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupbtoucharswithheadroom (
|
||||
moo_t* moo,
|
||||
moo_oow_t headroom_bytes,
|
||||
@ -2404,21 +2381,6 @@ MOO_EXPORT moo_bch_t* moo_duputobcharswithheadroom (
|
||||
moo_oow_t* bcslen
|
||||
);
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupbtouchars (
|
||||
moo_t* moo,
|
||||
const moo_bch_t* bcs,
|
||||
moo_oow_t bcslen,
|
||||
moo_oow_t* ucslen
|
||||
);
|
||||
|
||||
MOO_EXPORT moo_bch_t* moo_duputobchars (
|
||||
moo_t* moo,
|
||||
const moo_uch_t* ucs,
|
||||
moo_oow_t ucslen,
|
||||
moo_oow_t* bcslen
|
||||
);
|
||||
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupbtoucstrwithheadroom (
|
||||
moo_t* moo,
|
||||
moo_oow_t headroom_bytes,
|
||||
@ -2433,25 +2395,34 @@ MOO_EXPORT moo_bch_t* moo_duputobcstrwithheadroom (
|
||||
moo_oow_t* bcslen
|
||||
);
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupbtoucstr (
|
||||
moo_t* moo,
|
||||
const moo_bch_t* bcs,
|
||||
moo_oow_t* ucslen /* optional: length of returned string */
|
||||
);
|
||||
#if defined(MOO_HAVE_INLINE)
|
||||
static MOO_INLINE moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
|
||||
{
|
||||
return moo_duputobcharswithheadroom (moo, 0, ucs, ucslen, bcslen);
|
||||
}
|
||||
|
||||
MOO_EXPORT moo_bch_t* moo_duputobcstr (
|
||||
moo_t* moo,
|
||||
const moo_uch_t* ucs,
|
||||
moo_oow_t* bcslen /* optional: length of returned string */
|
||||
);
|
||||
static MOO_INLINE moo_uch_t* moo_dupbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
|
||||
{
|
||||
return moo_dupbtoucharswithheadroom (moo, 0, bcs, bcslen, ucslen);
|
||||
}
|
||||
|
||||
static MOO_INLINE moo_bch_t* moo_duputobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
{
|
||||
return moo_duputobcstrwithheadroom (moo, 0, ucs, bcslen);
|
||||
}
|
||||
|
||||
#if defined(MOO_OOCH_IS_UCH)
|
||||
# define moo_dupoochars(moo,oocs,oocslen) moo_dupuchars(moo,oocs,oocslen)
|
||||
static MOO_INLINE moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
{
|
||||
return moo_dupbtoucstrwithheadroom(moo, 0, bcs, ucslen);
|
||||
}
|
||||
#else
|
||||
# define moo_dupoochars(moo,oocs,oocslen) moo_dupbchars(moo,oocs,oocslen)
|
||||
# define moo_duputobchars(moo, ucs, ucslen, bcslen) moo_duputobcharswithheadroom(moo, 0, ucs, ucslen, bcslen)
|
||||
# define moo_dupbtouchars(moo, bcs, bcslen, ucslen) moo_dupbtoucharswithheadroom(moo, 0, bcs, bcslen, ucslen)
|
||||
# define moo_duputobcstr(moo, ucs, bcslen) moo_duputobcstrwithheadroom(moo, 0, ucs, bcslen)
|
||||
# define moo_dupbtoucstr(moo, bcs, ucslen) moo_dupbtoucstrwithheadroom(moo, 0, bcs, ucslen)
|
||||
#endif
|
||||
|
||||
|
||||
MOO_EXPORT moo_uch_t* moo_dupuchars (
|
||||
moo_t* moo,
|
||||
const moo_uch_t* ucs,
|
||||
@ -2464,6 +2435,31 @@ MOO_EXPORT moo_bch_t* moo_dupbchars (
|
||||
moo_oow_t bcslen
|
||||
);
|
||||
|
||||
#if defined(MOO_OOCH_IS_UCH)
|
||||
# define moo_dupootobcharswithheadroom(moo,hrb,oocs,oocslen,bcslen) moo_duputobcharswithheadroom(moo,hrb,oocs,oocslen,bcslen)
|
||||
# define moo_dupbtooocharswithheadroom(moo,hrb,bcs,bcslen,oocslen) moo_dupbtoucharswithheadroom(moo,hrb,bcs,bcslen,oocslen)
|
||||
# define moo_dupootobchars(moo,oocs,oocslen,bcslen) moo_duputobchars(moo,oocs,oocslen,bcslen)
|
||||
# define moo_dupbtooochars(moo,bcs,bcslen,oocslen) moo_dupbtouchars(moo,bcs,bcslen,oocslen)
|
||||
|
||||
# define moo_dupootobcstrwithheadroom(moo,hrb,oocs,bcslen) moo_duputobcstrwithheadroom(moo,hrb,oocs,bcslen)
|
||||
# define moo_dupbtooocstrwithheadroom(moo,hrb,bcs,oocslen) moo_dupbtoucstrwithheadroom(moo,hrb,bcs,oocslen)
|
||||
# define moo_dupootobcstr(moo,oocs,bcslen) moo_duputobcstr(moo,oocs,bcslen)
|
||||
# define moo_dupbtooocstr(moo,bcs,oocslen) moo_dupbtoucstr(moo,bcs,oocslen)
|
||||
# define moo_dupoochars(moo,oocs,oocslen) moo_dupuchars(moo,oocs,oocslen)
|
||||
#else
|
||||
# define moo_dupootoucharswithheadroom(moo,hrb,oocs,oocslen,ucslen) moo_dupbtoucharswithheadroom(moo,hrb,oocs,oocslen,ucslen)
|
||||
# define moo_duputooocharswithheadroom(moo,hrb,ucs,ucslen,oocslen) moo_duputobcharswithheadroom(moo,hrb,ucs,ucslen,oocslen)
|
||||
# define moo_dupootouchars(moo,oocs,oocslen,ucslen) moo_dupbtouchars(moo,oocs,oocslen,ucslen)
|
||||
# define moo_duputooochars(moo,ucs,ucslen,oocslen) moo_duputobchars(moo,ucs,ucslen,oocslen)
|
||||
|
||||
# define moo_dupootoucstrwithheadroom(moo,hrb,oocs,ucslen) moo_dupbtoucstrwithheadroom(moo,hrb,oocs,ucslen)
|
||||
# define moo_duputooocstrwithheadroom(moo,hrb,ucs,oocslen) moo_duputobcstrwithheadroom(moo,hrb,ucs,oocslen)
|
||||
# define moo_dupootoucstr(moo,oocs,ucslen) moo_dupbtoucstr(moo,oocs,ucslen)
|
||||
# define moo_duputooocstr(moo,ucs,oocslen) moo_duputobcstr(moo,ucs,oocslen)
|
||||
# define moo_dupoochars(moo,oocs,oocslen) moo_dupbchars(moo,oocs,oocslen)
|
||||
#endif
|
||||
|
||||
|
||||
/* =========================================================================
|
||||
* SBUF MANIPULATION
|
||||
* ========================================================================= */
|
||||
|
@ -545,6 +545,21 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
|
||||
}
|
||||
|
||||
arg->handle = bb;
|
||||
if (!arg->name)
|
||||
{
|
||||
/* for the top-level stream, i simply change the arg->name field
|
||||
* so that the compiler knows the file to be read */
|
||||
moo_oocs_t io_name;
|
||||
|
||||
io_name.ptr = moo_dupbtooocstr(moo, get_base_name(bb->fn), &io_name.len);
|
||||
if (!io_name.ptr) goto oops;
|
||||
|
||||
arg->name = moo_addcioname(moo, &io_name);
|
||||
moo_freemem (moo, io_name.ptr);
|
||||
|
||||
if (!arg->name) goto oops;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
@ -3703,6 +3718,7 @@ void moo_abortstd (moo_t* moo)
|
||||
moo_abort (moo);
|
||||
}
|
||||
|
||||
#if defined(MOO_INCLUDE_COMPILER)
|
||||
int moo_compilestd (moo_t* moo, const moo_iostd_t* in, moo_oow_t count)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(moo);
|
||||
@ -3716,6 +3732,7 @@ int moo_compilestd (moo_t* moo, const moo_iostd_t* in, moo_oow_t count)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void moo_rcvtickstd (moo_t* moo, int v)
|
||||
{
|
||||
|
@ -914,7 +914,7 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
MOO_INLINE moo_uch_t* moo_dupbtoucharswithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
|
||||
moo_uch_t* moo_dupbtoucharswithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
|
||||
{
|
||||
moo_oow_t inlen, outlen;
|
||||
moo_uch_t* ptr;
|
||||
@ -942,12 +942,7 @@ MOO_INLINE moo_uch_t* moo_dupbtoucharswithheadroom (moo_t* moo, moo_oow_t headro
|
||||
return ptr;
|
||||
}
|
||||
|
||||
moo_uch_t* moo_dupbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
|
||||
{
|
||||
return moo_dupbtoucharswithheadroom (moo, 0, bcs, bcslen, ucslen);
|
||||
}
|
||||
|
||||
MOO_INLINE moo_bch_t* moo_duputobcharswithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
|
||||
moo_bch_t* moo_duputobcharswithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
|
||||
{
|
||||
moo_oow_t inlen, outlen;
|
||||
moo_bch_t* ptr;
|
||||
@ -971,15 +966,9 @@ MOO_INLINE moo_bch_t* moo_duputobcharswithheadroom (moo_t* moo, moo_oow_t headro
|
||||
return ptr;
|
||||
}
|
||||
|
||||
moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
|
||||
{
|
||||
return moo_duputobcharswithheadroom (moo, 0, ucs, ucslen, bcslen);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
MOO_INLINE moo_uch_t* moo_dupbtoucstrwithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
moo_uch_t* moo_dupbtoucstrwithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
{
|
||||
moo_oow_t inlen, outlen;
|
||||
moo_uch_t* ptr;
|
||||
@ -999,12 +988,7 @@ MOO_INLINE moo_uch_t* moo_dupbtoucstrwithheadroom (moo_t* moo, moo_oow_t headroo
|
||||
return ptr;
|
||||
}
|
||||
|
||||
moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
|
||||
{
|
||||
return moo_dupbtoucstrwithheadroom (moo, 0, bcs, ucslen);
|
||||
}
|
||||
|
||||
MOO_INLINE moo_bch_t* moo_duputobcstrwithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
moo_bch_t* moo_duputobcstrwithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
{
|
||||
moo_oow_t inlen, outlen;
|
||||
moo_bch_t* ptr;
|
||||
@ -1026,10 +1010,6 @@ MOO_INLINE moo_bch_t* moo_duputobcstrwithheadroom (moo_t* moo, moo_oow_t headroo
|
||||
return ptr;
|
||||
}
|
||||
|
||||
moo_bch_t* moo_duputobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* bcslen)
|
||||
{
|
||||
return moo_duputobcstrwithheadroom (moo, 0, ucs, bcslen);
|
||||
}
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
moo_uch_t* moo_dupuchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen)
|
||||
|
Loading…
Reference in New Issue
Block a user