## adl-symboltable.api "adl" == "architecture description language"
#
# architecture description language is a hacked variant of SML, so
# to process it we need much of the machinery of a compiler.
# Here we implement a symbol table to track the types, values,
# packages etc known in a particular lexical scope.
# Compiled by:
#
src/lib/compiler/back/low/tools/arch/make-sourcecode-for-backend-packages.libstipulate
package raw = adl_raw_syntax_form; # adl_raw_syntax_form is from
src/lib/compiler/back/low/tools/adl-syntax/adl-raw-syntax-form.pkgherein
# This api is implemented in:
#
src/lib/compiler/back/low/tools/arch/adl-symboltable.pkg api Adl_Symboltable {
#
Symboltable;
empty: Symboltable; # Empty dictionary.
++ : (Symboltable, Symboltable) -> Symboltable; # Stack dictionaries.
# Typecheck:
#
make_variable: Symboltable -> raw::Type;
instantiate: Symboltable -> (raw::Expression, raw::Type) -> (raw::Expression, raw::Type);
generalize: Symboltable -> (raw::Expression, raw::Type) -> (raw::Expression, raw::Type);
lambda: Symboltable -> raw::Type -> raw::Type;
#
digest_declaration: Symboltable -> raw::Declaration -> Symboltable; # Result is a delta symboltable containing only info from given declaratation; see next to combine with pre-existing symboltable.
note_declaration: Symboltable -> raw::Declaration -> Symboltable; # This is just 'symboltable ++ digest_declaration symboltable declaration' -- given symboltable augmented by given declaration.
named_variable: (raw::Id, raw::Expression, raw::Type) -> Symboltable;
type_bind: (raw::Id, raw::Type) -> Symboltable;
named_package: (raw::Id, List(raw::Declaration), Symboltable) -> Symboltable;
# Lookup functions:
#
find_type: Symboltable -> raw::Ident -> raw::Type;
find_package: Symboltable -> raw::Ident -> Symboltable;
#
find_value: Symboltable -> raw::Ident -> (raw::Expression, raw::Type);
find_value': (raw::Id -> Void) -> Symboltable -> raw::Ident -> (raw::Expression, raw::Type);
#
sumtype_definitions: Symboltable -> List( raw::Sumtype );
# Iterators:
#
fold_val: ((raw::Id, raw::Expression, raw::Type, X) -> X)
-> X
-> Symboltable
-> X;
# Lookup code from nested packages/apis:
#
decl_of: Symboltable -> raw::Id -> raw::Declaration;
generic_arg_of: Symboltable -> raw::Id -> raw::Declaration;
type_of: Symboltable -> raw::Id -> raw::Declaration;
};
end;