Re: Code generation problems

Frederic Merizen <[email protected]> Sun, 03 Dec 2006 20:35:27 +0100
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
Le vendredi 01 décembre 2006 à 17:20 +0000, Oliver Elphick a écrit :
> On Fri, 2006-12-01 at 17:06 +0100, Frederic Merizen wrote:
> > Apparently, class 832
> > -is not generic
> > -either has no descendants in which the routine(s) that create(s) the agents 
> > is/are alive and has/have not been redefined, or the routine does not trigger 
> > the bug when compiled for those descendants
> 
> I'm afraid I don't understand the explanation.
> 
>         prod75.c: In function '_T832C832l1362c106':
>         prod75.c: In function '_T832C832l1357c98':
>         prod75.c: In function '_T832C832l1352c106':
>         prod75.c: In function '_T832C832l1346c98':

>         prod75.c: In function '_T832C88l1117c28':

Ah yes, I didn't address this one because it's only a warning about an
unused variable. Anyway, an agent creation is compiled to more than one
C function when the type of Current is not statically known. Here,
'_T832C832l1346c98' corresponds to the expression agent
insert_value_if_not_null(Result, seq_values_command, ?)
that was written on line 1117, column 28 of GDB_PERSISTENT_OBJECT, but
that gets executed when Current is a PRODUCT.

> I have used this way of doing this in several other classes in another
> system without a problem (and it used to compile in 2.1).  Is there a
> workaround?

I'd suspect the compiler doesn't like the nested agent creations, but I
don't know for sure... Actually I can't reproduce the bug with the
current compiler, maybe it is already fixed.

> What I have is these classes (class id numbers and line numbers
> indicated):
>         
>         class GDB_PERSISTENT_OBJECT -- #88
>         ...
>         feature
>         
>            insert_values_fragment: STRING is
>                  -- a fragment of an SQL command to be included inside the 
>                  -- VALUES(...) clause of an INSERT command
>               require
>                  has_fields: has_field_values
>               do
>                  create Result.make_empty
>                  create seq_values_command.make_empty
>         -- line #1117:
>                  field_list.do_all(agent insert_value_if_not_null(Result, seq_values_command, ?))
>               ensure
>                  not_void: Result /= Void
>               end
>         
>            insert_fields_fragment: STRING is
>                  -- a fragment of an SQL command to specify the fields to be 
>                  -- included in an INSERT command
>               require
>                  has_fields: has_field_values
>               do
>                  create Result.make(0)
>         -- for some reason, this line does not cause the bug:
>                  field_list.do_all(agent insert_field_if_not_null(Result, ?))
>               ensure
>                  not_void: Result /= Void
>               end
>         
>            add_to_why_object_cannot_be_stored(instr: STRING; obj: GDB_PERSISTENT_OBJECT) is
>                  -- This function is intended to be used in an agent call from some
>                  -- object maintaining a list of objects conforming to this class.
>                  -- The function adds to the string referenced by instr.
>               require
>                  good_string: instr /= Void
>                  good_object: obj /= Void
>               local
>                  outstr: STRING
>               do
>                  outstr := instr
>                  if not object_can_be_stored then
>                     outstr.append(why_object_cannot_be_stored)
>                  end
>               end
>         ---
>         end -- GDB_PERSISTENT_OBJECT
>         
>         
>         
>         class PRODUCT_DB_MAP
>         
>         inherit
>         
>            GDB_PERSISTENT_OBJECT
>         
>         feature
>         ...
>         
>           why_object_cannot_be_stored: STRING is
>         ...
>              end
>         
>         end -- PRODUCT_DB_MAP
>         
>         
>         
>         
>         class PRODUCT  -- #832
>         
>         inherit
>         
>            PRODUCT_DB_MAP
>         ...
>         feature
>         
>            why_forecasts_cannot_be_stored: STRING is
>               do
>                  create Result.make(0)
>         -- line #1346:
>                  sales_forecasts.do_all(agent {HASHED_DICTIONARY[ARRAY[SALES_FORECAST], INTEGER]}.do_all(agent {ARRAY[SALES_FORECAST]}.do_all(agent add_to_why_object_cannot_be_stored(Result, ?))))
>               end
>            
>            why_van_forecasts_cannot_be_stored: STRING is
>               do
>                  create Result.make(0)
>         -- line #1352:
>                  van_sales_forecasts.do_all(agent {HASHED_DICTIONARY[ARRAY[VAN_SALES_FORECAST], INTEGER]}.do_all(agent {ARRAY[VAN_SALES_FORECAST]}.do_all(agent add_to_why_object_cannot_be_stored(Result, ?))))
>               end
>            
>            store_forecasts(q: DB_QUERY) is
>               do
>         -- line #1357:
>                  sales_forecasts.do_all(agent {HASHED_DICTIONARY[ARRAY[SALES_FORECAST], INTEGER]}.do_all(agent {ARRAY[SALES_FORECAST]}.do_all(agent {SALES_FORECAST}.store(q))))
>               end
>            
>            store_van_forecasts(q: DB_QUERY) is
>               do
>         -- line #1362
>                  van_sales_forecasts.do_all(agent {HASHED_DICTIONARY[ARRAY[VAN_SALES_FORECAST], INTEGER]}.do_all(agent {ARRAY[VAN_SALES_FORECAST]}.do_all(agent {VAN_SALES_FORECAST}.store(q))))
>               end
>         
>         end -- PRODUCT