[m-rev.] for review: io.stream_db.m

Peter Wang novalazy at gmail.com
Fri Mar 11 16:14:04 AEDT 2022


On Fri, 11 Mar 2022 14:29:00 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> Carve io.stream_db.m out of io.m.
> 
> library/io.m:
> library/io.stream_db.m:
>     Move the data types describing the stream database, and the
>     predicates and functions managing and accessing it, to the new
>     submodule io.stream_db.m. Move the declarations and definitions
>     of the global variables holding the dabase accordingly.
> 
> library/MODULES_UNDOC:
> library/library.m:
>     List the new module as an undocumented new module.
> 
> browser/browse.m:
> browser/browser_info.m:
> library/stream.string_writer.m:
>     Get stream information from the new module.

> diff --git a/browser/browse.m b/browser/browse.m
> index 73c5f644c..c6fa205df 100644
> --- a/browser/browse.m
> +++ b/browser/browse.m
> @@ -190,6 +190,7 @@
>  :- import_module int.
>  :- import_module io.call_system.
>  :- import_module io.environment.
> +:- import_module io.stream_db.
>  :- import_module io.file.

Sort that.

> diff --git a/compiler/check_typeclass.m b/compiler/check_typeclass.m
> index cc5da35d9..56ae13d61 100644
> --- a/compiler/check_typeclass.m
> +++ b/compiler/check_typeclass.m

Be sure not to include these unrelated changes.

> diff --git a/compiler/make.dependencies.m b/compiler/make.dependencies.m
> index 80142a61c..09cdea2b8 100644
> --- a/compiler/make.dependencies.m
> +++ b/compiler/make.dependencies.m

Also unrelated changes, but you already committed these separately.

> diff --git a/library/io.m b/library/io.m
> index 59da37102..d47279af4 100644
> --- a/library/io.m
> +++ b/library/io.m

> -
> -:- func get_stream_id(stream) = stream_id.
> -
> -:- pragma foreign_proc("C",
> -    get_stream_id(Stream::in) = (Id::out),
> -    [will_not_call_mercury, promise_pure, thread_safe,
> -        does_not_affect_liveness, no_sharing],
> -"
> -#ifndef MR_NATIVE_GC
> -    // Most of the time, we can just use the pointer to the stream
> -    // as a unique identifier.
> -    Id = (MR_Word) Stream;
> -#else
> -    // For accurate GC we embed an ID in the MercuryFile
> -    // and retrieve it here.
> -    Id = (Stream)->id;
> -#endif
> -").
> -
> -:- pragma foreign_proc("C#",
> -    get_stream_id(Stream::in) = (Id::out),
> -    [will_not_call_mercury, promise_pure],
> -"
> -    Id = Stream.id;
> -").
> -
> -:- pragma foreign_proc("Java",
> -    get_stream_id(Stream::in) = (Id::out),
> -    [will_not_call_mercury, promise_pure, may_not_duplicate],
> -"
> -    Id = Stream.id;
> -").
> -

I would leave get_stream_id in io.m along with the definitions of the
stream type, and other stream_id stuff.

> diff --git a/library/io.stream_db.m b/library/io.stream_db.m
> index e69de29bb..c7cd1d7a0 100644
> --- a/library/io.stream_db.m
> +++ b/library/io.stream_db.m
...
> +:- pred lock_stream_db(io::di, io::uo) is det.
> +
> +:- pragma foreign_proc("C",
> +    lock_stream_db(_IO0::di, _IO::uo),
> +    [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io,
> +        no_sharing],
> +"
> +    MR_LOCK(&ML_io_stream_db_lock, ""io.lock_stream_db/2""); ").

Fix the formatting.

The rest looks fine.

Peter


More information about the reviews mailing list