Files
mercury/compiler/static_term.m
Fergus Henderson 7597790760 Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.

compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
	New files.  One module for each of the major components of the
	Mercury compiler.  These modules contain (as separate sub-modules)
	all the other modules in the Mercury compiler, except gcc.m and
	mlds_to_gcc.m.

Mmakefile:
compiler/Mmakefile:
	Handle the fact that the top-level module is now `top_level',
	not `mercury_compile' (since `mercury_compile' is a sub-module
	of `top_level').

compiler/Mmakefile:
	Update settings of *FLAGS-<modulename> to use the appropriate
	nested module names.

compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
	Convert the `recompilation_*' modules into sub-modules of the
	`recompilation' module.

compiler/*.m:
compiler/*.pp:
	Module-qualify the module names in `:- module', `:- import_module',
	and `:- use_module' declarations.

compiler/base_type_info.m:
compiler/base_type_layout.m:
	Deleted these unused empty modules.

compiler/prog_data.m:
compiler/globals.m:
	Move the `foreign_language' type from prog_data to globals.

compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
	Import `globals', for `foreign_language'.

Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
	Rename the %.check.c targets as %.check_hdr.c,
	to avoid conflicts with compiler/recompilation.check.c.
2002-03-20 12:37:56 +00:00

95 lines
3.1 KiB
Mathematica

%---------------------------------------------------------------------------%
% Copyright (C) 2000,2002 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%---------------------------------------------------------------------------%
%
% File: static_term.m.
% Author: zs.
%
% This module handles the conversion of Mercury terms in the compiler
% into rvals we can give to llds_out.m in order to make those terms available
% at runtime in the program being compiled.
%
%---------------------------------------------------------------------------%
:- module ll_backend__static_term.
:- interface.
:- import_module ll_backend__llds.
:- import_module counter, std_util.
:- pred static_term__term_to_rval(univ::in, maybe(rval)::out,
counter::in, counter::out) is det.
%---------------------------------------------------------------------------%
:- implementation.
:- import_module backend_libs__builtin_ops.
:- import_module deconstruct, list, require.
static_term__term_to_rval(Univ, Rval, CellCounter0, CellCounter) :-
( deconstruct__get_functor_info(Univ, FunctorInfo) ->
static_term__functor_info_to_rval(FunctorInfo, Rval,
CellCounter0, CellCounter)
;
error("static_term__term_to_rval: unexpected kind of term")
).
:- pred static_term__functor_info_to_rval(functor_tag_info::in,
maybe(rval)::out, counter::in, counter::out) is det.
static_term__functor_info_to_rval(FunctorInfo, MaybeRval,
CellCounter0, CellCounter) :-
(
FunctorInfo = functor_integer(Int),
MaybeRval = yes(const(int_const(Int))),
CellCounter = CellCounter0
;
FunctorInfo = functor_float(Float),
MaybeRval = yes(const(float_const(Float))),
CellCounter = CellCounter0
;
FunctorInfo = functor_string(String),
MaybeRval = yes(const(string_const(String))),
CellCounter = CellCounter0
;
FunctorInfo = functor_enum(Enum),
MaybeRval = yes(const(int_const(Enum))),
CellCounter = CellCounter0
;
FunctorInfo = functor_local(Ptag, Sectag),
MaybeRval = yes(mkword(Ptag,
unop(mkbody, const(int_const(Sectag))))),
CellCounter = CellCounter0
;
FunctorInfo = functor_remote(Ptag, Sectag, Args),
MaybeSectagRval = yes(const(int_const(Sectag))),
list__map_foldl(static_term__term_to_rval,
Args, MaybeArgRvals, CellCounter0, CellCounter1),
counter__allocate(CNum, CellCounter1, CellCounter),
Reuse = no,
MaybeRval = yes(create(Ptag, [MaybeSectagRval | MaybeArgRvals],
uniform(no), must_be_static, CNum,
"static_term", Reuse))
;
FunctorInfo = functor_unshared(Ptag, Args),
list__map_foldl(static_term__term_to_rval,
Args, MaybeArgRvals, CellCounter0, CellCounter1),
counter__allocate(CNum, CellCounter1, CellCounter),
Reuse = no,
MaybeRval = yes(create(Ptag, MaybeArgRvals,
uniform(no), must_be_static, CNum,
"static_term", Reuse))
;
FunctorInfo = functor_notag(Univ),
static_term__term_to_rval(Univ, MaybeRval,
CellCounter0, CellCounter)
;
FunctorInfo = functor_equiv(Univ),
static_term__term_to_rval(Univ, MaybeRval,
CellCounter0, CellCounter)
).