[svn:parrot] r43991 - trunk/compilers/pirc/src

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Feb 16 08:44:48 UTC 2010


Author: bacek
Date: Tue Feb 16 08:44:48 2010
New Revision: 43991
URL: https://trac.parrot.org/parrot/changeset/43991

Log:
Headerizer happiness work

Modified:
   trunk/compilers/pirc/src/pirsymbol.c

Modified: trunk/compilers/pirc/src/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/src/pirsymbol.c	Tue Feb 16 08:44:26 2010	(r43990)
+++ trunk/compilers/pirc/src/pirsymbol.c	Tue Feb 16 08:44:48 2010	(r43991)
@@ -55,26 +55,47 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
+static global_label * new_global_label(
+    ARGIN(lexer_state * const lexer),
+    ARGIN(char const * const name))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
 static local_label * new_local_label(
-    NOTNULL(lexer_state * const lexer),
-    NOTNULL(char const * const name),
+    ARGIN(lexer_state * const lexer),
+    ARGIN(char const * const name),
     unsigned offset)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-static int next_register(NOTNULL(lexer_state * const lexer), pir_type type)
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+static pir_reg * new_pir_reg(
+    ARGIN(lexer_state * const lexer),
+    pir_type type,
+    int regno)
+        __attribute__nonnull__(1);
+
+static int next_register(ARGIN(lexer_state * const lexer), pir_type type)
         __attribute__nonnull__(1);
 
 static int use_register(
-    NOTNULL(lexer_state * const lexer),
+    ARGIN(lexer_state * const lexer),
     pir_type type,
     int regno,
     int pasmregno)
         __attribute__nonnull__(1);
 
+#define ASSERT_ARGS_new_global_label __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(lexer) \
+    , PARROT_ASSERT_ARG(name))
 #define ASSERT_ARGS_new_local_label __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(lexer) \
     , PARROT_ASSERT_ARG(name))
+#define ASSERT_ARGS_new_pir_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(lexer))
 #define ASSERT_ARGS_next_register __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(lexer))
 #define ASSERT_ARGS_use_register __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -125,7 +146,8 @@
 
 */
 static int
-next_register(NOTNULL(lexer_state * const lexer), pir_type type) {
+next_register(ARGIN(lexer_state * const lexer), pir_type type)
+{
     ASSERT_ARGS(next_register)
 
     CURRENT_SUB(lexer)->info.regs_used[type]++; /* count number of registers used */
@@ -136,8 +158,8 @@
 
 /*
 
-=item C<void
-assign_vanilla_register(lexer_state * const lexer, symbol * const sym)>
+=item C<void assign_vanilla_register(lexer_state * const lexer, symbol * const
+sym)>
 
 Assign a new register to symbol C<sym>, and create a new live interval for C<sym>.
 
@@ -145,7 +167,9 @@
 
 */
 void
-assign_vanilla_register(NOTNULL(lexer_state * const lexer), symbol * const sym) {
+assign_vanilla_register(NOTNULL(lexer_state * const lexer),
+        ARGMOD(symbol * const sym))
+{
     sym->info.color    = next_register(lexer, sym->info.type);
     /* fprintf(stderr, "assigning vanilla reg %d to symbol %s\n", sym->info.color,
                     sym->info.id.name);
@@ -169,8 +193,7 @@
 
 /*
 
-=item C<static unsigned
-get_hashcode(char const * const str, unsigned num_buckets)>
+=item C<unsigned get_hashcode(char const * const str, unsigned num_buckets)>
 
 Calculate the hash code for the string C<str>.
 This code is taken from IMCC.
@@ -181,7 +204,8 @@
 PARROT_PURE_FUNCTION
 PARROT_WARN_UNUSED_RESULT
 unsigned
-get_hashcode(NOTNULL(char const * const str), unsigned num_buckets) {
+get_hashcode(NOTNULL(char const * const str), unsigned num_buckets)
+{
     unsigned long  key = 0;
     char const    *s;
 
@@ -193,8 +217,8 @@
 
 /*
 
-=item C<void
-store_bucket(hashtable * const table, bucket * const buck, unsigned long hash)>
+=item C<void store_bucket(hashtable * const table, bucket * const buck, unsigned
+long hash)>
 
 Store the bucket C<buck> in the hashtable C<table> at index C<hash>.
 
@@ -202,7 +226,9 @@
 
 */
 void
-store_bucket(NOTNULL(hashtable * const table), NOTNULL(bucket * const buck), unsigned long hash) {
+store_bucket(NOTNULL(hashtable * const table),
+        NOTNULL(bucket * const buck), unsigned long hash)
+{
     buck->next = table->contents[hash];
     table->contents[hash] = buck;
 }
@@ -219,14 +245,15 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 bucket *
-get_bucket(NOTNULL(hashtable * const table), unsigned long hash) {
+get_bucket(NOTNULL(hashtable * const table), unsigned long hash)
+{
     return table->contents[hash];
 }
 
 /*
 
-=item C<symbol *
-new_symbol(lexer_state * const lexer, char const * const name, pir_type type)>
+=item C<symbol * new_symbol(lexer_state * const lexer, char const * const name,
+pir_type type)>
 
 Create a new symbol node, returns it after initialization.
 
@@ -236,7 +263,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 symbol *
-new_symbol(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name), pir_type type) {
+new_symbol(NOTNULL(lexer_state * const lexer),
+        NOTNULL(char const * const name), pir_type type)
+{
     symbol *sym = pir_mem_allocate_zeroed_typed(lexer, symbol);
 
     sym->info.id.name = name;
@@ -315,7 +344,8 @@
 
 */
 void
-check_unused_symbols(NOTNULL(lexer_state * const lexer)) {
+check_unused_symbols(NOTNULL(lexer_state * const lexer))
+{
     subroutine *subiter;
 
     /* if there's no subs, just return. */
@@ -349,8 +379,8 @@
 
 /*
 
-=item C<symbol *
-find_symbol(lexer_state * const lexer, char const * const name)>
+=item C<symbol * find_symbol(lexer_state * const lexer, char const * const
+name)>
 
 Return the node for the symbol or NULL if the symbol
 is not defined. If an attempt is made to find a symbol,
@@ -363,7 +393,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 symbol *
-find_symbol(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name)) {
+find_symbol(NOTNULL(lexer_state * const lexer),
+        NOTNULL(char const * const name))
+{
     hashtable    *table    = &CURRENT_SUB(lexer)->symbols;
     unsigned long hashcode = get_hashcode(name, table->size);
     bucket       *buck     = get_bucket(table, hashcode);
@@ -401,8 +433,8 @@
 
 /*
 
-=item C<static pir_reg *
-new_pir_reg(lexer_state * const lexer, pir_type type, int regno)>
+=item C<static pir_reg * new_pir_reg(lexer_state * const lexer, pir_type type,
+int regno)>
 
 Create a new PIR register node representing PIR/symbolic register
 identified by C<regno> and of type C<type>.
@@ -413,7 +445,8 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static pir_reg *
-new_pir_reg(NOTNULL(lexer_state * const lexer), pir_type type, int regno) {
+new_pir_reg(ARGIN(lexer_state * const lexer), pir_type type, int regno)
+{
     pir_reg *r = pir_mem_allocate_zeroed_typed(lexer, pir_reg);
 
     r->info.type     = type;
@@ -427,8 +460,8 @@
 
 /*
 
-=item C<pir_reg *
-find_register(lexer_state * const lexer, pir_type type, int regno)>
+=item C<pir_reg * find_register(lexer_state * const lexer, pir_type type, int
+regno)>
 
 Find (symbolic) register no. C<regno> of type C<type>. If it's found,
 a pointer to it is returned, if not, NULL is returned.
@@ -439,7 +472,8 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 pir_reg *
-find_register(NOTNULL(lexer_state * const lexer), pir_type type, int regno) {
+find_register(ARGIN(lexer_state * const lexer), pir_type type, int regno)
+{
     /* should do a binary search. fix later.
      */
     pir_reg *iter = CURRENT_SUB(lexer)->registers[type];
@@ -486,7 +520,9 @@
 
 */
 static int
-use_register(NOTNULL(lexer_state * const lexer), pir_type type, int regno, int pasmregno) {
+use_register(ARGIN(lexer_state * const lexer), pir_type type,
+        int regno, int pasmregno)
+{
     ASSERT_ARGS(use_register)
 
     pir_reg *reg;
@@ -539,8 +575,7 @@
 
 /*
 
-=item C<int
-color_reg(struct lexer_state * const lexer, pir_type type, int regno)>
+=item C<int color_reg(lexer_state * const lexer, pir_type type, int regno)>
 
 Find register C<regno> of type C<type>; if it was used before in the
 current subroutine, a (pasm) register was already assigned to it, which
@@ -553,7 +588,8 @@
 
 */
 int
-color_reg(NOTNULL(lexer_state * const lexer), pir_type type, int regno) {
+color_reg(ARGIN(lexer_state * const lexer), pir_type type, int regno)
+{
     pir_reg *reg = find_register(lexer, type, regno);
 
     /* was the register already used, then it was already colored by
@@ -589,8 +625,8 @@
 
 /*
 
-=item C<static global_label *
-new_global_label(char * const name)>
+=item C<static global_label * new_global_label(lexer_state * const lexer, char
+const * const name)>
 
 Constructor to create a new global_label object.
 
@@ -600,7 +636,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static global_label *
-new_global_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name)) {
+new_global_label(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const name))
+{
     global_label *glob = pir_mem_allocate_zeroed_typed(lexer, global_label);
     glob->name         = name;
     glob->const_table_index = 0;
@@ -609,8 +647,8 @@
 
 /*
 
-=item C<void
-store_global_label(struct lexer_state * const lexer, char * const name)>
+=item C<void store_global_label(lexer_state * const lexer, char const * const
+name)>
 
 Store the global identifier C<name> in C<lexer>'s global label table.
 
@@ -618,7 +656,9 @@
 
 */
 void
-store_global_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name)) {
+store_global_label(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const name))
+{
     hashtable    *table = &lexer->globals;
     unsigned long hash  = get_hashcode(name, table->size);
     bucket *b           = new_bucket(lexer);
@@ -629,8 +669,8 @@
 
 /*
 
-=item C<global_label *
-find_global_label(struct lexer_state * const lexer, char const * const name)>
+=item C<global_label * find_global_label(lexer_state * const lexer, char const *
+const name)>
 
 Find the global identifier C<name>. If no such identifier was found,
 then NULL is returned.
@@ -641,7 +681,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 global_label *
-find_global_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name)) {
+find_global_label(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const name))
+{
     hashtable    *table    = &lexer->globals;
     unsigned long hashcode = get_hashcode(name, table->size);
     bucket *b              = get_bucket(table, hashcode);
@@ -657,8 +699,8 @@
 
 /*
 
-=item C<void
-store_global_constant(lexer_state *lexer, constant * const c)>
+=item C<void store_global_constant(lexer_state * const lexer, constdecl * const
+c)>
 
 Store the globally defined constant C<c> in the constant table.
 
@@ -666,7 +708,9 @@
 
 */
 void
-store_global_constant(NOTNULL(lexer_state * const lexer), NOTNULL(constdecl * const c)) {
+store_global_constant(ARGIN(lexer_state * const lexer),
+        ARGIN(constdecl * const c))
+{
     hashtable    *table  = &lexer->constants;
     unsigned long hash   = get_hashcode(c->name, table->size);
     bucket *b            = new_bucket(lexer);
@@ -676,8 +720,8 @@
 
 /*
 
-=item C<constant *
-find_global_constant(lexer_state *lexer, char * const name)>
+=item C<constdecl * find_global_constant(lexer_state * const lexer, char const *
+const name)>
 
 Find a constant defined as C<name>. If no constant was defined by
 that name, then NULL is returned.
@@ -688,7 +732,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 constdecl *
-find_global_constant(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name)) {
+find_global_constant(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const name))
+{
     hashtable    *table    = &lexer->constants;
     unsigned long hashcode = get_hashcode(name, table->size);
     bucket *b              = get_bucket(table, hashcode);
@@ -722,8 +768,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static local_label *
-new_local_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const name),
-                unsigned offset)
+new_local_label(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const name),
+        unsigned offset)
 {
     ASSERT_ARGS(new_local_label)
 
@@ -745,8 +792,9 @@
 
 */
 void
-store_local_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const labelname),
-                  unsigned offset)
+store_local_label(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const labelname),
+        unsigned offset)
 {
     local_label  *l     = new_local_label(lexer, labelname, offset);
     hashtable    *table = &CURRENT_SUB(lexer)->labels;
@@ -758,8 +806,8 @@
 
 /*
 
-=item C<unsigned
-find_local_label(lexer_state * const lexer, char const * const labelname)>
+=item C<unsigned find_local_label(lexer_state * const lexer, char const * const
+labelname)>
 
 Find the offset for label C<labelname>. If C<labelname> was not defined as
 a label, an error is emitted, otherwise, the offset of that label is returned.
@@ -769,7 +817,9 @@
 */
 PARROT_WARN_UNUSED_RESULT
 unsigned
-find_local_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const labelname)) {
+find_local_label(ARGIN(lexer_state * const lexer),
+        ARGIN(char const * const labelname))
+{
     hashtable    *table    = &CURRENT_SUB(lexer)->labels;
     unsigned long hashcode = get_hashcode(labelname, table->size);
     bucket *b              = get_bucket(table, hashcode);


More information about the parrot-commits mailing list