Files
mercury/tests/hard_coded/word_aligned_pointer.m
Zoltan Somogyi ffb357724f Fix gcc warnings in some test cases.
tests/hard_coded/target_mlobjs_c.c:
    Fix a bad use of printf.

tests/hard_coded/trace_goal_4.m:
tests/hard_coded/word_aligned_pointer.m:
tests/hard_coded/word_aligned_pointer_2.m:
tests/tabling/memo_non.m:
tests/tabling/table_foreign_output.m:
tests/tabling/test_enum.m:
    Don't assume that MR_Integers are ints; print them using
    MR_INTEGER_LENGTH_MODIFIER.
2018-07-30 09:26:12 +10:00

53 lines
1.5 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
% Test foreign type assertion `word_aligned_pointer'.
%---------------------------------------------------------------------------%
:- module word_aligned_pointer.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module list.
:- import_module string.
:- import_module word_aligned_pointer_2.
%---------------------------------------------------------------------------%
main(!IO) :-
% Construct values in different modules.
X = yes(make_foo),
Y = word_aligned_pointer_2.make_bar,
% Deconstruct in this module.
word_aligned_pointer.write_bar(X, !IO),
word_aligned_pointer.write_bar(Y, !IO),
% Deconstruct in the other module.
word_aligned_pointer_2.write_bar(X, !IO),
word_aligned_pointer_2.write_bar(Y, !IO).
%---------------------------------------------------------------------------%
:- pred write_bar(bar::in, io::di, io::uo) is det.
write_bar(Bar, !IO) :-
(
Bar = yes(Foo),
io.format("yes(0x%x)\n", [i(get_foo(Foo))], !IO)
;
Bar = no,
io.write_string("no", !IO)
).
%---------------------------------------------------------------------------%