[m-rev.] for review: postpone the processing of reuse/alias-pragma's

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Thu Aug 22 01:40:56 AEST 2002


> > @@ -114,6 +114,36 @@
> >  	--->    do_aditi_compilation
> >  	;       no_aditi_compilation.
> >  
> > +:- import_module pa_alias_as.
> 
> This import_module should be grouped with all the other import_modules.

ok

> > +	% This type is used to list all unprocessed alias-pragma's. These
> > +	% pragma's are read during the make_hlds-stage, but they may not 
> > +	% be processed until the actual alias-pass is started. The reason
> > +	% for this is that alias-information is provided for predicates that
> > +	% may not yet be within the predicate table at the moment where 
> > +	% make_hlds wishes to process this information. 
> > +	% The types in unproc_alias_pragma match the types in the 
> > +	% pa_alias_info-pragma (see prog_data.m).
> 
> I would suggest rewording this simply as follows:
> 
> 	The unprocessed pragma alias information.  This information is not
> 	processed until just prior to the alias pass in the compiler so that
> 	the entries correspond to the transformed versions of predicates
> 	(ie type-infos and so on).

I prefer to keep the last two lines relating this type to the pragma, so
that it is clear that these types have to remain in sync. 
The result is: 

	% The unprocessed pragma alias information.  This information is
	% not processed until just prior to the alias pass in the
	% compiler so that the entries correspond to the transformed
	% versions of predicates (ie type-infos and so on).
        % The types in unproc_alias_pragma match the types in the 
        % pa_alias_info-pragma (see prog_data.m).

> > +:- type unproc_alias_pragmas == list(unproc_alias_pragma).
> > +:- type unproc_alias_pragma 
> > +	--->	unproc_alias_pragma(pred_or_func, sym_name, 
> > +			list(mode), list(prog_var), list((type)), 
> > +			alias_as).
> > +
> > +:- import_module sr_data.
> 
> Again place this import_module with all the others.

ok

> > +	% This type is used to list all unprocessed reuse-pragma's. These
> > +	% pragma's are read during the make_hlds-stage, but they may not 
> > +	% be processed until the actual reuse-pass is started. The reason
> > +	% for this is that reuse-information is provided for predicates that
> > +	% may not yet be within the predicate table at the moment where 
> > +	% make_hlds wishes to process this information. 
> > +	% The types in unproc_reuse_pragma match the types in the 
> > +	% sr_reuse_info-pragma (see prog_data.m).
> 
> Reword similar to above.

same reply. 

> > +	% Search the table for the (unique) procedure matching this
> > +	% pred_or_func category, sym_name, arity, and declared modes. 
> > +	% If there was no mode declaration, then use the inferred argmodes.
> > +	% (inspired from make_hlds::get_procedure_matching_declmodes/4)
> 
> The inspired comment would be better placed as a comment on the code below,
> not on the interface declaration.

ok

> > +:- import_module mode_util.
> 
> Again put the import with all the other imports.

ok 

> > +:- pred mode_list_matches(list(mode), list(mode), module_info).
> > +:- mode mode_list_matches(in, in, in) is semidet.
> > +
> > +mode_list_matches([], [], _).
> > +mode_list_matches([Mode1 | Modes1], [Mode2 | Modes2], ModuleInfo) :-
> > +	% Use mode_get_insts_semidet instead of mode_get_insts to avoid
> > +	% aborting if there are undefined modes.
> > +	mode_get_insts_semidet(ModuleInfo, Mode1, Inst1, Inst2),
> > +	mode_get_insts_semidet(ModuleInfo, Mode2, Inst1, Inst2),
> > +	mode_list_matches(Modes1, Modes2, ModuleInfo).
> > +
> 
> It would be better to move this mode_list_matches predicate into
> mode_util.m and delete it from make_hlds.m.

done it, deleted it. 

> > +process_unproc_alias_pragma(UnprocAliasPragma, Module0, Module) --> 
> > +	{ UnprocAliasPragma = unproc_alias_pragma(PredOrFunc, SymName, 
> > +		Modes, HeadVars, Types, Alias0) },
> > +
> > +	globals__io_lookup_bool_option(very_verbose, VeryVerbose),
> > +
> > +	{ module_info_get_predicate_table(Module0, Preds) }, 
> > +	{ list__length(Modes, Arity) },
> > +	(
> > +		{ predicate_table_search_pf_sym_arity_declmodes(Module0, 
> > +			Preds, PredOrFunc, SymName, Arity, Modes, 
> > +			PredId, ProcId) }
> > +	->
> > +		{ module_info_preds(Module0, PredTable0) },
> > +		{ map__lookup(PredTable0, PredId, PredInfo0) },
> > +		{ pred_info_procedures(PredInfo0, ProcTable0) },
> > +		{ map__lookup(ProcTable0, ProcId, ProcInfo0) },
> > +		write_proc_progress_message("(Alias) Looking into ", 
> > +			PredId, ProcId, Module0),
> > +
> > +			% rename the headvars: 
> > +		maybe_write_string(VeryVerbose, "Renaming HeadVars..."),
> > +		{ proc_info_headvars(ProcInfo0, ProcHeadVars) }, 
> > +		{ list__map(term__coerce_var, HeadVars, CHVars) },
> > +		{ map__from_corresponding_lists(CHVars, ProcHeadVars,
> > +			MapHeadVars) }, 
> > +		{ pa_alias_as__rename(MapHeadVars, Alias0, Alias1) },
> > +		maybe_write_string(VeryVerbose, "done.\n"),
> > +	
> > +		% rename the types: 
> > +		maybe_write_string(VeryVerbose, "Renaming Types..."),
> > +		{ pred_info_arg_types(PredInfo0, ArgTypes) },
> > +		{ pa_alias_as__rename_types(Types, ArgTypes, 
> > +			Alias1, Alias) },
> > +		maybe_write_string(VeryVerbose, "done.\n"),
> > +
> > +		% set the proc_info right
> > +		{ proc_info_set_possible_aliases(ProcInfo0, 
> > +			Alias, ProcInfo) },
> > +		{ map__det_update(ProcTable0, ProcId, ProcInfo,
> > +				ProcTable) },
> > +		{ pred_info_set_procedures(PredInfo0, ProcTable,
> > +				PredInfo) },
> > +		{ map__det_update(PredTable0, PredId, PredInfo,
> > +				PredTable) },
> > +		{ module_info_set_preds(Module0, PredTable, Module) }
> > +	;
> > +		% io__write_string("Warning: no entry found for "),
> > +		% hlds_out__write_simple_call_id(PredOrFunc, SymName/Arity),
> > +		% io__write_string(" with modes: "), 
> > +		% { varset__init(EmptyVarset) },
> > +		% io__write_list(Modes, ", ", write_mode(EmptyVarset)),
> > +		% io__write_string(" (alias_info).\n"),
> 
> You definitely need to report an error here.
> 
> Use
> 
> io__set_exit_status(1),
> { module_info_incr_errors(Module0, Module) },
> 
> This should ensure that the compiler finishes with an abort.

I haven't changed this for the moment.. 

Idem for the reuse_info. 

Nancy
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list