Commit Graph

8 Commits

Author SHA1 Message Date
Zoltan Somogyi
4281a28f73 Make text_{input,output}_stream standalone types ...
... and make {input,output}_stream synonyms for them, rather than vice versa.

library/io.m:
    As above.

library/bitmap.m:
library/dir.m:
library/io.primitives_read.m:
library/io.stream_db.m:
library/io.text_read.m:
library/mercury_term_lexer.m:
library/stream.string_writer.m:
    Conform to the change above.

tests/hard_coded/stream_string_writer_types.exp:
    Expect the new type_ctor for text streams.
2023-04-24 13:52:10 +10:00
Zoltan Somogyi
79b65ff650 Fully initialize C# MR_MercuryFileStructs at open ...
... by setting up their reader or writer fields then, instead of
testing at each input or output operation whether the relevant field is null,
and filling it in if it is.

library/io.primitives_read.m:
library/io.primitives_write.m:
    Delete the test-and-fill-if-needed code from the read and write operations.

library/io.stream_ops.m:
    Initialize the reader and writer fields of each MR_MercuryFileStruct
    as it is created an file open time.

    Document when each field of the MR_MercuryFileStruct is meaningful.

    Add an XXX about binary vs text files.

    Add an XXX proposing a new arrangement of stream types.
2023-04-24 11:43:50 +10:00
Zoltan Somogyi
6d184346d5 Fix indentation. 2023-04-20 19:49:05 +10:00
Julien Fischer
6e9ce5e02f Address XXXs.
library/io.primitives_read.m:
library/io.primitives_write.m:
library/io.stream_ops.m:
     Delete unnecessary C# foreign_decl pragmas.
2022-04-03 17:36:27 +10:00
Zoltan Somogyi
d7fe06b6d3 Put args representing errors into consistent order. 2022-03-15 01:59:49 +11:00
Zoltan Somogyi
05fd615471 Carve io.stream_ops.m out of io.m.
Also, move foreign code pieces still in io.m that belong in
previously-carved-out modules to those modules.

library/io.m:
library/io.stream_ops.m:
    As above. The new private submodule contains the implementations
    (helper predicates) of the operations that

    - open and close streams,
    - get and set offsets in those streams,
    - get and set line numbers on streams,
    - return the standard streams, and
    - set streams as the current streams.

library/io.m:
    Make some previously private includes public, to allow modules outside
    of io.m to refer to the C# and Java symbols they define. These includes
    are in the second, undocumented interface section of io.m.

    Delete the foreign code moved to io.primitives_{read,write}.m,
    as well as the foreign code moved to io.stream_ops.m.

    Change {get,set}_{line_number,output_line_number}/3, which used
    to be implemented directly using foreign_procs, to implement them
    in terms of their arity-4 counterparts which take an explicit stream
    argument, which now are in io.stream_ops.m. This can yield a slowdown,
    but it should be so small as to be unmeasurable on all non-microbenchmark
    workloads.

    Move related code together.

    Update module qualifications in C# and Java code.

    Delete the second #include of mercury_library_types.h.

    Delete the MR_{initial,final}_io_state macros.

library/MODULES_UNDOC:
library/library.m:
    List the new submodule as undocumented.

library/io.primitives_read.m:
library/io.primitives_write.m:
    Move the C, C# and Java code related to reading and writing values
    of primitive types here from io.m. Put them into one foreign_decl
    and one foreign_code per language.

    Update module qualifications in C# and Java code.

library/benchmarking.m:
library/bitmap.m:
library/io.call_system.m:
    Update module qualifications in C# and Java code.

library/stm_builtin.m:
    Replace uses of the MR_{initial,final}_io_state macros with their bodies.
2022-03-14 15:20:22 +11:00
Zoltan Somogyi
aa6b78c6b9 Delete putback_byte_2.
library/io.primitives_read.m:
    As above.

library/io.m:
    Implement putback_byte using putback_uint8.
2022-03-12 16:49:02 +11:00
Zoltan Somogyi
f3d7165a3a Carve io.primitives_{read,write}.m out of io.m.
library/io.m:
library/io.primitives_read.m:
library/io.primitives_write.m:
    As above. The two new private submodules contain the implementations
    (helper predicates) of the operations that respectively read and write
    values of primitive types.

library/MODULES_UNDOC:
library/library.m:
    List the new submodules as undocumented.
2022-03-12 15:00:41 +11:00