[m-dev.] for review: more empty array initializers
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Feb 7 13:03:47 AEDT 2001
The diff will be OK after you address Fergus's comments, but it could be
improved.
> - list__foldl(output_number_in_vector, VarNames),
> + ( { VarNames = [] } ->
> + io__write_string("\t0\n")
> + ;
> + list__foldl(output_number_in_vector, VarNames)
> + ),
> io__write_string("};\n"),
> { decl_set_insert(DeclSet0, data_addr(
> layout_addr(proc_layout_var_names(ProcLabel))), DeclSet) }.
If a procedure has no variable names, then it would be better not to output
a var name array at all.
> - list__foldl(
> - output_layout_name_in_vector("(const MR_Proc_Layout *)\n\t&"),
> - ProcLayoutNames),
> + ( { ProcLayoutNames = [] } ->
> + io__write_string("\tNULL\n")
> + ;
> + list__foldl(output_layout_name_in_vector(
> + "(const MR_Proc_Layout *)\n\t&"),
> + ProcLayoutNames)
> + ),
At the moment, ProcLayoutNames can be the empty list only if the module does
not export any procedures or types (since types have automatically generated
unify and compare procedures). I don't think that is allowed, although I am not
sure whether the front end checks this.
> @@ -832,7 +840,11 @@
> io__write_string("\n"),
> output_layout_name_storage_type_name(VectorName, yes),
> io__write_string(" = {\n"),
> - list__foldl(output_layout_name_in_vector("&"), FileLayoutNames),
> + ( { FileLayoutNames = [] } ->
> + io__write_string("\tNULL\n")
> + ;
> + list__foldl(output_layout_name_in_vector("&"), FileLayoutNames)
> + ),
> io__write_string("};\n"),
> { decl_set_insert(DeclSet1, data_addr(layout_addr(VectorName)),
> DeclSet) }.
FileLayoutNames can be empty only if the module has *no* events with non-dummy
contexts. Even if the module has #line directives, every procedure (even
compiler-generated ones) should have a non-dummy context, so this can happen
if the module has no procedures.
> @@ -907,9 +923,13 @@
> io__write_string("\n"),
> output_layout_name_storage_type_name(LayoutName, yes),
> io__write_string(" = {\n"),
> - list__foldl(
> - output_data_addr_in_vector("(const MR_Label_Layout *)\n\t&"),
> - LabelAddrs),
> + ( { LabelAddrs = [] } ->
> + io__write_string("\tNULL\n")
> + ;
> + list__foldl(output_data_addr_in_vector(
> + "(const MR_Label_Layout *)\n\t&"),
> + LabelAddrs)
> + ),
> io__write_string("};\n"),
> { decl_set_insert(DeclSet0, data_addr(layout_addr(LayoutName)),
> DeclSet) }.
Same deal here.
Zoltan.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list