mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 19:03:45 +00:00
library/term.m:
library/term_context.m:
As above.
Rename the term.context type as term_context.term_context, with
term.context now being defined as an equivalence type.
Replace the context_init function and predicate and the dummy_context_init
function with just one function: dummy_context. This name includes
the important part (the fact that it return a *dummy* context) and deletes
the nonimportant part (dummy contexts are just about never updated,
so the function does not really "initialize" them).
Reduce function/predicate pairs that do the same thing to just a function.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of standard library modules.
NEWS:
Mention the new module, and the obsoleting of the moved predicates
and functions in term.m.
compiler/*.m:
library/*.m:
Conform to the changes above.
70 lines
2.2 KiB
Mathematica
70 lines
2.2 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1993-2000,2003-2009,2011-2012 The University of Melbourne.
|
|
% Copyright (C) 2014-2022 The Mercury team.
|
|
% This file is distributed under the terms specified in COPYING.LIB.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% File: term_context.m.
|
|
% Main author: fjh.
|
|
% Stability: medium.
|
|
%
|
|
% This file contains a type, term_context, that describes where each part
|
|
% of a term occurs in a file, and the operations associated with it.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module term_context.
|
|
:- interface.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- type term_context
|
|
---> context(
|
|
context_filename :: string,
|
|
context_linenumber :: int
|
|
).
|
|
|
|
% Initialize the term context when reading in (or otherwise constructing)
|
|
% a term.
|
|
%
|
|
:- func context_init(string, int) = term_context.
|
|
|
|
% Return a dummy term context.
|
|
%
|
|
:- func dummy_context = term_context.
|
|
|
|
% Is the given context a dummy context, as returned by dummy_context_init?
|
|
%
|
|
:- pred is_dummy_context(term_context::in) is semidet.
|
|
|
|
% Given a term context, return the source file.
|
|
%
|
|
:- func context_file(term_context) = string.
|
|
|
|
% Given a term context, return the source line number.
|
|
%
|
|
:- func context_line(term_context) = int.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
context_init(File, LineNumber) = context(File, LineNumber).
|
|
|
|
dummy_context = context("", 0).
|
|
|
|
is_dummy_context(Context) :-
|
|
Context = dummy_context.
|
|
|
|
context_file(context(FileName, _)) = FileName.
|
|
|
|
context_line(context(_, LineNumber)) = LineNumber.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- end_module term_context.
|
|
%---------------------------------------------------------------------------%
|