[m-rev.] for review: autoconfigure which version of .NET std lib to use

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 1 23:26:41 AEDT 2002


On 01-Mar-2002, Peter Ross <peter.ross at miscrit.be> wrote:
> 
> Configure the version of the .NET std library that we are using instead
> of hard-coding it in the compiler.

That certainly sounds like a good idea...

> Index: aclocal.m4
...
> +# We default to the Beta 2 version of the library
> +mercury_cv_microsoft_dotnet_library_version=1.0.2411.0
> +if test $mercury_cv_microsoft_dotnet = "yes"; then
> +	AC_MSG_CHECKING(determining version of .NET libraries)
> +	cat > conftest.cs << EOF
> +	using System;
> +	using System.Reflection;
> +	public class version {
> +	    public static void Main()
> +	    {
> +		Assembly asm = Assembly.Load("mscorlib");
> +		AssemblyName name = asm.GetName();
> +		Version version = name.Version;
> +		Console.Write(version);
> +		Console.Write("\n");
> +	    }
> +	}
> +EOF
> +	if
> +		echo csc conftest.cs >&AC_FD_CC 2>&1 && \
> +			csc conftest.cs  >&AC_FD_CC 2>&1

You should not hard-code the name "csc" here.
Instead there should be an autoconf variable for that,
like there is for "cl", "gcc", etc.

> +	then
> +		mercury_cv_microsoft_dotnet_library_version=`./conftest`

You should run

		./conftest > conftest.out 2>&1

in the condition of the if-then-else, so that you can
detect if it returns a non-zero exit status.
Only if it returns a zero exit status should you set

		mercury_cv_microsoft_dotnet_library_version=`cat conftest.out`

> +		AC_MSG_RESULT($mercury_cv_microsoft_dotnet_library_version)
> +		rm -f conftest*
> +	else
> +		rm -f conftest*
> +		AC_MSG_ERROR(unable to determine version)
> +		exit 1

This should not exit if the --disable-dotnet-grades option was specified
on the command line.

> Index: compiler/mlds_to_il.m
> +maybe_get_dotnet_library_version(MaybeVersion) -->
> +	io_lookup_string_option(dotnet_library_version, VersionStr),
> +	{ IsSep = (pred(('.')::in) is semidet) },
> +	( 
> +		{ string__words(IsSep, VersionStr) = [Mj, Mn, Bu, Rv] },
> +		{ string__to_int(Mj, Major) },
> +		{ string__to_int(Mn, Minor) },
> +		{ string__to_int(Bu, Build) },
> +		{ string__to_int(Rv, Revision) }
> +	->
> +		{ Version = version(Major, Minor, Build, Revision) },
> +		{ MaybeVersion = yes(Version) }
> +	;
> +		{ MaybeVersion = no },
> +		io__stderr_stream(StdErr),
> +		io__write_string(StdErr, "error: Invalid version string `"),
> +		io__write_string(StdErr, VersionStr),
> +		io__write_string(StdErr, "' passed " ),
> +		io__write_string(StdErr, "to --dotnet-library-version.\n"),
> +		io__set_exit_status(1)

s/error: Invalid/Error: invalid/
  ^      ^       ^      ^

Put --dotnet-library-version inside `single quotes'.

This code should use error_util.m.

> +:- pred generate_il(mlds, assembly_decl,
> +		list(ilasm:decl), set(foreign_language),

s/:/__/

> @@ -3980,11 +4021,11 @@
>  			])
>  		]) | Decls].
>  
> -:- func dotnet_system_assembly_decls = list(assembly_decl).
> +:- func dotnet_system_assembly_decls(assembly_decl) = list(assembly_decl).
>  
> -dotnet_system_assembly_decls
> +dotnet_system_assembly_decls(Version)
>  	= [
> -		version(1, 0, 2411, 0),
> +		Version,
>  		public_key_token([
>  			int8(0xb7), int8(0x7a), int8(0x5c), int8(0x56),
>  			int8(0x19), int8(0x34), int8(0xE0), int8(0x89)

There's no point fixing the hard-coding of the version number
if you don't also fix the hard-coding of the hash
(see the code immediately above this fragment of the diff).

> Index: compiler/options.m
...
> +		"--dotnet-library-version",

That should be
		"--dotnet-library-version <version-number>",

> +		"\tThe version number for the standard libraries distributed",
> +		"\twith the Microsoft .NET SDK."

The documentation should make it clear that this version number is the
version number of the "mscorlib" assembly.

(Otherwise, people using Visual Studio.NET 1.0 will first try "1.0" and
will have no idea what to try next).

> Index: doc/user_guide.texi
...
> + at sp 1
> + at item --dotnet-library-version @var{extension}

s/extension/version-number/

> + at findex --dotnet-library-version
> +The version number for the standard libraries distributed with the
> +Microsoft .NET SDK.

See above.

> +++ scripts/mmc.in	1 Mar 2002 10:30:21 -0000
> @@ -34,11 +34,15 @@
>  NUM_REAL_R_TEMPS=@NUM_REAL_R_TEMPS@
>  HAVE_DELAY_SLOT=@HAVE_DELAY_SLOT@
>  HAVE_BOXED_FLOATS=@HAVE_BOXED_FLOATS@
> +DOTNET_LIBRARY_VERSION=@MS_DOTNET_LIBRARY_VERSION@

You should be consistent about whether or not it has an MS_ prefix.

Since there is a non-MS implementation, it should not have an MS_ prefix.


Please post another diff when you've addressed these comments.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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