[m-rev.] diff: IL back-end: some fixes for --high-level-datas

Tyson Dowd trd at cs.mu.OZ.AU
Tue Aug 14 01:31:00 AEST 2001


On 13-Aug-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 2
> Branches: main
> 
> Fix a couple of bugs in the IL back-end that caused it to generate incorrect 
> refences to constructor names when --high-level-data was enabled.
> One was that it was using the base class type rather than the
> derived type for the appropriate constructor.
> The other was that it was using "." rather than "/" as the class qualifier
> when referencing nested classes.
> (This change is only a partial fix for the latter problem.)
> 
> compiler/ilds.m:
> 	Change the structured_type so that nested classes are stored
> 	a separate field from the namespace-qualified top-level class.
> 
> 	Rename "append_class_name" as "append_toplevel_class_name",
> 	and add a new routine "append_nested_class_name".
> 	
> compiler/ilasm.m:
> 	Output "/" rather than "." as the class qualifier for nested classes.
> 
> compiler/mlds_to_csharp.m:
> compiler/mlds_to_mcpp.m:
> 	Minor changes to handle the new definition of structured_type.
> 
> compiler/mlds_to_il.m:
> 	Handle the new definition of structured_type.
> 	Use the MaybeCtorName field of new_object instructions
> 	to determine the type to allocate.
> 
> Workspace: /home/venus/fjh/ws-venus4/mercury
> Index: compiler/ilasm.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
> retrieving revision 1.18
> diff -u -d -r1.18 ilasm.m
> --- compiler/ilasm.m	9 Aug 2001 16:30:24 -0000	1.18
> +++ compiler/ilasm.m	13 Aug 2001 01:37:31 -0000
> @@ -1420,17 +1420,14 @@
>  	ilasm_info::in, ilasm_info::out, io__state::di, io__state::uo) is det.
>  output_class_member_name(class_member_name(StructuredName, MemberName),
>  		Info0, Info) -->
> -	( { StructuredName = structured_name(_, [_ | _]) } ->
> -		output_structured_name(StructuredName, Info0, Info),
> -		io__write_string("::")
> -	;
> -		{ Info = Info0 }
> -	),
> +	output_structured_name(StructuredName, Info0, Info),
> +	io__write_string("::"),
>  	output_member_name(MemberName).
>  
>  :- pred output_structured_name(structured_name::in, ilasm_info::in,
>  	ilasm_info::out, io__state::di, io__state::uo) is det.
> -output_structured_name(structured_name(Asm, DottedName), Info, Info) -->
> +output_structured_name(structured_name(Asm, DottedName, NestedClasses),
> +		Info, Info) -->
>  	( { Asm = assembly(Assembly) },
>  		maybe_output_quoted_assembly_name(Assembly, Info)
>  	; { Asm = module(Module, Assembly) },
> @@ -1444,7 +1441,9 @@
>  			maybe_output_quoted_assembly_name(Assembly, Info)
>  		)
>  	),
> -	output_dotted_name(DottedName).
> +	output_dotted_name(DottedName),
> +	output_nested_class_quals(NestedClasses).
> +
>  
>  :- pred maybe_output_quoted_assembly_name(ilds__id::in, ilasm_info::in,
>  		io__state::di, io__state::uo) is det.
> @@ -1461,6 +1460,14 @@
>  	io__state::di, io__state::uo) is det.
>  output_dotted_name(Name) -->
>  	io__write_list(Name, ".", output_id).
> +
> +:- pred output_nested_class_quals(nested_class_name::in,
> +	io__state::di, io__state::uo) is det.
> +output_nested_class_quals(Name) -->
> +	list__foldl(
> +		(pred(Id::in, di, uo) is det -->
> +			io__write_char('/'), output_id(Id)),
> +		Name).
>  
>  :- pred output_id(ilds__id::in, io__state::di, io__state::uo) is det.
>  output_id(Id) -->
> Index: compiler/ilds.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ilds.m,v
> retrieving revision 1.9
> diff -u -d -r1.9 ilds.m
> --- compiler/ilds.m	9 Aug 2001 16:30:24 -0000	1.9
> +++ compiler/ilds.m	13 Aug 2001 01:37:31 -0000

> @@ -344,31 +366,39 @@
>  
>  	% Get the non-namespace portion of a class name.
>  
> -:- func get_class_suffix(ilds__class_name) = ilds__id.
> +:- func get_class_suffix(ilds__class_name) = list(ilds__id).
>  
> -	% Add an extra identifier to the end of an IL class name, e.g.
> +	% Add an extra identifier to the end of an IL namespace name, e.g.
>  	% append Foo to [mercury]mercury.runtime to make
>  	% [mercury]mercury.runtime.Foo
>  
> -:- func append_class_name(ilds__class_name, ilds__namespace_qual_name) =
> +:- func append_toplevel_class_name(ilds__namespace_name, ilds__id) =
> +	ilds__class_name.
> +
> +	% Add an extra identifier to the end of an IL class name, e.g.
> +	% append Bar to [mercury]mercury.runtime.Foo to make
> +	% [mercury]mercury.runtime.Foo.Bar
> +
> +:- func append_nested_class_name(ilds__class_name, ilds__nested_class_name) =
>  	ilds__class_name.

Shouldn't that comment read:
	% Add an extra identifier to the end of an IL class name, e.g.
	% append Bar to [mercury]mercury.runtime.Foo to make
	% [mercury]mercury.runtime.Foo/Bar


Otherwise this change looks fine.

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