## varhome.api -- Representing where a variable lives and how to access its value at runtime.
# Compiled by:
#
src/lib/compiler/front/typer-stuff/typecheckdata.sublib### "When attempting to understand human civilization,
### it helps to keep in mind that humans are as dumb
### as it is possible for an animal to be, while still
### being able to knock two rocks together to make a third.
###
### "Civilization must necessarily always be founded by such
### an animal, and must inevitably suffer the consequences."
###
### -- Lawrence Tartakower
stipulate
package tmp = highcode_codetemp; # highcode_codetemp is from
src/lib/compiler/back/top/highcode/highcode-codetemp.pkg package ph = picklehash; # picklehash is from
src/lib/compiler/front/basics/map/picklehash.pkg package sy = symbol; # symbol is from
src/lib/compiler/front/basics/map/symbol.pkgherein
api Varhome {
#
Varhome
= HIGHCODE_VARIABLE tmp::Codetemp
| EXTERN ph::Picklehash
| PATH (Varhome, Int)
| NO_VARHOME
;
#
# A HIGHCODE_VARIABLE is just a lambda-bound variable --- a temporary
# used to denote a named value in the current compilation unit.
#
# EXTERN refers to a named value defined externally (in other modules).
#
# PATH is an absolute address from some lambda-bound variable.
# (i.e. we find the value of the lambda-bound variable, and then
# do selects from that). PATH's are kept in reverse order.
# This lets us, for example, select a field in a record
# exported from some package.
#
# NO_VARHOME is used to denote built-in packages that do not
# have corresponding actual linkable heapchunks -- for example
# the built-in 'inline' package that declares all the built-in ops.
# It is likely that NO_VARHOME will go away in the future once we
# have cleaned up the bootstrap procedure. XXX BUGGO FIXME.
#
Valcon_Form
= UNTAGGED
| TAGGED Int
| TRANSPARENT
| CONSTANT Int
| REFCELL_REP
| EXCEPTION Varhome
| SUSPENSION Null_Or( (Varhome, Varhome) )
| LISTCONS
| LISTNIL
;
#
# All true sumtypes are divided into four categories, depending on the
# pair of parameters (m, n) where m is the number of constant constructors
# and n is the number of value carrying constructors.
#
# REFCELL_REP, EXCEPTION, SUSP are special constructors for reference cells, exceptions,
# and suspensions, respectively. Treating them as data constructors
# simplifies match compilation.
#
# LISTCONS and LISTNIL are special conreps for unrolled lists.
#
# The process of assigning conreps should probably
# be performed on the intermediate language instead. XXX BUGGO FIXME
Valcon_Signature
= CONSTRUCTOR_SIGNATURE (Int, Int)
| NULLARY_CONSTRUCTOR
;
print_varhome: Varhome -> String;
print_representation: Valcon_Form -> String;
print_constructor_api: Valcon_Signature -> String;
is_exception: Valcon_Form -> Bool;
select_varhome
:
(Varhome, Int) -> Varhome;
duplicate_varhome
:
( tmp::Codetemp,
(Null_Or( sy::Symbol ) -> tmp::Codetemp)
)
->
Varhome;
named_varhome
:
( sy::Symbol,
(Null_Or( sy::Symbol ) -> tmp::Codetemp)
)
->
Varhome;
make_varhome
:
(Null_Or( sy::Symbol ) -> tmp::Codetemp)
->
Varhome;
external_varhome
:
ph::Picklehash -> Varhome;
null_varhome: Varhome;
highcode_variable_or_null
:
Varhome -> Null_Or( tmp::Codetemp );
};
end;
## Copyright 1996 by AT&T Bell Laboratories
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.