*/
#define YASM_LIB_INTERNAL
#include "util.h"
-/*@unused@*/ RCSID("$IdPath$");
+/*@unused@*/ RCSID("$IdPath: yasm/libyasm/bytecode.c,v 1.93 2003/03/31 05:36:29 peter Exp $");
#include "file.h"
cur = next;
}
STAILQ_INIT(headp);
+ yasm_xfree(headp);
}
yasm_bytecode *
}
}
-/* Non-macro yasm_bcs_initialize() for non-YASM_INTERNAL users. */
-#undef yasm_bcs_initialize
-void
-yasm_bcs_initialize(yasm_bytecodehead *headp)
+yasm_bytecodehead *
+yasm_bcs_new(void)
{
+ yasm_bytecodehead *headp;
+ headp = yasm_xmalloc(sizeof(yasm_bytecodehead));
STAILQ_INIT(headp);
+ return headp;
}
/* Non-macro yasm_bcs_first() for non-YASM_INTERNAL users. */
* \file bytecode.h
* \brief YASM bytecode interface.
*
- * $IdPath: yasm/libyasm/bytecode.h,v 1.71 2003/03/31 08:22:05 peter Exp $
+ * $IdPath: yasm/libyasm/bytecode.h,v 1.72 2003/05/04 08:40:35 peter Exp $
*
* Copyright (C) 2001 Peter Johnson
*
/*@null@*/ yasm_output_bc_objfmt_data_func output_bc_objfmt_data)
/*@sets *buf@*/;
-/** Initialize list of bytecodes.
- * \param headp bytecode list
+/** Create list of bytecodes.
+ * \return Newly allocated bytecode list.
*/
-void yasm_bcs_initialize(yasm_bytecodehead *headp);
-#ifdef YASM_INTERNAL
-#define yasm_bcs_initialize(headp) STAILQ_INIT(headp)
-#endif
+/*@only@*/ yasm_bytecodehead *yasm_bcs_new(void);
/** Get the first bytecode in a list of bytecodes.
* \param headp bytecode list
/** Delete (free allocated memory for) a list of bytecodes.
* \param headp bytecode list
*/
-void yasm_bcs_delete(yasm_bytecodehead *headp);
+void yasm_bcs_delete(/*@only@*/ yasm_bytecodehead *headp);
/** Add bytecode to the end of a list of bytecodes.
* \note Does not make a copy of bc; so don't pass this function static or
-/* $IdPath$
+/* $IdPath: yasm/libyasm/parser.h,v 1.21 2003/03/13 06:54:19 peter Exp $
* Parser module interface header file
*
* Copyright (C) 2001 Peter Johnson
* This function returns the starting section of a linked list of sections
* (whatever was in the file).
*/
- yasm_sectionhead *(*do_parse)
+ /*@only@*/ yasm_sectionhead *(*do_parse)
(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm,
FILE *f, const char *in_filename, int save_input);
};
*/
#define YASM_LIB_INTERNAL
#include "util.h"
-/*@unused@*/ RCSID("$IdPath: yasm/libyasm/section.c,v 1.35 2003/03/15 05:07:48 peter Exp $");
+/*@unused@*/ RCSID("$IdPath: yasm/libyasm/section.c,v 1.36 2003/05/04 20:31:57 peter Exp $");
#include "errwarn.h"
#include "intnum.h"
int res_only; /* allow only resb family of bytecodes? */
- yasm_bytecodehead bc; /* the bytecodes for the section's contents */
+ /* the bytecodes for the section's contents */
+ /*@only@*/ yasm_bytecodehead *bc;
};
+/*@reldef@*/ STAILQ_HEAD(yasm_sectionhead, yasm_section);
+
static void yasm_section_delete(/*@only@*/ yasm_section *sect);
/*@-compdestroy@*/
-yasm_section *
-yasm_sections_initialize(yasm_sectionhead *headp, yasm_objfmt *of)
+yasm_sectionhead *
+yasm_sections_new(yasm_section **def, yasm_objfmt *of)
{
- yasm_section *s;
+ yasm_sectionhead *headp;
yasm_valparamhead vps;
yasm_valparam *vp;
/* Initialize linked list */
+ headp = yasm_xmalloc(sizeof(yasm_sectionhead));
STAILQ_INIT(headp);
/* Add an initial "default" section */
vp = yasm_vp_new(yasm__xstrdup(of->default_section_name), NULL);
yasm_vps_initialize(&vps);
yasm_vps_append(&vps, vp);
- s = of->sections_switch(headp, &vps, NULL, 0);
+ *def = of->sections_switch(headp, &vps, NULL, 0);
yasm_vps_delete(&vps);
- return s;
+ return headp;
}
/*@=compdestroy@*/
s->data.general.of_data = NULL;
s->start = yasm_expr_new_ident(yasm_expr_int(yasm_intnum_new_uint(start)),
lindex);
- yasm_bcs_initialize(&s->bc);
+ s->bc = yasm_bcs_new();
s->opt_flags = 0;
s->res_only = res_only;
s->type = SECTION_ABSOLUTE;
s->start = start;
- yasm_bcs_initialize(&s->bc);
+ s->bc = yasm_bcs_new();
s->opt_flags = 0;
s->res_only = 1;
cur = next;
}
STAILQ_INIT(headp);
+ yasm_xfree(headp);
}
void
yasm_bytecodehead *
yasm_section_get_bytecodes(yasm_section *sect)
{
- return §->bc;
+ return sect->bc;
}
const char *
}
}
yasm_expr_delete(sect->start);
- yasm_bcs_delete(§->bc);
+ yasm_bcs_delete(sect->bc);
yasm_xfree(sect);
}
if (print_bcs) {
fprintf(f, "%*sBytecodes:\n", indent_level, "");
- yasm_bcs_print(f, indent_level+1, §->bc);
+ yasm_bcs_print(f, indent_level+1, sect->bc);
}
}
* \file section.h
* \brief YASM section interface.
*
- * $IdPath: yasm/libyasm/section.h,v 1.37 2003/05/04 20:28:28 peter Exp $
+ * $IdPath: yasm/libyasm/section.h,v 1.38 2003/05/04 20:31:57 peter Exp $
*
* Copyright (C) 2001 Peter Johnson
*
#ifndef YASM_SECTION_H
#define YASM_SECTION_H
-#ifdef YASM_INTERNAL
-/*@reldef@*/ STAILQ_HEAD(yasm_sectionhead, yasm_section);
-#endif
-
/** Create a new section list. A default section is created as the
* first section.
- * \param headp pre-allocated section list head
+ * \param def returned; default section
* \param of object format in use
- * \return Default section.
+ * \return Newly allocated section list.
*/
-/*@dependent@*/ yasm_section *yasm_sections_initialize(yasm_sectionhead *headp,
- yasm_objfmt *of);
+/*@only@*/ yasm_sectionhead *yasm_sections_new
+ (/*@out@*/ /*@dependent@*/ yasm_section **def, yasm_objfmt *of);
/** Create a new, or continue an existing, general section. The section is
* added to a section list if there's not already a section by that name.
* section list and all bytecodes within those sections are also deleted.
* \param headp section list
*/
-void yasm_sections_delete(yasm_sectionhead *headp);
+void yasm_sections_delete(/*@only@*/ yasm_sectionhead *headp);
/** Print a section list. For debugging purposes.
* \param f file
#define YASM_LIB_INTERNAL
#define YASM_EXPR_INTERNAL
#include <libyasm.h>
-RCSID("$IdPath$");
+RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-bison.y,v 1.92 2003/03/31 05:36:30 peter Exp $");
#ifdef STDC_HEADERS
# include <math.h>
} else if (yasm__strcasecmp(name, "section") == 0 ||
yasm__strcasecmp(name, "segment") == 0) {
yasm_section *new_section =
- nasm_parser_objfmt->sections_switch(&nasm_parser_sections,
+ nasm_parser_objfmt->sections_switch(nasm_parser_sections,
valparams, objext_valparams,
lindex);
if (new_section) {
vp = yasm_vps_first(valparams);
if (vp->val)
nasm_parser_cur_section =
- yasm_sections_switch_absolute(&nasm_parser_sections,
+ yasm_sections_switch_absolute(nasm_parser_sections,
p_expr_new_ident(yasm_expr_sym(
yasm_symrec_use(vp->val, lindex))));
else if (vp->param) {
nasm_parser_cur_section =
- yasm_sections_switch_absolute(&nasm_parser_sections,
+ yasm_sections_switch_absolute(nasm_parser_sections,
vp->param);
vp->param = NULL;
}
}
} else if (!nasm_parser_arch->parse_directive(name, valparams,
objext_valparams,
- &nasm_parser_sections,
+ nasm_parser_sections,
lindex)) {
;
} else if (nasm_parser_objfmt->directive(name, valparams, objext_valparams,
- &nasm_parser_sections, lindex)) {
+ nasm_parser_sections, lindex)) {
yasm__error(lindex, N_("unrecognized directive [%s]"), name);
}
*/
#define YASM_LIB_INTERNAL
#include <libyasm.h>
-/*@unused@*/ RCSID("$IdPath$");
+/*@unused@*/ RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-parser.c,v 1.33 2003/04/01 07:26:33 peter Exp $");
#include "nasm-parser.h"
FILE *nasm_parser_in = NULL;
size_t (*nasm_parser_input) (char *buf, size_t max_size);
-yasm_sectionhead nasm_parser_sections;
+/*@only@*/ yasm_sectionhead *nasm_parser_sections;
/*@dependent@*/ yasm_section *nasm_parser_cur_section;
/* last "base" label for local (.) labels */
int nasm_parser_save_input;
-static /*@dependent@*/ yasm_sectionhead *
+static /*@only@*/ yasm_sectionhead *
nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
yasm_linemgr *lm, FILE *f, const char *in_filename,
int save_input)
nasm_parser_save_input = save_input;
/* Initialize section list */
- nasm_parser_cur_section =
- yasm_sections_initialize(&nasm_parser_sections, of);
+ nasm_parser_sections = yasm_sections_new(&nasm_parser_cur_section, of);
/* yacc debugging, needs YYDEBUG set in bison.y.in to work */
/* nasm_parser_debug = 1; */
if (nasm_parser_locallabel_base)
yasm_xfree(nasm_parser_locallabel_base);
- return &nasm_parser_sections;
+ return nasm_parser_sections;
}
/* Define valid preprocessors to use with this parser */
-/* $IdPath$
+/* $IdPath: yasm/modules/parsers/nasm/nasm-parser.h,v 1.6 2003/03/13 06:54:19 peter Exp $
* NASM-compatible parser header file
*
* Copyright (C) 2002 Peter Johnson
extern int nasm_parser_debug;
extern size_t (*nasm_parser_input) (char *buf, size_t max_size);
-extern yasm_sectionhead nasm_parser_sections;
+extern yasm_sectionhead *nasm_parser_sections;
extern /*@dependent@*/ yasm_section *nasm_parser_cur_section;
extern char *nasm_parser_locallabel_base;