#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
-
+#ifdef HAVE_STRING_H
# include <string.h>
+#endif
+
+#include <assert.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/encoding.h>
#include "read_t.h"
#include "read.h"
#include "irvrfy.h"
#include "type.h"
#include "tv.h"
+#include "xmalloc.h"
+
+# define MY_ENCODING "ISO-8859-1"
+
+# define CHECK(ptr,msg) assert (ptr && msg)
+
+# define NODE_NAME(n, m) (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
+# define CHECK_NAME(n, m) assert (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
+
+# define NEW(T) (T*)xmalloc(sizeof (T))
+
#define VERBOSE_PRINTING 0
#if VERBOSE_PRINTING
/* this is only used inside a VERBOSE_PRINT() call */
-static char *effect_string[] = {
+static const char *effect_string[] = {
"arg",
"valref",
"select",
free (sel);
if (0 != n_args) {
- const ident **args = (const ident**) malloc(n_args * sizeof(const ident*));
+ const ident **args = (const ident**) xmalloc(n_args * sizeof(const ident*));
int i = 0;
while (NULL != arg) {
child = child->next;
}
- ins = (const ident **) malloc (n_ins * sizeof (const ident *) );
+ ins = (const ident **) xmalloc (n_ins * sizeof (const ident *) );
i = 0;
child = get_valid_child(joinelm);
VERBOSE_PRINT ((stdout, "type node \t0x%08x (%s)\n", (int) typeelm, tp_id));
VERBOSE_PRINT ((stdout, "type = \"%s\"\n", getNodeTypeStr (typeelm)));
- type = (type_t*) malloc (sizeof (type_t));
+ type = (type_t*) xmalloc (sizeof (type_t));
type -> type_ident = new_id_from_str(getNodeTypeStr (typeelm));
type -> id = new_id_from_str(tp_id);
curr_effs = NEW (proc_t);
curr_effs -> proc_ident = new_id_from_str(procname);
curr_effs -> ownerid = new_id_from_str(ownerid);
- curr_effs->effs = (eff_t**) malloc (n_effs * sizeof (eff_t*));
+ curr_effs->effs = (eff_t**) xmalloc (n_effs * sizeof (eff_t*));
cur = effelm -> xmlChildrenNode;
while (NULL != cur) {
static
-void read_extern (const char *filename)
+int read_extern (const char *filename)
{
/* xmlNsPtr ns = NULL; */ /* no namespace for us */
xmlDocPtr doc; /* whole document */
LIBXML_TEST_VERSION xmlKeepBlanksDefault (0);
VERBOSE_PRINT((stdout, "read file %s\n", filename));
doc = xmlParseFile (filename);
- CHECK (doc, "xmlParseFile");
+ if (! doc)
+ return 0;
cur = xmlDocGetRootElement (doc);
CHECK (cur, "xmlDocGetRootElement");
module -> next = modules;
modules = module;
+
+ return 1;
}
/********************************************************************/
addr = find_valueid_in_proc_effects(eff -> effect.call.valrefid, proc);
assert(addr && "no address for load");
- /* if addr is Unknown, set propper mode */
+ /* if addr is Unknown, set proper mode */
if(iro_Unknown == get_irn_opcode(addr -> firmnode)) {
set_irn_mode(addr -> firmnode, mode_P);
}
if(ent) {
/* the address */
sel = new_simpleSel(get_store(), addr -> firmnode, ent);
- /* mthod type */
+ /* method type */
mtype = get_entity_type(ent);
- mik = true;
+ mik = 1;
}
else {
/* the address */
sel = addr -> firmnode;
- /* mthod type */
+ /* method type */
mtype = get_unknown_type();
- mik = false;
+ mik = 0;
}
/* the args */
c_block = new_immBlock (); /* for the Phi after the branch(es) */
- ins = (ir_node**) malloc (n_ins * sizeof (ir_node*));
+ ins = (ir_node**) xmalloc (n_ins * sizeof (ir_node*));
for (i = 0; i < n_ins; i ++) {
ir_node *projX = NULL;
ir_node *s_block = NULL;
VERBOSE_PRINT((stdout, "verify graph\n"));
irg_vrfy(irg);
VERBOSE_PRINT((stdout, "finalize construction\n"));
- finalize_cons (irg);
+ irg_finalize_cons (irg);
}
/********************************************************************/
typ = find_type_in_module(module, xmlent -> owner);
assert(typ && "class not found in module");
type = typ -> f_tp;
- assert(is_class_type(type));
+ assert(is_Class_type(type));
num = get_class_n_members(type);
ent = NULL;
for(i = 0; i < num; i++) {
class_typ = get_irp_type(i);
VERBOSE_PRINT((stdout, "test type %s\n", get_type_name(class_typ)));
- if(is_class_type(class_typ)
- && (type -> type_ident == get_type_ident(class_typ))) {
- /* found class type */
- VERBOSE_PRINT((stdout, "found type %s\n", get_type_name(class_typ)));
- break;
+ if (is_Class_type(class_typ)
+ && (type -> type_ident == get_type_ident(class_typ))) {
+ /* found class type */
+ VERBOSE_PRINT((stdout, "found type %s\n", get_type_name(class_typ)));
+ break;
}
class_typ = NULL;
}
VERBOSE_PRINT((stdout, "found global type %s\n", get_type_name(class_typ)));
}
assert(class_typ && "type not found");
- assert(is_class_type(class_typ) && "is not a class type");
+ assert(is_Class_type(class_typ) && "is not a class type");
type -> f_tp = class_typ;
/* find entity for procedure in class */
}
-void create_abstraction(const char *filename)
+int create_abstraction(const char *filename)
{
module_t *module;
/* read and parse XML file */
- read_extern(filename);
+ if (! read_extern(filename))
+ return 0;
/* finished reading and parsing here */
/* build FIRM graphs */
entities = NULL;
procs = NULL;
modules = NULL;
+
+ return 1;
}
\f
/*
* $Log$
+ * Revision 1.23 2005/11/18 09:46:50 beck
+ * removed depency of bool type and stdbool.h (not C89)
+ *
+ * Revision 1.22 2005/08/16 10:18:35 beck
+ * create_abstraction() now returns an error code if the file could not
+ * be opened.
+ *
+ * Revision 1.21 2005/03/10 10:05:38 goetz
+ * chanmged method name
+ *
+ * Revision 1.20 2005/01/05 14:28:35 beck
+ * renames all is_x*_type() functions to is_X*_type() to prevent name clash with EDG frontend
+ *
+ * Revision 1.19 2004/12/10 15:14:34 beck
+ * used xmalloc instead of malloc
+ *
+ * Revision 1.18 2004/12/02 16:21:42 beck
+ * fixed config.h include
+ *
* Revision 1.17 2004/11/23 14:17:31 liekweg
* fenced out currently unneeded static functions
*