[m-rev.] For review: State Variables

Simon Taylor stayl at cs.mu.OZ.AU
Fri Jun 7 16:39:05 AEST 2002


On 07-Jun-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Index: make_hlds.m
> ===================================================================
> @@ -3787,6 +3803,29 @@
>  		PredInfo1 = PredInfo0
>  	},
>  	(
> +		{ IllegalSVarResult = yes(StateVar) }
> +	->
> +		report_illegal_func_svar_result(Context, ClauseVarSet,
> +			StateVar),
> +		{ ModuleInfo = ModuleInfo1 },
> +		{ Info       = Info0 }
> +	;
> +		{ pred_info_pragma_goal_type(PredInfo1) },
> +		{ get_mode_annotations(Args, _, empty, ModeAnnotations) },
> +		{ ModeAnnotations = empty ; ModeAnnotations = none }
> +	->
> +			% If we have a pragma foreign_proc for this procedure
> +			% already, and we are trying to add a non-mode specific
> +			% Mercury clause 
> +		{ module_info_incr_errors(ModuleInfo1, ModuleInfo) },
> +		prog_out__write_context(Context),
> +		io__write_string("Error: non mode-specific clause for "),
> +		hlds_out__write_simple_call_id(PredOrFunc, PredName/Arity),
> +		io__write_string("\n"),
> +		prog_out__write_context(Context),
> +		io__write_string("  with `:- pragma foreign_proc' declaration preceding.\n"),
> +		{ Info = Info0 }
> +	;

This looks wrong.

> @@ -4212,9 +4263,31 @@
>  	% tagged as opt_imported only if/when we see a clause (including
>  	% a `pragma import' clause) for them
>  	{ Status = opt_imported ->
> -		pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1)
> +		pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1a)
>  	;
> -		PredInfo1 = PredInfo0
> +		PredInfo1a = PredInfo0
> +	},
> +	{
> +		% If this procedure was previously defined as clauses only
> +		% then we need to turn all the non mode-specific clauses
> +		% into mode-specific clauses.
> +		pred_info_clause_goal_type(PredInfo1a)
> +	->
> +		pred_info_clauses_info(PredInfo1a, CInfo0),
> +		clauses_info_clauses(CInfo0, ClauseList0),
> +		ClauseList = list__map(
> +			(func(C) =
> +				( C = clause([], Goal, mercury, Ctxt) ->
> +					clause(AllProcIds, Goal, mercury, Ctxt)
> +				;
> +					C
> +				) :-
> +				pred_info_all_procids(PredInfo1a, AllProcIds)
> +			), ClauseList0),
> +		clauses_info_set_clauses(CInfo0, ClauseList, CInfo),
> +		pred_info_set_clauses_info(PredInfo1a, CInfo, PredInfo1)
> +	;
> +		PredInfo1 = PredInfo1a
>  	},
>  	( 
>  		{ pred_info_is_imported(PredInfo1) }
> @@ -4366,31 +4439,9 @@
>  	% tagged as opt_imported only if/when we see a clause (including
>  	% a `pragma c_code' clause) for them
>  	{ Status = opt_imported ->
> -		pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1a)
> -	;
> -		PredInfo1a = PredInfo0
> -	},
> -	{
> -		% If this procedure was previously defined as clauses only
> -		% then we need to turn all the non mode-specific clauses
> -		% into mode-specific clauses.
> -		pred_info_clause_goal_type(PredInfo1a)
> -	->
> -		pred_info_clauses_info(PredInfo1a, CInfo0),
> -		clauses_info_clauses(CInfo0, ClauseList0),
> -		ClauseList = list__map(
> -			(func(C) =
> -				( C = clause([], Goal, mercury, Ctxt) ->
> -					clause(AllProcIds, Goal, mercury, Ctxt)
> -				;
> -					C
> -				) :-
> -				pred_info_all_procids(PredInfo1a, AllProcIds)
> -			), ClauseList0),
> -		clauses_info_set_clauses(CInfo0, ClauseList, CInfo),
> -		pred_info_set_clauses_info(PredInfo1a, CInfo, PredInfo1)
> +		pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1)
>  	;
> -		PredInfo1 = PredInfo1a
> +		PredInfo1 = PredInfo0
>  	},
>  	( 
>  		{ pred_info_is_imported(PredInfo1) }

This too.

> @@ -4404,6 +4455,23 @@
>  		io__write_string(".\n"),
>  		{ Info = Info0 }
>  	;	
> +		{ pred_info_clause_goal_type(PredInfo1) },
> +		{ pred_info_clauses_info(PredInfo1, CInfo) },
> +		{ clauses_info_clauses(CInfo, ClauseList) },
> +		{ list__member(clause([], _, mercury, _), ClauseList) }
> +
> +	->
> +		{ module_info_incr_errors(ModuleInfo1, ModuleInfo) },
> +		prog_out__write_context(Context),
> +		io__write_string("Error: `:- pragma foreign_proc' (or `pragma c_code')\n"),
> +		prog_out__write_context(Context),
> +		io__write_string("declaration for "),
> +		hlds_out__write_simple_call_id(PredOrFunc, PredName/Arity),
> +		io__write_string("\n"),
> +		prog_out__write_context(Context),
> +		io__write_string("  with preceding non-mode specific clauses.\n"),
> +		{ Info = Info0 }
> +	;
>  			% Don't add clauses for foreign languages other
>  			% than the ones we can generate code for.
>  		{ not list__member(PragmaForeignLanguage, BackendForeignLangs) }

This too.

You need to go over this more thoroughly looking for places
were the merge hasn't worked.

Simon.
--------------------------------------------------------------------------
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