## browse.pkg
## (C) 2001 Lucent Technologies, Bell Labs
# Compiled by:
#
src/lib/compiler/front/typer-stuff/typecheckdata.sublibstipulate
package mld = module_level_declarations; # module_level_declarations is from
src/lib/compiler/front/typer-stuff/modules/module-level-declarations.pkg package mj = module_junk; # module_junk is from
src/lib/compiler/front/typer-stuff/modules/module-junk.pkg package sxe = symbolmapstack_entry; # symbolmapstack_entry is from
src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack-entry.pkg package sy = symbol; # symbol is from
src/lib/compiler/front/basics/map/symbol.pkg package syx = symbolmapstack; # symbolmapstack is from
src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkgherein
package browse_symbolmapstack
: (weak)
api {
Bind_Info
= NO_DICTIONARY
| DICTIONARY { get: symbol::Symbol -> Bind_Info,
symbols: Void -> List( symbol::Symbol )
};
browse: symbolmapstack::Symbolmapstack -> symbol::Symbol -> Bind_Info;
catalog: symbolmapstack::Symbolmapstack -> List( symbol::Symbol );
}
{
fun bug m
=
error_message::impossible ("browse_symbolmapstack: " + m);
Bind_Info
= NO_DICTIONARY
| DICTIONARY { get: symbol::Symbol -> Bind_Info,
symbols: Void -> List( symbol::Symbol )
};
fun get_elems elements symbol
=
case (mj::get_api_element (elements, symbol))
#
mld::PACKAGE_IN_API { an_api, ... } => sigenv an_api;
mld::GENERIC_IN_API { a_generic_api, ... } => fsgenv a_generic_api;
_ => NO_DICTIONARY;
esac
except
mj::UNBOUND _ = NO_DICTIONARY
also
fun sigenv (an_api as mld::API { api_elements, ... } )
=>
DICTIONARY { get => get_elems api_elements,
symbols => {. mj::get_api_symbols an_api; }
};
sigenv _ => NO_DICTIONARY;
end
# The following is a hack to make the browse function consistent
# with the changes made on raw_syntax_tree during the typechecker
# conversion of raw_syntax_tree into deep_syntax_tree.
#
# Syntactic changes made on raw_syntax_tree by the typechecker
# should be propagated to this function so that Makelib can do
# the correct job.
#
# I personally think that syntactic changes on curried generics
# and insertions of <result_package>s should be done on raw_syntax
# directly, before typechecking --- that way we wouldn't have
# to write the following ugly sigenv_sp function. XXX BUGGO FIXME
#
also
fun sigenv_sp (
mld::API {
api_elements => [
( symbol,
mld::PACKAGE_IN_API { an_api, ... }
)
],
...
}
)
=>
if (sy::name symbol == "<result_package>")
#
sigenv an_api;
else
bug "unexpected case <result_package> in sigenvSp";
fi;
sigenv_sp (
mld::API {
api_elements => [
( symbol,
mld::GENERIC_IN_API { a_generic_api, ... }
)
],
...
}
)
=>
if (sy::name symbol == "<generic>")
#
fsgenv a_generic_api;
else
bug "unexpected case <generic> in sigenvSp";
fi;
sigenv_sp _
=>
bug "unexpected case in signenvSp";
end
also
fun fsgenv (mld::GENERIC_API { body_api, ... } )
=>
sigenv_sp body_api;
fsgenv _
=>
NO_DICTIONARY;
end;
fun strenv (mld::A_PACKAGE { an_api, ... } )
=>
sigenv an_api;
strenv _
=>
NO_DICTIONARY;
end;
fun fctenv (mld::GENERIC { a_generic_api, ... } )
=>
fsgenv a_generic_api;
fctenv _
=>
NO_DICTIONARY;
end;
fun browse symbolmapstack symbol
=
case (syx::get (symbolmapstack, symbol))
#
sxe::NAMED_API b => sigenv b;
sxe::NAMED_PACKAGE b => strenv b;
sxe::NAMED_GENERIC_API b => fsgenv b;
sxe::NAMED_GENERIC b => fctenv b;
_ => NO_DICTIONARY;
esac
except
syx::UNBOUND = NO_DICTIONARY;
fun catalog symbolmapstack
=
map #1 (symbolmapstack::to_sorted_list symbolmapstack);
};
end;