Convert comments to doxygen
[libfirm] / testprograms / call_str_example.c
index 3fa59ba..ff4f0ba 100644 (file)
@@ -1,24 +1,26 @@
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Christian Schaefer, Goetz Lindenmaier
-**
-** testprogram.
+* All rights reserved.
+*
+* Authors: Christian Schaefer, Goetz Lindenmaier
+*
+* testprogram.
 */
 
-#include <stdio.h>
+# include <string.h>
+# include <stdio.h>
 
+# include "irvrfy.h"
 # include "irdump.h"
 # include "firm.h"
 
 /**
-***  This file constructs the ir for the following pseudo-program:
-***
-***  void f(char *);
-***
-***  main() {
-***    f("Hello world !");
-***  }
+*  This file constructs the ir for the following pseudo-program:
+*
+*  void f(char *);
+*
+*  main() {
+*    f("Hello world !");
+*  }
 **/
 
 int main(int argc, char **argv)
@@ -39,14 +41,14 @@ int main(int argc, char **argv)
   string_ptr = new_type_pointer (
                 id_from_str ("ptr_to_string", 13),
                 new_type_array (id_from_str ("char_arr", 8), 1,
-                                new_type_primitive (id_from_str("char", 4), mode_c)));
+                                new_type_primitive (id_from_str("char", 4), mode_Bu)));
   /* FIRM was designed for oo languages where all methods belong to a class.
    * For imperative languages like C we view a program as a large class containing
    * all functions of the program as methods in this class.  This class is
    * automatically generated.
    * We use the same name for the method type as for the method entity.
    */
-#define METHODNAME "main"
+#define METHODNAME "CALL_STR_EXAMPLE_main"
 #define NRARGS 0
 #define NRES 0
   owner = get_glob_type();
@@ -64,7 +66,7 @@ int main(int argc, char **argv)
   set_method_param_type(proc_called, 0, string_ptr);
 
   /* Make the entity for main needed for a correct  ir_graph.  */
-#define ENTITYNAME "main"
+#define ENTITYNAME "CALL_STR_EXAMPLE_main"
   ent = new_entity (owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)),
                     proc_main);
 
@@ -76,7 +78,7 @@ int main(int argc, char **argv)
   irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
 
   /* the string is entered in the constant table. const_str is a pointer to the string */
-  const_str = new_Const (mode_p, tarval_p_from_str ("Hello world!"));
+  const_str = new_Const (mode_P, tarval_P_from_str ("Hello world!"));
 
   /* get the pointer to the procedure from the class type */
   /* this is how a pointer to be fixed by the linker is represented after
@@ -109,6 +111,8 @@ int main(int argc, char **argv)
   /* Now we can mature the end block as all it's predecessors are known. */
   mature_block (get_irg_end_block(irg));
 
+  finalize_cons (irg);
+
   printf("Optimizing ...\n");
   dead_node_elimination(irg);