Files
mercury/library/univ.m
Julien Fischer 3dd02876a5 Delete the MLDS->IL backend.
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_managed.m:
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/ilds.m:
    Delete the modules making up the MLDS->IL code generator.

compiler/globals.m:
compiler/prog_data.m:
    Delete IL as a target and foreign language.

compiler/prog_io_pragma.m:
    Delete the max_stack_size/1 foreign proc attribute.  This was only
    ever required by the IL backend.

compiler/options.m
    Delete options used for the IL backend.

compiler/write_deps_file.m:
    Don't generate mmake targets for .il files etc.

compiler/*.m:
    Conform to the above changes.

compiler/notes/compiler_design.html
compiler/notes/work_in_progress.html
    Conform to the above changes.

library/*.m:
    Delete IL foreign_proc and foreign_export pragmas.

README.DotNet:
    Delete this file.

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
    Conform the above changes.

configure.ac:
    Don't check that IL is a supported foreign language when performing the
    up-to-date check.

    Delete the '--enable-dotnet-grades' option.

scripts/Mmake.vars.in:
    Delete variables used for the IL backend (and in on case by the Aditi
    backend).

scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
scripts/Mmake.rules:
scripts/canonical_grade.sh-subr:
tools/bootcheck:
    Delete stuff related to the 'il' and 'ilc' grades.

doc/reference_manual.texi:
     Delete the documentation of the 'max_stack_size' option.

doc/user_guide.texi:
     Delete stuff related to the IL backend.

tests/hard_coded/csharp_test.{m,exp}:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/valid/csharp_hello.m:
	Delete these tests: they are no longer relevant.

tests/hard_coded/equality_pred_which_requires_boxing.m:
tests/hard_coded/foreign_import_module.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/foreign_type.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/intermod_foreign_type2.m:
tests/hard_coded/lp.m:
tests/hard_coded/user_compare.m:
tests/invalid/foreign_type_2.m:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/invalid/foreign_type_visibility.m:
tests/invalid/illtyped_compare.{m,err_exp}:
tests/submodules/external_unification_pred.m
tests/valid/big_foreign_type.m
tests/valid/solver_type_bug.m
tests/valid_seq/foreign_type_spec.m
tests/valid_seq/intermod_impure2.m
    Delete IL foreign_procs where necessary.

tests/hard_coded/Mmakefile
tests/invalid/Mercury.options
tests/invalid/Mmakefile
tests/submodules/Mmakefile
tests/valid/Mercury.options
tests/valid/Mmake.valid.common
tests/valid/Mmakefile
tests/valid_seq/Mmakefile
tests/valid_seq/Mercury.options
    Conform to the above changes.
2015-09-21 11:34:46 +10:00

146 lines
4.7 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
%---------------------------------------------------------------------------%
% Copyright (C) 1994-2010 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: univ.m.
% Main author: fjh.
% Stability: medium.
%
% The universal type `univ'
%
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- module univ.
:- interface.
:- import_module type_desc.
%---------------------------------------------------------------------------%
% An object of type `univ' can hold the type and value of an object of any
% other type.
%
:- type univ.
% type_to_univ(Object, Univ).
%
% True iff the type stored in `Univ' is the same as the type of `Object',
% and the value stored in `Univ' is equal to the value of `Object'.
%
% Operational, the forwards mode converts an object to type `univ',
% while the reverse mode converts the value stored in `Univ'
% to the type of `Object', but fails if the type stored in `Univ'
% does not match the type of `Object'.
%
:- pred type_to_univ(T, univ).
:- mode type_to_univ(di, uo) is det.
:- mode type_to_univ(in, out) is det.
:- mode type_to_univ(out, in) is semidet.
% univ_to_type(Univ, Object) :- type_to_univ(Object, Univ).
%
:- pred univ_to_type(univ, T).
:- mode univ_to_type(in, out) is semidet.
:- mode univ_to_type(out, in) is det.
:- mode univ_to_type(uo, di) is det.
% The function univ/1 provides the same functionality as type_to_univ/2.
% univ(Object) = Univ :- type_to_univ(Object, Univ).
%
:- func univ(T) = univ.
:- mode univ(in) = out is det.
:- mode univ(di) = uo is det.
:- mode univ(out) = in is semidet.
% det_univ_to_type(Univ, Object).
%
% The same as the forwards mode of univ_to_type, but aborts
% if univ_to_type fails.
%
:- pred det_univ_to_type(univ::in, T::out) is det.
% univ_type(Univ).
%
% Returns the type_desc for the type stored in `Univ'.
%
:- func univ_type(univ) = type_desc.
% univ_value(Univ).
%
% Returns the value of the object stored in Univ.
%
:- some [T] func univ_value(univ) = T.
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module require.
:- import_module list.
:- import_module string.
%---------------------------------------------------------------------------%
% We call the constructor for univs `univ_cons' to avoid ambiguity
% with the univ/1 function which returns a univ.
%
:- type univ
---> some [T] univ_cons(T).
univ_to_type(Univ, X) :- type_to_univ(X, Univ).
univ(X) = Univ :- type_to_univ(X, Univ).
det_univ_to_type(Univ, X) :-
( if type_to_univ(X0, Univ) then
X = X0
else
UnivTypeName = type_name(univ_type(Univ)),
ObjectTypeName = type_name(type_of(X)),
string.append_list(["det_univ_to_type: conversion failed\n",
"\tUniv Type: ", UnivTypeName, "\n",
"\tObject Type: ", ObjectTypeName], ErrorString),
error(ErrorString)
).
univ_value(univ_cons(X)) = X.
:- pragma promise_equivalent_clauses(type_to_univ/2).
type_to_univ(T::di, Univ::uo) :-
Univ0 = 'new univ_cons'(T),
unsafe_promise_unique(Univ0, Univ).
type_to_univ(T::in, Univ::out) :-
Univ = 'new univ_cons'(T).
type_to_univ(T::out, Univ::in) :-
Univ = univ_cons(T0),
private_builtin.typed_unify(T0, T).
univ_type(Univ) = type_of(univ_value(Univ)).
:- pred construct_univ(T::in, univ::out) is det.
:- pragma foreign_export("C", construct_univ(in, out), "ML_construct_univ").
:- pragma foreign_export("C#", construct_univ(in, out), "ML_construct_univ").
:- pragma foreign_export("Java", construct_univ(in, out), "ML_construct_univ").
construct_univ(X, Univ) :-
Univ = univ(X).
:- some [T] pred unravel_univ(univ::in, T::out) is det.
:- pragma foreign_export("C", unravel_univ(in, out), "ML_unravel_univ").
:- pragma foreign_export("C#", unravel_univ(in, out), "ML_unravel_univ").
:- pragma foreign_export("Java", unravel_univ(in, out), "ML_unravel_univ").
unravel_univ(Univ, X) :-
univ_value(Univ) = X.
%---------------------------------------------------------------------------%
:- end_module univ.
%---------------------------------------------------------------------------%