]> granicus.if.org Git - yasm/commitdiff
Use STAILQ's for datavals and bytecodes.
authorPeter Johnson <peter@tortall.net>
Sun, 19 Aug 2001 05:41:01 +0000 (05:41 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 19 Aug 2001 05:41:01 +0000 (05:41 -0000)
svn path=/trunk/yasm/; revision=146

14 files changed:
frontends/yasm/yasm.c
libyasm/bytecode.c
libyasm/bytecode.h
modules/parsers/nasm/bison.y.in
modules/parsers/nasm/nasm-bison.y
modules/parsers/nasm/nasm-parser.c
modules/parsers/nasm/parser.c
src/bytecode.c
src/bytecode.h
src/main.c
src/parsers/nasm/bison.y.in
src/parsers/nasm/nasm-bison.y
src/parsers/nasm/nasm-parser.c
src/parsers/nasm/parser.c

index f10759910fe69082438dfbc67026e1ab59bf8768..54eba8f4739b6188ec5e047dc1e6a1a7662420ea 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: yasm.c,v 1.7 2001/08/19 03:52:58 peter Exp $
+/* $Id: yasm.c,v 1.8 2001/08/19 05:41:01 peter Exp $
  * Program entry point, command line parsing
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "util.h"
 #include "bytecode.h"
 #include "section.h"
 #include "outfmt.h"
index b86e86e772d6025496e3f41039f31d03055edea6..22612e8de9e891f89c45fa16f6f9b56bad51d4d0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bytecode.c,v 1.16 2001/08/19 03:52:58 peter Exp $
+/* $Id: bytecode.c,v 1.17 2001/08/19 05:41:01 peter Exp $
  * Bytecode utility functions
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "util.h"
 #include "globals.h"
 #include "bytecode.h"
 #include "errwarn.h"
@@ -255,7 +260,6 @@ BuildBC_Insn(bytecode      *bc,
             unsigned char  im_len,
             unsigned char  im_sign)
 {
-    bc->next = (bytecode *)NULL;
     bc->type = BC_INSN;
 
     if (ea_ptr) {
@@ -306,7 +310,6 @@ BuildBC_JmpRel(bytecode      *bc,
               unsigned char  near_op2,
               unsigned char  addrsize)
 {
-    bc->next = (bytecode *)NULL;
     bc->type = BC_JMPREL;
 
     bc->data.jmprel.target = target->val;
@@ -341,9 +344,9 @@ BuildBC_JmpRel(bytecode      *bc,
 }
 
 void
-BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
+BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size)
 {
-    dataval *cur = data;
+    dataval *cur;
 
     /* First check to see if all the data elements are valid for the size
      * being set.
@@ -359,7 +362,7 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
      * constants (equ's) should always be legal, but labels should raise
      * warnings when used in db or dq context at the minimum).
      */
-    while (cur) {
+    STAILQ_FOREACH(cur, datahead, link) {
        switch (cur->type) {
            case DV_EMPTY:
            case DV_STRING:
@@ -376,13 +379,11 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
                    Error(ERR_DECLDATA_EXPR, (char *)NULL, "DT");
                break;
        }
-       cur = cur->next;
     }
 
-    bc->next = (bytecode *)NULL;
     bc->type = BC_DATA;
 
-    bc->data.data.data = data;
+    bc->data.data.datahead = *datahead;
     bc->data.data.size = size;
 
     BuildBC_Common(bc);
@@ -391,7 +392,6 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
 void
 BuildBC_Reserve(bytecode *bc, expr *numitems, unsigned long itemsize)
 {
-    bc->next = (bytecode *)NULL;
     bc->type = BC_RESERVE;
 
     bc->data.reserve.numitems = numitems;
@@ -502,7 +502,7 @@ DebugPrintBC(bytecode *bc)
            printf("Final Element Size=%u\n",
                   (unsigned int)bc->data.data.size);
            printf("Elements:\n");
-           dataval_print(bc->data.data.data);
+           dataval_print(&bc->data.data.datahead);
            break;
        case BC_RESERVE:
            printf("_Reserve_\n");
@@ -528,8 +528,6 @@ dataval_new_expr(expr *exp)
     if (!retval)
        Fatal(FATAL_NOMEM);
 
-    retval->next = (dataval *)NULL;
-    retval->last = retval;
     retval->type = DV_EXPR;
     retval->data.exp = exp;
 
@@ -544,8 +542,6 @@ dataval_new_float(double float_val)
     if (!retval)
        Fatal(FATAL_NOMEM);
 
-    retval->next = (dataval *)NULL;
-    retval->last = retval;
     retval->type = DV_FLOAT;
     retval->data.float_val = float_val;
 
@@ -560,39 +556,18 @@ dataval_new_string(char *str_val)
     if (!retval)
        Fatal(FATAL_NOMEM);
 
-    retval->next = (dataval *)NULL;
-    retval->last = retval;
     retval->type = DV_STRING;
     retval->data.str_val = str_val;
 
     return retval;
 }
 
-dataval *
-dataval_append(dataval *list, dataval *item)
-{
-    if (item)
-       item->next = (dataval *)NULL;
-
-    if (!list) {
-       item->last = item;
-       return item;
-    } else {
-       if (item) {
-           list->last->next = item;
-           list->last = item;
-           item->last = (dataval *)NULL;
-       }
-       return list;
-    }
-}
-
 void
-dataval_print(dataval *start)
+dataval_print(datavalhead *head)
 {
-    dataval *cur = start;
+    dataval *cur;
 
-    while (cur) {
+    STAILQ_FOREACH(cur, head, link) {
        switch (cur->type) {
            case DV_EMPTY:
                printf(" Empty\n");
@@ -609,7 +584,5 @@ dataval_print(dataval *start)
                printf(" String=%s\n", cur->data.str_val);
                break;
        }
-
-       cur = cur->next;
     }
 }
index f6874c013adc4232428203eff80a3dfb0da3e9b0..bb69f8db5e59d1eb8f6801809c349504f5d4ad49 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bytecode.h,v 1.16 2001/08/19 03:52:58 peter Exp $
+/* $Id: bytecode.h,v 1.17 2001/08/19 05:41:01 peter Exp $
  * Bytecode utility functions header file
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -47,8 +47,10 @@ typedef struct immval_s {
     unsigned char f_sign;      /* 1 if final imm should be signed */
 } immval;
 
+typedef STAILQ_HEAD(datavalhead_s, dataval_s) datavalhead;
+
 typedef struct dataval_s {
-    struct dataval_s *next, *last;
+    STAILQ_ENTRY(dataval_s) link;
 
     enum { DV_EMPTY, DV_EXPR, DV_FLOAT, DV_STRING } type;
 
@@ -74,7 +76,7 @@ typedef struct targetval_s {
 } targetval;
 
 typedef struct bytecode_s {
-    struct bytecode_s *next;
+    STAILQ_ENTRY(bytecode_s) link;
 
     enum { BC_EMPTY, BC_INSN, BC_JMPREL, BC_DATA, BC_RESERVE } type;
 
@@ -109,7 +111,8 @@ typedef struct bytecode_s {
            unsigned char lockrep_pre;  /* 0 indicates no prefix */
        } jmprel;
        struct {
-           dataval *data;      /* non-converted data (linked list) */
+           /* non-converted data (linked list) */
+           datavalhead datahead;
 
            /* final (converted) size of each element (in bytes) */
            unsigned char size;
@@ -173,7 +176,7 @@ void BuildBC_JmpRel(bytecode      *bc,
                    unsigned char  near_op2,
                    unsigned char  addrsize);
 
-void BuildBC_Data(bytecode *bc, dataval *data, unsigned long size);
+void BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size);
 
 void BuildBC_Reserve(bytecode      *bc,
                     struct expr_s *numitems,
@@ -187,6 +190,6 @@ dataval *dataval_new_string(char *str_val);
 
 dataval *dataval_append(dataval *list, dataval *item);
 
-void dataval_print(dataval *start);
+void dataval_print(datavalhead *head);
 
 #endif
index d0903e666416b3d071679bbe05b0e4aa1dc220d0..28590b864f6f15e2470a2e4c063e0aad4d006c4b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.23 2001/08/19 02:15:18 peter Exp $
+/* $Id: bison.y.in,v 1.24 2001/08/19 05:41:01 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 %{
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <math.h>
 #include <stdlib.h>
+#include "util.h"
 #include "symrec.h"
 #include "globals.h"
 #include "bytecode.h"
@@ -52,6 +57,7 @@ void nasm_parser_error(char *);
     expr *exp;
     immval im_val;
     targetval tgt_val;
+    datavalhead datahead;
     dataval *data;
     bytecode bc;
 }
@@ -93,7 +99,8 @@ void nasm_parser_error(char *);
 %type <syminfo> explabel
 %type <sym> label_id
 %type <tgt_val> target
-%type <data> dataval datavals
+%type <data> dataval
+%type <datahead> datavals
 
 %left '|'
 %left '^'
@@ -121,12 +128,18 @@ line: '\n'        { $$.type = BC_EMPTY; }
 ;
 
 exp: instr
-    | DECLARE_DATA datavals    { BuildBC_Data(&$$, $2, $1); }
+    | DECLARE_DATA datavals    { BuildBC_Data(&$$, &$2, $1); }
     | RESERVE_SPACE expr       { BuildBC_Reserve(&$$, $2, $1); }
 ;
 
-datavals: dataval
-    | datavals ',' dataval     { $$ = dataval_append($1, $3); }
+datavals: dataval              {
+       STAILQ_INIT(&$$);
+       STAILQ_INSERT_TAIL(&$$, $1, link);
+    }
+    | datavals ',' dataval     {
+       STAILQ_INSERT_TAIL(&$1, $3, link);
+       $$ = $1;
+    }
 ;
 
 dataval: expr_no_string                { $$ = dataval_new_expr($1); }
index d5ff200aac2578d72f7c05b794531b7a354501bf..1516e8661d79c9dec88aa9e1c43f5f18eabb9343 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.23 2001/08/19 02:15:18 peter Exp $
+/* $Id: nasm-bison.y,v 1.24 2001/08/19 05:41:01 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 %{
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <math.h>
 #include <stdlib.h>
+#include "util.h"
 #include "symrec.h"
 #include "globals.h"
 #include "bytecode.h"
@@ -52,6 +57,7 @@ void nasm_parser_error(char *);
     expr *exp;
     immval im_val;
     targetval tgt_val;
+    datavalhead datahead;
     dataval *data;
     bytecode bc;
 }
@@ -93,7 +99,8 @@ void nasm_parser_error(char *);
 %type <syminfo> explabel
 %type <sym> label_id
 %type <tgt_val> target
-%type <data> dataval datavals
+%type <data> dataval
+%type <datahead> datavals
 
 %left '|'
 %left '^'
@@ -121,12 +128,18 @@ line: '\n'        { $$.type = BC_EMPTY; }
 ;
 
 exp: instr
-    | DECLARE_DATA datavals    { BuildBC_Data(&$$, $2, $1); }
+    | DECLARE_DATA datavals    { BuildBC_Data(&$$, &$2, $1); }
     | RESERVE_SPACE expr       { BuildBC_Reserve(&$$, $2, $1); }
 ;
 
-datavals: dataval
-    | datavals ',' dataval     { $$ = dataval_append($1, $3); }
+datavals: dataval              {
+       STAILQ_INIT(&$$);
+       STAILQ_INSERT_TAIL(&$$, $1, link);
+    }
+    | datavals ',' dataval     {
+       STAILQ_INSERT_TAIL(&$1, $3, link);
+       $$ = $1;
+    }
 ;
 
 dataval: expr_no_string                { $$ = dataval_new_expr($1); }
index 15a24c3af0058887c28614949f157093959dc288..92a2df1870a0812436c73c163d9c085f8a94e53f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $
+/* $Id: nasm-parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $
  * NASM-compatible parser
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
+#include "util.h"
 #include "bytecode.h"
 #include "section.h"
 #include "outfmt.h"
index ccfcf2a2c946da23d23e6805b9211faeba77c336..feaddd1d879f7b1b667d43d70b9fabc963441267 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $
+/* $Id: parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $
  * NASM-compatible parser
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
+#include "util.h"
 #include "bytecode.h"
 #include "section.h"
 #include "outfmt.h"
index b86e86e772d6025496e3f41039f31d03055edea6..22612e8de9e891f89c45fa16f6f9b56bad51d4d0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bytecode.c,v 1.16 2001/08/19 03:52:58 peter Exp $
+/* $Id: bytecode.c,v 1.17 2001/08/19 05:41:01 peter Exp $
  * Bytecode utility functions
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "util.h"
 #include "globals.h"
 #include "bytecode.h"
 #include "errwarn.h"
@@ -255,7 +260,6 @@ BuildBC_Insn(bytecode      *bc,
             unsigned char  im_len,
             unsigned char  im_sign)
 {
-    bc->next = (bytecode *)NULL;
     bc->type = BC_INSN;
 
     if (ea_ptr) {
@@ -306,7 +310,6 @@ BuildBC_JmpRel(bytecode      *bc,
               unsigned char  near_op2,
               unsigned char  addrsize)
 {
-    bc->next = (bytecode *)NULL;
     bc->type = BC_JMPREL;
 
     bc->data.jmprel.target = target->val;
@@ -341,9 +344,9 @@ BuildBC_JmpRel(bytecode      *bc,
 }
 
 void
-BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
+BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size)
 {
-    dataval *cur = data;
+    dataval *cur;
 
     /* First check to see if all the data elements are valid for the size
      * being set.
@@ -359,7 +362,7 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
      * constants (equ's) should always be legal, but labels should raise
      * warnings when used in db or dq context at the minimum).
      */
-    while (cur) {
+    STAILQ_FOREACH(cur, datahead, link) {
        switch (cur->type) {
            case DV_EMPTY:
            case DV_STRING:
@@ -376,13 +379,11 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
                    Error(ERR_DECLDATA_EXPR, (char *)NULL, "DT");
                break;
        }
-       cur = cur->next;
     }
 
-    bc->next = (bytecode *)NULL;
     bc->type = BC_DATA;
 
-    bc->data.data.data = data;
+    bc->data.data.datahead = *datahead;
     bc->data.data.size = size;
 
     BuildBC_Common(bc);
@@ -391,7 +392,6 @@ BuildBC_Data(bytecode *bc, dataval *data, unsigned long size)
 void
 BuildBC_Reserve(bytecode *bc, expr *numitems, unsigned long itemsize)
 {
-    bc->next = (bytecode *)NULL;
     bc->type = BC_RESERVE;
 
     bc->data.reserve.numitems = numitems;
@@ -502,7 +502,7 @@ DebugPrintBC(bytecode *bc)
            printf("Final Element Size=%u\n",
                   (unsigned int)bc->data.data.size);
            printf("Elements:\n");
-           dataval_print(bc->data.data.data);
+           dataval_print(&bc->data.data.datahead);
            break;
        case BC_RESERVE:
            printf("_Reserve_\n");
@@ -528,8 +528,6 @@ dataval_new_expr(expr *exp)
     if (!retval)
        Fatal(FATAL_NOMEM);
 
-    retval->next = (dataval *)NULL;
-    retval->last = retval;
     retval->type = DV_EXPR;
     retval->data.exp = exp;
 
@@ -544,8 +542,6 @@ dataval_new_float(double float_val)
     if (!retval)
        Fatal(FATAL_NOMEM);
 
-    retval->next = (dataval *)NULL;
-    retval->last = retval;
     retval->type = DV_FLOAT;
     retval->data.float_val = float_val;
 
@@ -560,39 +556,18 @@ dataval_new_string(char *str_val)
     if (!retval)
        Fatal(FATAL_NOMEM);
 
-    retval->next = (dataval *)NULL;
-    retval->last = retval;
     retval->type = DV_STRING;
     retval->data.str_val = str_val;
 
     return retval;
 }
 
-dataval *
-dataval_append(dataval *list, dataval *item)
-{
-    if (item)
-       item->next = (dataval *)NULL;
-
-    if (!list) {
-       item->last = item;
-       return item;
-    } else {
-       if (item) {
-           list->last->next = item;
-           list->last = item;
-           item->last = (dataval *)NULL;
-       }
-       return list;
-    }
-}
-
 void
-dataval_print(dataval *start)
+dataval_print(datavalhead *head)
 {
-    dataval *cur = start;
+    dataval *cur;
 
-    while (cur) {
+    STAILQ_FOREACH(cur, head, link) {
        switch (cur->type) {
            case DV_EMPTY:
                printf(" Empty\n");
@@ -609,7 +584,5 @@ dataval_print(dataval *start)
                printf(" String=%s\n", cur->data.str_val);
                break;
        }
-
-       cur = cur->next;
     }
 }
index f6874c013adc4232428203eff80a3dfb0da3e9b0..bb69f8db5e59d1eb8f6801809c349504f5d4ad49 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bytecode.h,v 1.16 2001/08/19 03:52:58 peter Exp $
+/* $Id: bytecode.h,v 1.17 2001/08/19 05:41:01 peter Exp $
  * Bytecode utility functions header file
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -47,8 +47,10 @@ typedef struct immval_s {
     unsigned char f_sign;      /* 1 if final imm should be signed */
 } immval;
 
+typedef STAILQ_HEAD(datavalhead_s, dataval_s) datavalhead;
+
 typedef struct dataval_s {
-    struct dataval_s *next, *last;
+    STAILQ_ENTRY(dataval_s) link;
 
     enum { DV_EMPTY, DV_EXPR, DV_FLOAT, DV_STRING } type;
 
@@ -74,7 +76,7 @@ typedef struct targetval_s {
 } targetval;
 
 typedef struct bytecode_s {
-    struct bytecode_s *next;
+    STAILQ_ENTRY(bytecode_s) link;
 
     enum { BC_EMPTY, BC_INSN, BC_JMPREL, BC_DATA, BC_RESERVE } type;
 
@@ -109,7 +111,8 @@ typedef struct bytecode_s {
            unsigned char lockrep_pre;  /* 0 indicates no prefix */
        } jmprel;
        struct {
-           dataval *data;      /* non-converted data (linked list) */
+           /* non-converted data (linked list) */
+           datavalhead datahead;
 
            /* final (converted) size of each element (in bytes) */
            unsigned char size;
@@ -173,7 +176,7 @@ void BuildBC_JmpRel(bytecode      *bc,
                    unsigned char  near_op2,
                    unsigned char  addrsize);
 
-void BuildBC_Data(bytecode *bc, dataval *data, unsigned long size);
+void BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size);
 
 void BuildBC_Reserve(bytecode      *bc,
                     struct expr_s *numitems,
@@ -187,6 +190,6 @@ dataval *dataval_new_string(char *str_val);
 
 dataval *dataval_append(dataval *list, dataval *item);
 
-void dataval_print(dataval *start);
+void dataval_print(datavalhead *head);
 
 #endif
index e5c9b5357face832a226a6635c6f8bb0a7edbe6e..53c288bcb3f59574cfef5ec1f3b0da7eb088fd7a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.7 2001/08/19 03:52:58 peter Exp $
+/* $Id: main.c,v 1.8 2001/08/19 05:41:01 peter Exp $
  * Program entry point, command line parsing
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "util.h"
 #include "bytecode.h"
 #include "section.h"
 #include "outfmt.h"
index d0903e666416b3d071679bbe05b0e4aa1dc220d0..28590b864f6f15e2470a2e4c063e0aad4d006c4b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.23 2001/08/19 02:15:18 peter Exp $
+/* $Id: bison.y.in,v 1.24 2001/08/19 05:41:01 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 %{
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <math.h>
 #include <stdlib.h>
+#include "util.h"
 #include "symrec.h"
 #include "globals.h"
 #include "bytecode.h"
@@ -52,6 +57,7 @@ void nasm_parser_error(char *);
     expr *exp;
     immval im_val;
     targetval tgt_val;
+    datavalhead datahead;
     dataval *data;
     bytecode bc;
 }
@@ -93,7 +99,8 @@ void nasm_parser_error(char *);
 %type <syminfo> explabel
 %type <sym> label_id
 %type <tgt_val> target
-%type <data> dataval datavals
+%type <data> dataval
+%type <datahead> datavals
 
 %left '|'
 %left '^'
@@ -121,12 +128,18 @@ line: '\n'        { $$.type = BC_EMPTY; }
 ;
 
 exp: instr
-    | DECLARE_DATA datavals    { BuildBC_Data(&$$, $2, $1); }
+    | DECLARE_DATA datavals    { BuildBC_Data(&$$, &$2, $1); }
     | RESERVE_SPACE expr       { BuildBC_Reserve(&$$, $2, $1); }
 ;
 
-datavals: dataval
-    | datavals ',' dataval     { $$ = dataval_append($1, $3); }
+datavals: dataval              {
+       STAILQ_INIT(&$$);
+       STAILQ_INSERT_TAIL(&$$, $1, link);
+    }
+    | datavals ',' dataval     {
+       STAILQ_INSERT_TAIL(&$1, $3, link);
+       $$ = $1;
+    }
 ;
 
 dataval: expr_no_string                { $$ = dataval_new_expr($1); }
index d5ff200aac2578d72f7c05b794531b7a354501bf..1516e8661d79c9dec88aa9e1c43f5f18eabb9343 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.23 2001/08/19 02:15:18 peter Exp $
+/* $Id: nasm-bison.y,v 1.24 2001/08/19 05:41:01 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 %{
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <math.h>
 #include <stdlib.h>
+#include "util.h"
 #include "symrec.h"
 #include "globals.h"
 #include "bytecode.h"
@@ -52,6 +57,7 @@ void nasm_parser_error(char *);
     expr *exp;
     immval im_val;
     targetval tgt_val;
+    datavalhead datahead;
     dataval *data;
     bytecode bc;
 }
@@ -93,7 +99,8 @@ void nasm_parser_error(char *);
 %type <syminfo> explabel
 %type <sym> label_id
 %type <tgt_val> target
-%type <data> dataval datavals
+%type <data> dataval
+%type <datahead> datavals
 
 %left '|'
 %left '^'
@@ -121,12 +128,18 @@ line: '\n'        { $$.type = BC_EMPTY; }
 ;
 
 exp: instr
-    | DECLARE_DATA datavals    { BuildBC_Data(&$$, $2, $1); }
+    | DECLARE_DATA datavals    { BuildBC_Data(&$$, &$2, $1); }
     | RESERVE_SPACE expr       { BuildBC_Reserve(&$$, $2, $1); }
 ;
 
-datavals: dataval
-    | datavals ',' dataval     { $$ = dataval_append($1, $3); }
+datavals: dataval              {
+       STAILQ_INIT(&$$);
+       STAILQ_INSERT_TAIL(&$$, $1, link);
+    }
+    | datavals ',' dataval     {
+       STAILQ_INSERT_TAIL(&$1, $3, link);
+       $$ = $1;
+    }
 ;
 
 dataval: expr_no_string                { $$ = dataval_new_expr($1); }
index 15a24c3af0058887c28614949f157093959dc288..92a2df1870a0812436c73c163d9c085f8a94e53f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $
+/* $Id: nasm-parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $
  * NASM-compatible parser
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
+#include "util.h"
 #include "bytecode.h"
 #include "section.h"
 #include "outfmt.h"
index ccfcf2a2c946da23d23e6805b9211faeba77c336..feaddd1d879f7b1b667d43d70b9fabc963441267 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: parser.c,v 1.3 2001/08/19 02:57:02 peter Exp $
+/* $Id: parser.c,v 1.4 2001/08/19 05:41:01 peter Exp $
  * NASM-compatible parser
  *
  *  Copyright (C) 2001  Peter Johnson
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
+#include "util.h"
 #include "bytecode.h"
 #include "section.h"
 #include "outfmt.h"