Files
mercury/browser/io_action.m
Julien Fischer 459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00

138 lines
4.1 KiB
Mathematica

%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2002, 2004-2006 The University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
%-----------------------------------------------------------------------------%
% File: io_action.m.
% Author: zs.
% This module defines the representation of I/O actions used by the
% declarative debugger.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- module mdb.io_action.
:- interface.
:- import_module mdb.browser_term.
:- import_module mdbcomp.prim_data.
:- import_module list.
:- import_module io.
:- import_module univ.
%-----------------------------------------------------------------------------%
:- type io_action
---> io_action(
io_action_proc_name :: string,
io_action_pf :: pred_or_func,
io_action_args :: list(univ)
).
:- type maybe_tabled_io_action
---> tabled(io_action)
; untabled.
:- type io_seq_num == int.
:- type io_action_range
---> io_action_range(
from_io_action :: io_seq_num,
to_io_action :: io_seq_num
).
:- func io_action_to_browser_term(io_action) = browser_term.
:- pred get_maybe_io_action(io_seq_num::in, maybe_tabled_io_action::out,
io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module mdb.declarative_debugger.
:- import_module bool.
:- import_module exception.
:- import_module int.
:- import_module maybe.
:- import_module require.
:- import_module svmap.
%-----------------------------------------------------------------------------%
get_maybe_io_action(IoActionNum, MaybeTabledIoAction, !IO) :-
pickup_io_action(IoActionNum, MaybeIoAction, !IO),
(
MaybeIoAction = yes(IoAction),
MaybeTabledIoAction = tabled(IoAction)
;
MaybeIoAction = no,
MaybeTabledIoAction = untabled
).
io_action_to_browser_term(IoAction) = Term :-
IoAction = io_action(ProcName, PredFunc, Args),
(
PredFunc = predicate,
IsFunc = no
;
PredFunc = function,
IsFunc = yes
),
Term = synthetic_term_to_browser_term(ProcName, Args, IsFunc).
:- pred pickup_io_action(int::in, maybe(io_action)::out,
io.state::di, io.state::uo) is det.
:- pragma foreign_proc("C",
pickup_io_action(SeqNum::in, MaybeIOAction::out, S0::di, S::uo),
[thread_safe, promise_pure, tabled_for_io, may_call_mercury],
"{
const char *problem;
const char *proc_name;
MR_Bool is_func;
MR_Word args;
MR_bool io_action_tabled;
MR_String ProcName;
MR_save_transient_hp();
io_action_tabled = MR_trace_get_action(SeqNum, &proc_name, &is_func,
&args);
MR_restore_transient_hp();
/* cast away const */
ProcName = (MR_String) (MR_Integer) proc_name;
if (io_action_tabled) {
MaybeIOAction = MR_IO_ACTION_make_yes_io_action(ProcName, is_func,
args);
} else {
MaybeIOAction = MR_IO_ACTION_make_no_io_action();
}
S = S0;
}").
:- func make_no_io_action = maybe(io_action).
:- pragma export(make_no_io_action = out, "MR_IO_ACTION_make_no_io_action").
make_no_io_action = no.
:- func make_yes_io_action(string, bool, list(univ)) = maybe(io_action).
:- pragma export(make_yes_io_action(in, in, in) = out,
"MR_IO_ACTION_make_yes_io_action").
make_yes_io_action(ProcName, yes, Args) =
yes(io_action(ProcName, function, Args)).
make_yes_io_action(ProcName, no, Args) =
yes(io_action(ProcName, predicate, Args)).
pickup_io_action(_, _, _, _) :-
private_builtin.sorry("pickup_io_action").