## stamp.api
#
# In the early phases of the compiler we track
# variables, functions, types etc by assigning
# them symbols which we store in symbolmapstacks.
# These 'symbols' correspond directly to user
# identifiers appearing in the source code. See:
#
#
src/lib/compiler/front/basics/map/symbol.pkg#
src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg#
# In the later phases of the compiler, as we simplify
# and abstract away from the sourcecode, we in essence
# switch from *naming* things to *numbering* them.
#
# Instead of looking up symbols in symbolmapstacks
# we look up stamps in stampmapstacks, where 'stamps'
# are in essence small integers sequentially assigned
# starting at zero whose only property of interest is
# uniqueness -- being unequal to all other stamps of
# interest.
#
# See also:
#
src/lib/compiler/front/typer-stuff/modules/stampmapstack.pkg# Compiled by:
#
src/lib/compiler/front/typer-stuff/typecheckdata.sublibapi Stamp {
Stamp;
Fresh_Stamp_Maker = Void -> Stamp;
Key = Stamp; # To match api Key
# For global stamps:
#
Picklehash
=
picklehash::Picklehash; # picklehash is from
src/lib/compiler/front/basics/map/picklehash.pkg same_stamp: (Stamp, Stamp) -> Bool;
compare: (Stamp, Stamp) -> Order; # Instead of "cmp" (Key)
# FRESH stamps:
# Most stamps are 'fresh'. These are small
# integers assigned sequentially starting
# at zero, used to distinguish local variables,
# types etc from each other. (The 'fresh' nomenclature
# stretches all the way back to the original
# "Definition of Standard ML" book.)
#
# STATIC stamps:
# We assign permanent 'static' stamps to various
# special internal things like entries in the
# base_types_and_ops and error entities.
#
# GLOBAL stamps:
# We use 'global' stamps to refer to entities
# (such as vars, fns, types, packages, apis...)
# from other compilation units. We number entities
# sequentially from zero within each compilation unit;
# to achieve global uniqueness we qualify global
# references with a messagedigest-style hash of the
# entire pickled compilation unit in question -- a 'picklehash':
make_fresh_stamp_maker: Void -> Fresh_Stamp_Maker;
make_static_stamp: String -> Stamp; # Make a static stamp. We use these for various permanent things including error entities and things in base_types_and_ops.
make_global_stamp # Make a "global" stamp (i.e., one naming an entity that comes
: # from a different compilation unit). Used only by the unpickler.
{ picklehash: Picklehash,
count: Int
}
->
Stamp;
# Case analysis on the abstract type with
# built-in alpha-conversion (renumbering)
# for fresh stamps.
# Used by the pickler.
#
Converter;
#
new_converter: Void -> Converter;
#
case': Converter
->
Stamp
->
{ fresh: Int -> X, # Already alpha-converted
static: String -> X,
global: { picklehash: Picklehash,
count: Int
}
->
X
}
->
X;
# Quick test for freshness:
#
is_fresh: Stamp -> Bool;
# Debugging:
#
to_string: Stamp -> String;
to_short_string: Stamp -> String;
};
## Copyright 1996 by AT&T Bell Laboratories
## Re-written by Matthias Blume (3/2000)
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.