Commit f9006d43 authored by Daniel Kochmański's avatar Daniel Kochmański
Browse files

packages: add nicknamedby field and accessors

Add accessors to probe for local nicknames.
parent 214f8e16
......@@ -120,6 +120,7 @@ alloc_package(cl_object name)
p->pack.name = name;
p->pack.nicknames = ECL_NIL;
p->pack.local_nicknames = ECL_NIL;
p->pack.nicknamedby = ECL_NIL;
p->pack.shadowings = ECL_NIL;
p->pack.uses = ECL_NIL;
p->pack.usedby = ECL_NIL;
......@@ -240,7 +241,12 @@ ecl_make_package(cl_object name, cl_object nicknames,
x->pack.uses = CONS(y, x->pack.uses);
y->pack.usedby = CONS(x, y->pack.usedby);
} end_loop_for_in;
x->pack.local_nicknames = local_nicknames;
loop_for_in(local_nicknames) {
cl_object y = ECL_CONS_CAR(local_nicknames);
cl_object nicknamed = ECL_CONS_CDR(y);
x->pack.local_nicknames = CONS(y, x->pack.local_nicknames);
nicknamed->pack.nicknamedby = CONS(x, nicknamed->pack.nicknamedby);
} end_loop_for_in;
/* Finally, add it to the list of packages */
cl_core.packages = CONS(x, cl_core.packages);
OUTPUT:
......@@ -946,6 +952,20 @@ si_package_lock(cl_object p, cl_object t)
@(return (previous? ECL_T : ECL_NIL));
}
cl_object
si_package_local_nicknames(cl_object p)
{
p = si_coerce_to_package(p);
return cl_copy_tree(p->pack.local_nicknames);
}
cl_object
si_package_locally_nicknamed_by_list(cl_object p)
{
p = si_coerce_to_package(p);
return cl_copy_list(p->pack.nicknamedby);
}
cl_object
cl_list_all_packages()
{
......
......@@ -1207,7 +1207,7 @@ cl_symbols[] = {
{EXT_ "MKSTEMP", EXT_ORDINARY, si_mkstemp, 1, OBJNULL},
{SYS_ "RMDIR", SI_ORDINARY, si_rmdir, 1, OBJNULL},
{EXT_ "MAKE-PIPE", EXT_ORDINARY, si_make_pipe, 0, OBJNULL},
/* PACKAGE_LOCKS */
/* package extensions */
{SYS_ "*IGNORE-PACKAGE-LOCKS*", SI_SPECIAL, NULL, -1, ECL_NIL},
{EXT_ "PACKAGE-LOCK", EXT_ORDINARY, si_package_lock, 2, OBJNULL},
{SYS_ "LOCK-PACKAGE", EXT_ORDINARY, NULL, 1, OBJNULL},
......@@ -1215,7 +1215,9 @@ cl_symbols[] = {
{SYS_ "PACKAGE-LOCKED-P", EXT_ORDINARY, NULL, 1, OBJNULL},
{SYS_ "WITHOUT-PACKAGE-LOCKS", EXT_ORDINARY, NULL, 1, OBJNULL},
{SYS_ "WITH-UNLOCKED-PACKAGES", EXT_ORDINARY, NULL, 1, OBJNULL},
/* ~PACKAGE_LOCKS */
{EXT_ "PACKAGE-LOCAL-NICKNAMES", EXT_ORDINARY, si_package_local_nicknames, 1, OBJNULL},
{EXT_ "PACKAGE-LOCALLY-NICKNAMED-BY-LIST", EXT_ORDINARY, si_package_locally_nicknamed_by_list, 1, OBJNULL},
/* ~ */
{SYS_ "PACKAGE-HASH-TABLES", SI_ORDINARY, si_package_hash_tables, 1, OBJNULL},
{SYS_ "PATHNAME-TRANSLATIONS", SI_ORDINARY, si_pathname_translations, -1, OBJNULL},
{SYS_ "POINTER", SI_ORDINARY, si_pointer, 1, OBJNULL},
......
......@@ -1207,7 +1207,7 @@ cl_symbols[] = {
{EXT_ "MKSTEMP","si_mkstemp"},
{SYS_ "RMDIR","si_rmdir"},
{EXT_ "MAKE-PIPE","si_make_pipe"},
/* PACKAGE_LOCKS */
/* package extensions */
{SYS_ "*IGNORE-PACKAGE-LOCKS*",NULL},
{EXT_ "PACKAGE-LOCK","si_package_lock"},
{SYS_ "LOCK-PACKAGE",NULL},
......@@ -1215,7 +1215,9 @@ cl_symbols[] = {
{SYS_ "PACKAGE-LOCKED-P",NULL},
{SYS_ "WITHOUT-PACKAGE-LOCKS",NULL},
{SYS_ "WITH-UNLOCKED-PACKAGES",NULL},
/* ~PACKAGE_LOCKS */
{EXT_ "PACKAGE-LOCAL-NICKNAMES","si_package_local_nicknames"},
{EXT_ "PACKAGE-LOCALLY-NICKNAMED-BY-LIST","si_package_locally_nicknamed_by_list"},
{SYS_ "PACKAGE-HASH-TABLES","si_package_hash_tables"},
{SYS_ "PATHNAME-TRANSLATIONS","si_pathname_translations"},
{SYS_ "POINTER","si_pointer"},
......
......@@ -1283,6 +1283,8 @@ extern ECL_API cl_object cl_package_nicknames(cl_object p);
extern ECL_API cl_object cl_package_use_list(cl_object p);
extern ECL_API cl_object cl_package_used_by_list(cl_object p);
extern ECL_API cl_object cl_package_shadowing_symbols(cl_object p);
extern ECL_API cl_object si_package_local_nicknames(cl_object p);
extern ECL_API cl_object si_package_locally_nicknamed_by_list(cl_object p);
extern ECL_API cl_object cl_list_all_packages(void);
extern ECL_API cl_object si_package_hash_tables(cl_object p);
extern ECL_API cl_object si_package_lock(cl_object p, cl_object t);
......
......@@ -275,9 +275,10 @@ struct ecl_package {
cl_object name; /* package name, a string */
cl_object nicknames; /* nicknames, list of strings */
cl_object local_nicknames; /* local nicknames, assoc list */
cl_object shadowings; /* shadowing symbol list */
cl_object uses; /* use-list of packages */
cl_object usedby; /* used-by-list of packages */
cl_object nicknamedby; /* nicknamed-by-list of packages */
cl_object shadowings; /* shadowing symbol list */
cl_object uses; /* use-list of packages */
cl_object usedby; /* used-by-list of packages */
cl_object internal; /* hashtable for internal symbols */
cl_object external; /* hashtable for external symbols */
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment