mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 07:45:09 +00:00
Estimated hours taken: 3 Branches: main Get the tests in hard_coded to compile in the grade il. The tests may still fail because of other reasons. tests/hard_coded/constraint_order.m: tests/hard_coded/copy_pred.m: tests/hard_coded/copy_pred_2.m: tests/hard_coded/dupcall_impurity.m: tests/hard_coded/export_test.m: tests/hard_coded/foreign_import_module.m: tests/hard_coded/foreign_type3.m: tests/hard_coded/ho_solns.m: tests/hard_coded/ho_univ_to_type.m: tests/hard_coded/impure_foreign.m: tests/hard_coded/impure_prune.m: tests/hard_coded/intermod_c_code2.m: tests/hard_coded/intermod_multimode.m: tests/hard_coded/multimode.m: tests/hard_coded/no_inline.m: tests/hard_coded/rnd.m: Provide C# implementation of C code. tests/hard_coded/existential_types_test.m: tests/hard_coded/frameopt_pragma_redirect.m: tests/hard_coded/mode_choice.m: tests/hard_coded/pragma_c_code.m: tests/hard_coded/pragma_inline.m: tests/hard_coded/target_mlobjs.m: tests/hard_coded/unused_float_box_test.m: Provide Mercury implementation of C code. tests/hard_coded/redoip_clobber.m: Provide MC++ implementation of C code.
50 lines
1.2 KiB
Mathematica
50 lines
1.2 KiB
Mathematica
% This is a test case to test that duplicate call elimination
|
|
% takes purity into account.
|
|
|
|
:- module dupcall_impurity.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- impure pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module string.
|
|
|
|
:- impure pred test1(io__state::di, io__state::uo) is det.
|
|
:- impure pred test2(io__state::di, io__state::uo) is det.
|
|
|
|
main -->
|
|
impure test1,
|
|
impure test2.
|
|
|
|
test1 -->
|
|
{ impure next_x(X0) },
|
|
{ impure next_x(X1) },
|
|
print(X0), nl,
|
|
print(X1), nl.
|
|
|
|
test2 -->
|
|
{ semipure get_x(X0) },
|
|
{ impure incr_x },
|
|
{ semipure get_x(X1) },
|
|
print(X0), nl,
|
|
print(X1), nl.
|
|
|
|
:- semipure pred get_x(int::out) is det.
|
|
:- impure pred next_x(int::out) is det.
|
|
:- impure pred incr_x is det.
|
|
|
|
:- pragma c_header_code("extern int my_global;").
|
|
:- pragma c_code("int my_global;").
|
|
|
|
:- pragma c_code(get_x(X::out), "X = my_global;").
|
|
:- pragma c_code(next_x(X::out), "X = my_global++;").
|
|
:- pragma c_code(incr_x, "my_global++;").
|
|
|
|
:- pragma foreign_code("C#", "static int my_global;").
|
|
|
|
:- pragma foreign_proc("C#", get_x(X::out),
|
|
[promise_semipure], "X = my_global;").
|
|
:- pragma foreign_proc("C#", next_x(X::out), [], "X = my_global++;").
|
|
:- pragma foreign_proc("C#", incr_x, [], "my_global++;").
|