]> granicus.if.org Git - yasm/commitdiff
Add valparam data structure.
authorPeter Johnson <peter@tortall.net>
Sun, 18 Nov 2001 18:44:26 +0000 (18:44 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 18 Nov 2001 18:44:26 +0000 (18:44 -0000)
svn path=/trunk/yasm/; revision=340

Mkfiles/Makefile.dj
Mkfiles/Makefile.flat
Mkfiles/Makefile.vc
libyasm/util.h
libyasm/valparam.c [new file with mode: 0644]
libyasm/valparam.h [new file with mode: 0644]
src/Makefile.am
src/util.h
src/valparam.c [new file with mode: 0644]
src/valparam.h [new file with mode: 0644]
util.h

index 4fa8fbf453c96f4f0e341379d17f32717cb2b8fe..df17d15e5cfed7521b09b70a889d4be8454a3a23 100644 (file)
@@ -31,6 +31,7 @@ SRC_OBJS= \
  src/mergesort.o \
  src/ternary.o \
  src/bitvect.o \
+ src/valparam.o \
  src/xmalloc.o \
  src/xstrdup.o \
  src/strcasecmp.o
index 222c25903c75c0442e92bab8662d0712937ed726..0f8b9713be952970423547d2e550a26346f3844d 100644 (file)
@@ -40,6 +40,7 @@ SRC_OBJS= \
  src/mergesort.o \
  src/ternary.o \
  src/bitvect.o \
+ src/valparam.o \
  src/xmalloc.o \
  src/xstrdup.o \
  src/strcasecmp.o
index 9b9b05de0a55cfc52c23d293d57ae875439ff781..5c454a9d7df8f2596cc70b81e9dcf1894c20016c 100644 (file)
@@ -31,6 +31,7 @@ SRC_OBJS= \
  src\mergesort.obj \\r
  src\ternary.obj \\r
  src\bitvect.obj \\r
+ src\valparam.obj \\r
  src\xmalloc.obj \\r
  src\xstrdup.obj \\r
  src\strcasecmp.obj\r
index aae7c4696d43e091588a7f886b5347b6df19b72e..fb4e0d50fd75b54ccd4ed933315e3695d6f563b0 100644 (file)
@@ -112,4 +112,6 @@ void xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p);
 
 #include "coretype.h"
 
+#include "valparam.h"
+
 #endif
diff --git a/libyasm/valparam.c b/libyasm/valparam.c
new file mode 100644 (file)
index 0000000..5e2e82b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Value/Parameter type functions
+ *
+ *  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
+ */
+#include "util.h"
+/*@unused@*/ RCSID("$IdPath$");
+
+#include "expr.h"
+
+
+void
+vps_delete(valparamhead *headp)
+{
+    valparam *cur, *next;
+
+    cur = STAILQ_FIRST(headp);
+    while (cur) {
+       next = STAILQ_NEXT(cur, link);
+       expr_delete(cur->val);
+       if (cur->param)
+           expr_delete(cur->param);
+       xfree(cur);
+       cur = next;
+    }
+    STAILQ_INIT(headp);
+}
diff --git a/libyasm/valparam.h b/libyasm/valparam.h
new file mode 100644 (file)
index 0000000..50ac782
--- /dev/null
@@ -0,0 +1,50 @@
+/* $IdPath$
+ * Value/Parameter type definition
+ *
+ *  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_VALPARAM_H
+#define YASM_VALPARAM_H
+
+typedef struct valparam {
+    /*@reldef@*/ STAILQ_ENTRY(valparam) link;
+    /*@owned@*/ expr *val;
+    /*@owned@*/ /*@null@*/ expr *param;
+} valparam;
+typedef /*@reldef@*/ STAILQ_HEAD(valparamhead, valparam) valparamhead;
+
+void vp_new(/*@out@*/ valparam *r, /*@keep@*/ expr *v, /*@keep@*/ expr *p);
+#define vp_new(r, v, p)                do {    \
+       r = xmalloc(sizeof(valparam));  \
+       r->val = v;                     \
+       r->param = p;                   \
+    } while(0)
+
+void vps_initialize(/*@out@*/ valparamhead *headp);
+#define vps_initialize(headp)  STAILQ_INIT(headp)
+void vps_delete(valparamhead *headp);
+void vps_append(valparamhead *headp, /*@keep@*/ valparam *vp);
+#define vps_append(headp, vp)  do {                \
+       if (vp)                                     \
+           STAILQ_INSERT_TAIL(headp, vp, link);    \
+    } while(0)
+
+#define vps_foreach(iter, headp)    STAILQ_FOREACH(iter, headp, link)
+
+#endif
index c97dfafe5a4c3b2991214d7cbb15c01f97bcb6e4..fd68d0924219aa826e05a5df02f21ef58967ce73 100644 (file)
@@ -56,6 +56,8 @@ libyasm_a_SOURCES = \
        ternary.h               \
        bitvect.c               \
        bitvect.h               \
+       valparam.c              \
+       valparam.h              \
        xmalloc.c               \
        xstrdup.c               \
        strcasecmp.c
index aae7c4696d43e091588a7f886b5347b6df19b72e..fb4e0d50fd75b54ccd4ed933315e3695d6f563b0 100644 (file)
@@ -112,4 +112,6 @@ void xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p);
 
 #include "coretype.h"
 
+#include "valparam.h"
+
 #endif
diff --git a/src/valparam.c b/src/valparam.c
new file mode 100644 (file)
index 0000000..5e2e82b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Value/Parameter type functions
+ *
+ *  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
+ */
+#include "util.h"
+/*@unused@*/ RCSID("$IdPath$");
+
+#include "expr.h"
+
+
+void
+vps_delete(valparamhead *headp)
+{
+    valparam *cur, *next;
+
+    cur = STAILQ_FIRST(headp);
+    while (cur) {
+       next = STAILQ_NEXT(cur, link);
+       expr_delete(cur->val);
+       if (cur->param)
+           expr_delete(cur->param);
+       xfree(cur);
+       cur = next;
+    }
+    STAILQ_INIT(headp);
+}
diff --git a/src/valparam.h b/src/valparam.h
new file mode 100644 (file)
index 0000000..50ac782
--- /dev/null
@@ -0,0 +1,50 @@
+/* $IdPath$
+ * Value/Parameter type definition
+ *
+ *  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_VALPARAM_H
+#define YASM_VALPARAM_H
+
+typedef struct valparam {
+    /*@reldef@*/ STAILQ_ENTRY(valparam) link;
+    /*@owned@*/ expr *val;
+    /*@owned@*/ /*@null@*/ expr *param;
+} valparam;
+typedef /*@reldef@*/ STAILQ_HEAD(valparamhead, valparam) valparamhead;
+
+void vp_new(/*@out@*/ valparam *r, /*@keep@*/ expr *v, /*@keep@*/ expr *p);
+#define vp_new(r, v, p)                do {    \
+       r = xmalloc(sizeof(valparam));  \
+       r->val = v;                     \
+       r->param = p;                   \
+    } while(0)
+
+void vps_initialize(/*@out@*/ valparamhead *headp);
+#define vps_initialize(headp)  STAILQ_INIT(headp)
+void vps_delete(valparamhead *headp);
+void vps_append(valparamhead *headp, /*@keep@*/ valparam *vp);
+#define vps_append(headp, vp)  do {                \
+       if (vp)                                     \
+           STAILQ_INSERT_TAIL(headp, vp, link);    \
+    } while(0)
+
+#define vps_foreach(iter, headp)    STAILQ_FOREACH(iter, headp, link)
+
+#endif
diff --git a/util.h b/util.h
index aae7c4696d43e091588a7f886b5347b6df19b72e..fb4e0d50fd75b54ccd4ed933315e3695d6f563b0 100644 (file)
--- a/util.h
+++ b/util.h
@@ -112,4 +112,6 @@ void xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p);
 
 #include "coretype.h"
 
+#include "valparam.h"
+
 #endif