mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
This is actually worthwhile; I found and fixed a few bugs/edge cases while doing this. For more information on LCLint, see <http://lclint.cs.virginia.edu/>. svn path=/trunk/yasm/; revision=335
104 lines
3.4 KiB
C
104 lines
3.4 KiB
C
/* $IdPath$
|
|
* Bytecode utility functions header file
|
|
*
|
|
* Copyright (C) 2001 Peter Johnson
|
|
*
|
|
* This file is part of YASM.
|
|
*
|
|
* YASM is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* YASM is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
#ifndef YASM_BYTECODE_H
|
|
#define YASM_BYTECODE_H
|
|
|
|
typedef struct effaddr effaddr;
|
|
typedef struct immval immval;
|
|
typedef /*@reldef@*/ STAILQ_HEAD(datavalhead, dataval) datavalhead;
|
|
typedef struct dataval dataval;
|
|
|
|
/* Additional types may be architecture-defined starting at
|
|
* BYTECODE_TYPE_BASE.
|
|
*/
|
|
typedef enum {
|
|
BC_EMPTY = 0,
|
|
BC_DATA,
|
|
BC_RESERVE
|
|
} bytecode_type;
|
|
#define BYTECODE_TYPE_BASE BC_RESERVE+1
|
|
|
|
/*@only@*/ immval *imm_new_int(unsigned long int_val);
|
|
/*@only@*/ immval *imm_new_expr(/*@keep@*/ expr *e);
|
|
|
|
void ea_set_len(effaddr *ea, unsigned char len);
|
|
void ea_set_nosplit(effaddr *ea, unsigned char nosplit);
|
|
|
|
void bc_set_multiple(bytecode *bc, /*@keep@*/ expr *e);
|
|
|
|
/*@only@*/ bytecode *bc_new_common(bytecode_type type, size_t datasize);
|
|
/*@only@*/ bytecode *bc_new_data(datavalhead *datahead, unsigned char size);
|
|
/*@only@*/ bytecode *bc_new_reserve(/*@keep@*/ expr *numitems,
|
|
unsigned char itemsize);
|
|
|
|
void bc_delete(/*@only@*/ /*@null@*/ bytecode *bc);
|
|
|
|
/* Gets the offset of the bytecode specified by bc if possible.
|
|
* Return value is IF POSSIBLE, not the value.
|
|
*/
|
|
int bc_get_offset(section *sect, bytecode *bc,
|
|
/*@out@*/ unsigned long *ret_val);
|
|
|
|
void bc_print(const bytecode *bc);
|
|
|
|
void bc_parser_finalize(bytecode *bc);
|
|
|
|
/* void bytecodes_initialize(bytecodehead *headp); */
|
|
#define bytecodes_initialize(headp) STAILQ_INIT(headp)
|
|
|
|
void bcs_delete(bytecodehead *headp);
|
|
|
|
/* Adds bc to the list of bytecodes headp.
|
|
* NOTE: Does not make a copy of bc; so don't pass this function
|
|
* static or local variables, and discard the bc pointer after calling
|
|
* this function. If bc was actually appended (it wasn't NULL or empty),
|
|
* then returns bc, otherwise returns NULL.
|
|
*/
|
|
/*@only@*/ /*@null@*/ bytecode *bcs_append(bytecodehead *headp,
|
|
/*@returned@*/ /*@only@*/ /*@null@*/
|
|
bytecode *bc);
|
|
|
|
void bcs_print(const bytecodehead *headp);
|
|
|
|
void bcs_parser_finalize(bytecodehead *headp);
|
|
|
|
dataval *dv_new_expr(/*@keep@*/ expr *expn);
|
|
dataval *dv_new_float(/*@keep@*/ floatnum *flt);
|
|
dataval *dv_new_string(/*@keep@*/ char *str_val);
|
|
|
|
void dvs_initialize(datavalhead *headp);
|
|
#define dvs_initialize(headp) STAILQ_INIT(headp)
|
|
|
|
void dvs_delete(datavalhead *headp);
|
|
|
|
/* Adds dv to the list of datavals headp.
|
|
* NOTE: Does not make a copy of dv; so don't pass this function
|
|
* static or local variables, and discard the dv pointer after calling
|
|
* this function. If dv was actually appended (it wasn't NULL), then
|
|
* returns dv, otherwise returns NULL.
|
|
*/
|
|
/*@null@*/ dataval *dvs_append(datavalhead *headp,
|
|
/*@returned@*/ /*@null@*/ dataval *dv);
|
|
|
|
void dvs_print(const datavalhead *head);
|
|
|
|
#endif
|