From: uz Date: Wed, 17 Aug 2011 16:08:26 +0000 (+0000) Subject: Added cc65_line_bysource X-Git-Tag: V2.13.3~268 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=115db5974355a73ae486019c78779d24049e6513;p=cc65 Added cc65_line_bysource git-svn-id: svn://svn.cc65.org/cc65/trunk@5194 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/dbginfo/dbginfo.c b/src/dbginfo/dbginfo.c index c769e1889..b63ab2473 100644 --- a/src/dbginfo/dbginfo.c +++ b/src/dbginfo/dbginfo.c @@ -4792,6 +4792,45 @@ const cc65_lineinfo* cc65_line_bynumber (cc65_dbginfo Handle, unsigned FileId, +const cc65_lineinfo* cc65_line_bysource (cc65_dbginfo Handle, unsigned FileId) +/* Return line information for a source file. The function returns NULL if the + * file id is invalid. + */ +{ + DbgInfo* Info; + FileInfo* F; + cc65_lineinfo* D; + unsigned I; + + /* Check the parameter */ + assert (Handle != 0); + + /* The handle is actually a pointer to a debug info struct */ + Info = (DbgInfo*) Handle; + + /* Check if the source file id is valid */ + if (FileId >= CollCount (&Info->FileInfoById)) { + return 0; + } + + /* Get the file */ + F = CollAt (&Info->FileInfoById, FileId); + + /* Prepare the struct we will return to the caller */ + D = new_cc65_lineinfo (CollCount (&F->LineInfoByLine)); + + /* Fill in the data */ + for (I = 0; I < CollCount (&F->LineInfoByLine); ++I) { + /* Copy the data */ + CopyLineInfo (D->data + I, CollConstAt (&F->LineInfoByLine, I)); + } + + /* Return the allocated struct */ + return D; +} + + + void cc65_free_lineinfo (cc65_dbginfo Handle, const cc65_lineinfo* Info) /* Free line info returned by one of the other functions */ { diff --git a/src/dbginfo/dbginfo.h b/src/dbginfo/dbginfo.h index 45c942736..e7d598ada 100644 --- a/src/dbginfo/dbginfo.h +++ b/src/dbginfo/dbginfo.h @@ -189,6 +189,11 @@ const cc65_lineinfo* cc65_line_bynumber (cc65_dbginfo handle, * function returns NULL if no line information was found. */ +const cc65_lineinfo* cc65_line_bysource (cc65_dbginfo Handle, unsigned source_id); +/* Return line information for a source file. The function returns NULL if the + * file id is invalid. + */ + void cc65_free_lineinfo (cc65_dbginfo handle, const cc65_lineinfo* info); /* Free line info returned by one of the other functions */