libyasm
Defines | Functions

libyasm/linemap.h File Reference

YASM virtual line mapping interface. More...

Go to the source code of this file.

Functions

YASM_LIB_DECL yasm_linemapyasm_linemap_create (void)
 Create a new line mapping repository.
YASM_LIB_DECL void yasm_linemap_destroy (yasm_linemap *linemap)
 Clean up any memory allocated for a repository.
YASM_LIB_DECL unsigned long yasm_linemap_get_current (yasm_linemap *linemap)
 Get the current line position in a repository.
YASM_LIB_DECL int yasm_linemap_get_source (yasm_linemap *linemap, unsigned long line, yasm_bytecode **bcp, const char **sourcep)
 Get bytecode and source line information, if any, for a virtual line.
YASM_LIB_DECL void yasm_linemap_add_source (yasm_linemap *linemap, yasm_bytecode *bc, const char *source)
 Add bytecode and source line information to the current virtual line.
YASM_LIB_DECL unsigned long yasm_linemap_goto_next (yasm_linemap *linemap)
 Go to the next line (increments the current virtual line).
YASM_LIB_DECL void yasm_linemap_set (yasm_linemap *linemap, const char *filename, unsigned long virtual_line, unsigned long file_line, unsigned long line_inc)
 Set a new file/line physical association starting point at the specified virtual line.
YASM_LIB_DECL unsigned long yasm_linemap_poke (yasm_linemap *linemap, const char *filename, unsigned long file_line)
 Poke a single file/line association, restoring the original physical association starting point.
YASM_LIB_DECL void yasm_linemap_lookup (yasm_linemap *linemap, unsigned long line, const char **filename, unsigned long *file_line)
 Look up the associated physical file and line for a virtual line.
YASM_LIB_DECL int yasm_linemap_traverse_filenames (yasm_linemap *linemap, void *d, int(*func)(const char *filename, void *d))
 Traverses all filenames used in a linemap, calling a function on each filename.

Detailed Description

YASM virtual line mapping interface.

Definition in file linemap.h.


Function Documentation

YASM_LIB_DECL void yasm_linemap_add_source ( yasm_linemap linemap,
yasm_bytecode bc,
const char *  source 
)

Add bytecode and source line information to the current virtual line.

Attention:
Deletes any existing bytecode and source line information for the current virtual line.
Parameters:
linemapline mapping repository
bcbytecode (if any)
sourcesource code line
Note:
The source code line pointer is NOT kept, it is strdup'ed.
YASM_LIB_DECL yasm_linemap* yasm_linemap_create ( void  )

Create a new line mapping repository.

Returns:
New repository.
YASM_LIB_DECL void yasm_linemap_destroy ( yasm_linemap linemap)

Clean up any memory allocated for a repository.

Parameters:
linemapline mapping repository
YASM_LIB_DECL unsigned long yasm_linemap_get_current ( yasm_linemap linemap)

Get the current line position in a repository.

Parameters:
linemapline mapping repository
Returns:
Current virtual line.
YASM_LIB_DECL int yasm_linemap_get_source ( yasm_linemap linemap,
unsigned long  line,
yasm_bytecode **  bcp,
const char **  sourcep 
)

Get bytecode and source line information, if any, for a virtual line.

Parameters:
linemapline mapping repository
linevirtual line
bcppointer to return bytecode into
sourceppointer to return source code line pointer into
Returns:
Zero if source line information available for line, nonzero if not.
Note:
If source line information is not available, bcp and sourcep targets are set to NULL.
YASM_LIB_DECL unsigned long yasm_linemap_goto_next ( yasm_linemap linemap)

Go to the next line (increments the current virtual line).

Parameters:
linemapline mapping repository
Returns:
The current (new) virtual line.
YASM_LIB_DECL void yasm_linemap_lookup ( yasm_linemap linemap,
unsigned long  line,
const char **  filename,
unsigned long *  file_line 
)

Look up the associated physical file and line for a virtual line.

Parameters:
linemapline mapping repository
linevirtual line
filenamephysical file name (output)
file_linephysical line number (output)
YASM_LIB_DECL unsigned long yasm_linemap_poke ( yasm_linemap linemap,
const char *  filename,
unsigned long  file_line 
)

Poke a single file/line association, restoring the original physical association starting point.

Caution: increments the current virtual line twice.

Parameters:
linemapline mapping repository
filenamephysical file name (if NULL, not changed)
file_linephysical line number
Returns:
The virtual line number of the poked association.
YASM_LIB_DECL void yasm_linemap_set ( yasm_linemap linemap,
const char *  filename,
unsigned long  virtual_line,
unsigned long  file_line,
unsigned long  line_inc 
)

Set a new file/line physical association starting point at the specified virtual line.

line_inc indicates how much the "real" line is incremented by for each virtual line increment (0 is perfectly legal).

Parameters:
linemapline mapping repository
filenamephysical file name (if NULL, not changed)
virtual_linevirtual line number (if 0, linemap->current is used)
file_linephysical line number
line_incline increment
YASM_LIB_DECL int yasm_linemap_traverse_filenames ( yasm_linemap linemap,
void *  d,
int(*)(const char *filename, void *d)  func 
)

Traverses all filenames used in a linemap, calling a function on each filename.

Parameters:
linemapline mapping repository
ddata pointer passed to func on each call
funcfunction
Returns:
Stops early (and returns func's return value) if func returns a nonzero value; otherwise 0.