## core-hack.pkg
#
# This is an obscure dedicated hack to replace a given
# package name-symbol (in practice, "xcore") with
# core_symbol::core_symbol (i.e., "_Core").
# We do this only on top-level raw::NAMED_PACKAGE instances.
# Compiled by:
#
src/app/makelib/makelib.sublib### "The longest journal begins with a single word."
###
### -- Allucquere Rosanne Stone
stipulate
package csy = core_symbol; # core_symbol is from
src/lib/compiler/front/typer-stuff/basics/core-symbol.pkg package raw = raw_syntax; # raw_syntax is from
src/lib/compiler/front/parser/raw-syntax/raw-syntax.pkg package sy = symbol; # symbol is from
src/lib/compiler/front/basics/map/symbol.pkgherein
package core_hack: (weak)
api {
substitute_symbol_in_raw_declaration
:
(raw::Declaration, sy::Symbol)
->
raw::Declaration;
}
{
# This fn is called (only) from:
#
#
src/app/makelib/compile/compile-in-dependency-order-g.pkg #
fun substitute_symbol_in_raw_declaration
(
decl,
symbol_to_replace
)
=
do_declaration decl
where
# The first case here is the only one that does useful work;
# the remainder just search recursively through the parsetree:
#
fun do_named_package (named_package as raw::NAMED_PACKAGE { name_symbol, definition, constraint, kind } )
=>
if (sy::eq (name_symbol, symbol_to_replace))
#
raw::NAMED_PACKAGE
{
name_symbol => csy::core_symbol, # <--- The beef in the burger.
definition,
constraint,
kind
};
else
named_package;
fi;
do_named_package (raw::SOURCE_CODE_REGION_FOR_NAMED_PACKAGE (named_package, src_region))
=> raw::SOURCE_CODE_REGION_FOR_NAMED_PACKAGE (do_named_package named_package, src_region);
end;
fun do_declaration (raw::PACKAGE_DECLARATIONS named_packages) => raw::PACKAGE_DECLARATIONS (map do_named_package named_packages);
do_declaration (raw::LOCAL_DECLARATIONS (decl1, decl2)) => raw::LOCAL_DECLARATIONS (decl1, do_declaration decl2);
do_declaration (raw::SEQUENTIAL_DECLARATIONS declarations) => raw::SEQUENTIAL_DECLARATIONS (map do_declaration declarations);
do_declaration (raw::SOURCE_CODE_REGION_FOR_DECLARATION (decl, src_region)) => raw::SOURCE_CODE_REGION_FOR_DECLARATION (do_declaration decl, src_region);
do_declaration other => other;
end;
end;
};
end;
## (C) 2000 Lucent Technologies, Bell Laboratories
## Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.