libyasm
|
YASM value/parameter interface. More...
Go to the source code of this file.
Data Structures | |
struct | yasm_valparam |
Value/parameter pair. More... | |
union | yasm_valparam::yasm_param |
Parameter value. More... | |
struct | yasm_directive |
Directive list entry structure. More... | |
struct | yasm_dir_help |
Directive valparam parse helper structure. More... | |
Typedefs | |
typedef struct yasm_dir_help | yasm_dir_help |
Directive valparam parse helper structure. More... | |
Functions | |
STAILQ_HEAD (yasm_valparamhead, yasm_valparam) | |
Linked list of value/parameter pairs. More... | |
YASM_LIB_DECL void | yasm_call_directive (const yasm_directive *directive, yasm_object *object, yasm_valparamhead *valparams, yasm_valparamhead *objext_valparams, unsigned long line) |
Call a directive. More... | |
YASM_LIB_DECL yasm_valparam * | yasm_vp_create_id (char *v, char *p, int id_prefix) |
Create a new valparam with identifier parameter. More... | |
YASM_LIB_DECL yasm_valparam * | yasm_vp_create_string (char *v, char *p) |
Create a new valparam with string parameter. More... | |
YASM_LIB_DECL yasm_valparam * | yasm_vp_create_expr (char *v, yasm_expr *p) |
Create a new valparam with expression parameter. More... | |
YASM_LIB_DECL yasm_expr * | yasm_vp_expr (const yasm_valparam *vp, yasm_symtab *symtab, unsigned long line) |
Get a valparam parameter as an expr. More... | |
YASM_LIB_DECL const char * | yasm_vp_string (const yasm_valparam *vp) |
Get a valparam parameter as a string. More... | |
YASM_LIB_DECL const char * | yasm_vp_id (const yasm_valparam *vp) |
Get a valparam parameter as an identifier. More... | |
YASM_LIB_DECL yasm_valparamhead * | yasm_vps_create (void) |
Create a new linked list of valparams. More... | |
YASM_LIB_DECL void | yasm_vps_destroy (yasm_valparamhead *headp) |
Destroy a list of valparams (created with yasm_vps_create). More... | |
void | yasm_vps_initialize (yasm_valparamhead *headp) |
Initialize linked list of valparams. More... | |
YASM_LIB_DECL void | yasm_vps_delete (yasm_valparamhead *headp) |
Destroy (free allocated memory for) linked list of valparams (created with yasm_vps_initialize). More... | |
void | yasm_vps_append (yasm_valparamhead *headp, yasm_valparam *vp) |
Append valparam to tail of linked list. More... | |
yasm_valparam * | yasm_vps_first (yasm_valparamhead *headp) |
Get first valparam in linked list. More... | |
yasm_valparam * | yasm_vps_next (yasm_valparam *cur) |
Get next valparam in linked list. More... | |
YASM_LIB_DECL void | yasm_vps_print (const yasm_valparamhead *headp, FILE *f) |
Iterate through linked list of valparams. More... | |
YASM_LIB_DECL int | yasm_dir_helper (void *obj, yasm_valparam *vp_first, unsigned long line, const yasm_dir_help *help, size_t nhelp, void *data, int(*helper_valparam)(void *object, yasm_valparam *vp, unsigned long line, void *data)) |
Help parse a list of directive value/parameters. More... | |
YASM_LIB_DECL int | yasm_dir_helper_flag_set (void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) |
Standard helper for yasm_dir_helper() that simply sets a flag when called. More... | |
YASM_LIB_DECL int | yasm_dir_helper_flag_or (void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) |
Standard helper for yasm_dir_helper() that simply ORs a flag when called. More... | |
YASM_LIB_DECL int | yasm_dir_helper_flag_and (void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) |
Standard helper for yasm_dir_helper() that simply ANDs a flag when called. More... | |
YASM_LIB_DECL int | yasm_dir_helper_expr (void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) |
Standard helper for yasm_dir_helper() that parses an expr parameter. More... | |
YASM_LIB_DECL int | yasm_dir_helper_intn (void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) |
Standard helper for yasm_dir_helper() that parses an intnum parameter. More... | |
YASM_LIB_DECL int | yasm_dir_helper_string (void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) |
Standard helper for yasm_dir_helper() that parses an string (or standalone identifier) parameter. More... | |
YASM_LIB_DECL int | yasm_dir_helper_valparam_warn (void *obj, yasm_valparam *vp, unsigned long line, void *data) |
Standard catch-all callback fro yasm_dir_helper(). More... | |
YASM value/parameter interface.
Definition in file valparam.h.
typedef struct yasm_dir_help yasm_dir_help |
Directive valparam parse helper structure.
STAILQ_HEAD | ( | yasm_valparamhead | , |
yasm_valparam | |||
) |
Linked list of value/parameter pairs.
YASM_LIB_DECL void yasm_call_directive | ( | const yasm_directive * | directive, |
yasm_object * | object, | ||
yasm_valparamhead * | valparams, | ||
yasm_valparamhead * | objext_valparams, | ||
unsigned long | line | ||
) |
Call a directive.
Performs any valparam checks asked for by the directive prior to call. Note that for a variety of reasons, a directive can generate an error.
directive | directive |
object | object |
valparams | value/parameters |
objext_valparams | object format-specific value/parameters |
line | virtual line (from yasm_linemap) |
YASM_LIB_DECL int yasm_dir_helper | ( | void * | obj, |
yasm_valparam * | vp_first, | ||
unsigned long | line, | ||
const yasm_dir_help * | help, | ||
size_t | nhelp, | ||
void * | data, | ||
int(*)(void *object, yasm_valparam *vp, unsigned long line, void *data) | helper_valparam | ||
) |
Help parse a list of directive value/parameters.
Takes an array of yasm_dir_help structures and tries to match val=param (or just val) against the passed value/parameters. When no match is found in the array of help structures, calls helper_valparam.
obj | object to be passed to yasm_dir_help.helper() or helper_valparam() callback |
vp_first | first value/parameter to examine |
line | virtual line number; passed down to helper callback |
help | array of yasm_dir_help structures |
nhelp | number of array elements |
data | base data pointer; if a match is found, the respective yasm_dir_help.off is added to this prior to it being passed to the helper callback |
helper_valparam | catch-all callback; should return -1 on error, 0 if not matched, 1 if matched. |
YASM_LIB_DECL int yasm_dir_helper_expr | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data, | ||
uintptr_t | arg | ||
) |
Standard helper for yasm_dir_helper() that parses an expr parameter.
The yasm_dir_help structure that uses this function should have needsparam=1. The obj parameter to yasm_dir_helper() when this helper is used MUST point to a yasm_object. In addition, the data parameter that is ultimately passed to this function (e.g. yasm_dir_helper() data parameter plus yasm_dir_help.off) must point to a yasm_expr * initialized to NULL.
obj | object; must be yasm_object |
vp | valparam |
line | virtual line number |
data | pointer to yasm_expr * |
arg | unused argument |
YASM_LIB_DECL int yasm_dir_helper_flag_and | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data, | ||
uintptr_t | arg | ||
) |
Standard helper for yasm_dir_helper() that simply ANDs a flag when called.
It does not look at the vp; rather, it uses the value of the arg parameter, and ANDs its inverse (~) with the unsigned long value in data.
obj | unused |
vp | unused |
line | unused |
data | pointer to an unsigned long |
arg | flag to AND |
YASM_LIB_DECL int yasm_dir_helper_flag_or | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data, | ||
uintptr_t | arg | ||
) |
Standard helper for yasm_dir_helper() that simply ORs a flag when called.
It does not look at the vp; rather, it uses the value of the arg parameter, and ORs it with the unsigned long value in data.
obj | unused |
vp | unused |
line | unused |
data | pointer to an unsigned long |
arg | flag to OR |
YASM_LIB_DECL int yasm_dir_helper_flag_set | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data, | ||
uintptr_t | arg | ||
) |
Standard helper for yasm_dir_helper() that simply sets a flag when called.
It does not look at the vp; rather, it uses the value of the arg parameter, and stores an unsigned long value to data.
obj | unused |
vp | unused |
line | unused |
data | pointer to an unsigned long |
arg | flag to set |
YASM_LIB_DECL int yasm_dir_helper_intn | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data, | ||
uintptr_t | arg | ||
) |
Standard helper for yasm_dir_helper() that parses an intnum parameter.
The yasm_dir_help structure that uses this function should have needsparam=1. The obj parameter to yasm_dir_helper() when this helper is used MUST point to a yasm_object. In addition, the data parameter that is ultimately passed to this function (e.g. yasm_dir_helper() data parameter plus yasm_dir_help.off) must point to a yasm_intnum * initialized to NULL.
obj | object; must be yasm_object |
vp | valparam |
line | virtual line number |
data | pointer to yasm_intnum * |
arg | unused argument |
YASM_LIB_DECL int yasm_dir_helper_string | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data, | ||
uintptr_t | arg | ||
) |
Standard helper for yasm_dir_helper() that parses an string (or standalone identifier) parameter.
The yasm_dir_help structure that uses this function should have needsparam=1. The data parameter that is ultimately passed to this function (e.g. yasm_dir_helper() data parameter plus yasm_dir_help.off) must point to a char * initialized to NULL.
obj | unused |
vp | valparam |
line | unused |
data | pointer to char * |
arg | unused |
YASM_LIB_DECL int yasm_dir_helper_valparam_warn | ( | void * | obj, |
yasm_valparam * | vp, | ||
unsigned long | line, | ||
void * | data | ||
) |
Standard catch-all callback fro yasm_dir_helper().
Generates standard warning for all valparams.
obj | unused |
vp | valparam |
line | unused |
data | unused |
YASM_LIB_DECL yasm_valparam* yasm_vp_create_expr | ( | char * | v, |
yasm_expr * | p | ||
) |
Create a new valparam with expression parameter.
v | value |
p | parameter |
YASM_LIB_DECL yasm_valparam* yasm_vp_create_id | ( | char * | v, |
char * | p, | ||
int | id_prefix | ||
) |
Create a new valparam with identifier parameter.
v | value |
p | parameter |
id_prefix | identifier prefix for raw identifiers |
YASM_LIB_DECL yasm_valparam* yasm_vp_create_string | ( | char * | v, |
char * | p | ||
) |
Create a new valparam with string parameter.
v | value |
p | parameter |
YASM_LIB_DECL yasm_expr* yasm_vp_expr | ( | const yasm_valparam * | vp, |
yasm_symtab * | symtab, | ||
unsigned long | line | ||
) |
Get a valparam parameter as an expr.
If the parameter is an identifier, it's treated as a symbol (yasm_symtab_use() is called to convert it).
vp | valparam |
symtab | symbol table |
line | virtual line |
YASM_LIB_DECL const char* yasm_vp_id | ( | const yasm_valparam * | vp | ) |
Get a valparam parameter as an identifier.
vp | valparam |
YASM_LIB_DECL const char* yasm_vp_string | ( | const yasm_valparam * | vp | ) |
Get a valparam parameter as a string.
If the parameter is an identifier, it's treated as a string.
vp | valparam |
void yasm_vps_append | ( | yasm_valparamhead * | headp, |
yasm_valparam * | vp | ||
) |
Append valparam to tail of linked list.
headp | linked list |
vp | valparam |
YASM_LIB_DECL yasm_valparamhead* yasm_vps_create | ( | void | ) |
Create a new linked list of valparams.
YASM_LIB_DECL void yasm_vps_delete | ( | yasm_valparamhead * | headp | ) |
Destroy (free allocated memory for) linked list of valparams (created with yasm_vps_initialize).
headp | linked list |
YASM_LIB_DECL void yasm_vps_destroy | ( | yasm_valparamhead * | headp | ) |
Destroy a list of valparams (created with yasm_vps_create).
headp | list of valparams |
yasm_valparam* yasm_vps_first | ( | yasm_valparamhead * | headp | ) |
Get first valparam in linked list.
headp | linked list |
void yasm_vps_initialize | ( | yasm_valparamhead * | headp | ) |
Initialize linked list of valparams.
headp | linked list |
yasm_valparam* yasm_vps_next | ( | yasm_valparam * | cur | ) |
Get next valparam in linked list.
cur | previous valparam in linked list |
YASM_LIB_DECL void yasm_vps_print | ( | const yasm_valparamhead * | headp, |
FILE * | f | ||
) |
Iterate through linked list of valparams.
iter | iterator variable |
headp | linked list Print linked list of valparams. For debugging purposes. |
f | file |
headp | linked list |