libyasm/valparam.h File Reference

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...

Functions

 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.
YASM_LIB_DECL yasm_valparamyasm_vp_create_id (char *v, char *p, int id_prefix)
 Create a new valparam with identifier parameter.
YASM_LIB_DECL yasm_valparamyasm_vp_create_string (char *v, char *p)
 Create a new valparam with string parameter.
YASM_LIB_DECL yasm_valparamyasm_vp_create_expr (char *v, yasm_expr *p)
 Create a new valparam with expression parameter.
YASM_LIB_DECL yasm_expryasm_vp_expr (const yasm_valparam *vp, yasm_symtab *symtab, unsigned long line)
 Get a valparam parameter as an expr.
YASM_LIB_DECL const char * yasm_vp_string (const yasm_valparam *vp)
 Get a valparam parameter as a string.
YASM_LIB_DECL const char * yasm_vp_id (const yasm_valparam *vp)
 Get a valparam parameter as an identifier.
YASM_LIB_DECL yasm_valparamheadyasm_vps_create (void)
 Create a new linked list of valparams.
YASM_LIB_DECL void yasm_vps_destroy (yasm_valparamhead *headp)
 Destroy a list of valparams (created with yasm_vps_create).
void yasm_vps_initialize (yasm_valparamhead *headp)
 Initialize 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).
void yasm_vps_append (yasm_valparamhead *headp, yasm_valparam *vp)
 Append valparam to tail of linked list.
yasm_valparamyasm_vps_first (yasm_valparamhead *headp)
 Get first valparam in linked list.
yasm_valparamyasm_vps_next (yasm_valparam *cur)
 Get next valparam in linked list.
YASM_LIB_DECL void yasm_vps_print (const yasm_valparamhead *headp, FILE *f)
 Iterate through linked list of valparams.
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.
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.
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.
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.
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.
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.
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.
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().


Detailed Description

YASM value/parameter interface.

Definition in file valparam.h.


Function Documentation

STAILQ_HEAD ( yasm_valparamhead  ,
yasm_valparam   
)

Linked list of value/parameter pairs.

For internal use only.

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.

Parameters:
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.

Parameters:
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.
Returns:
-1 on error, 1 if any arguments matched (including via catch-all callback), 0 if no match.

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.

Parameters:
obj object; must be yasm_object
vp valparam
line virtual line number
data pointer to yasm_expr *
arg unused argument
Returns:
-1 on error, 0 otherwise.

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.

Parameters:
obj unused
vp unused
line unused
data pointer to an unsigned long
arg flag to AND
Returns:
0

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.

Parameters:
obj unused
vp unused
line unused
data pointer to an unsigned long
arg flag to OR
Returns:
0

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.

Parameters:
obj unused
vp unused
line unused
data pointer to an unsigned long
arg flag to set
Returns:
0

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.

Parameters:
obj object; must be yasm_object
vp valparam
line virtual line number
data pointer to yasm_intnum *
arg unused argument
Returns:
-1 on error, 0 otherwise.

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.

Parameters:
obj unused
vp valparam
line unused
data pointer to char *
arg unused
Returns:
-1 on error, 0 otherwise.

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.

Parameters:
obj unused
vp valparam
line unused
data unused
Returns:
0

YASM_LIB_DECL yasm_valparam* yasm_vp_create_expr ( char *  v,
yasm_expr p 
)

Create a new valparam with expression parameter.

Parameters:
v value
p parameter
Returns:
Newly allocated valparam.

YASM_LIB_DECL yasm_valparam* yasm_vp_create_id ( char *  v,
char *  p,
int  id_prefix 
)

Create a new valparam with identifier parameter.

Parameters:
v value
p parameter
id_prefix identifier prefix for raw identifiers
Returns:
Newly allocated valparam.

YASM_LIB_DECL yasm_valparam* yasm_vp_create_string ( char *  v,
char *  p 
)

Create a new valparam with string parameter.

Parameters:
v value
p parameter
Returns:
Newly allocated valparam.

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).

Parameters:
vp valparam
symtab symbol table
line virtual line
Returns:
Expression, or NULL if vp is NULL or the parameter cannot be converted to an expression.

YASM_LIB_DECL const char* yasm_vp_id ( const yasm_valparam vp  ) 

Get a valparam parameter as an identifier.

Parameters:
vp valparam
Returns:
Identifier (string), or NULL if vp is NULL or the parameter is not an identifier.

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.

Parameters:
vp valparam
Returns:
String, or NULL if vp is NULL or the parameter cannot be realized as a string.

void yasm_vps_append ( yasm_valparamhead headp,
yasm_valparam vp 
)

Append valparam to tail of linked list.

Parameters:
headp linked list
vp valparam

YASM_LIB_DECL yasm_valparamhead* yasm_vps_create ( void   ) 

Create a new linked list of valparams.

Returns:
Newly allocated valparam list.

YASM_LIB_DECL void yasm_vps_delete ( yasm_valparamhead headp  ) 

Destroy (free allocated memory for) linked list of valparams (created with yasm_vps_initialize).

Warning:
Deletes val/params.
Parameters:
headp linked list

YASM_LIB_DECL void yasm_vps_destroy ( yasm_valparamhead headp  ) 

Destroy a list of valparams (created with yasm_vps_create).

Parameters:
headp list of valparams

yasm_valparam* yasm_vps_first ( yasm_valparamhead headp  ) 

Get first valparam in linked list.

Parameters:
headp linked list
Returns:
First valparam in linked list.

void yasm_vps_initialize ( yasm_valparamhead headp  ) 

Initialize linked list of valparams.

Parameters:
headp linked list

yasm_valparam* yasm_vps_next ( yasm_valparam cur  ) 

Get next valparam in linked list.

Parameters:
cur previous valparam in linked list
Returns:
Next valparam in linked list.

YASM_LIB_DECL void yasm_vps_print ( const yasm_valparamhead headp,
FILE *  f 
)

Iterate through linked list of valparams.

For internal use only.

Parameters:
iter iterator variable
headp linked list Print linked list of valparams. For debugging purposes.
f file
headp linked list


Generated on Thu Nov 20 01:22:30 2008 for libyasm by  doxygen 1.5.6