1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 18:14:21 +03:00
inform7/inter/inter-module/Chapter 2/Connectors.w

44 lines
1.9 KiB
OpenEdge ABL
Raw Normal View History

2019-08-04 14:19:47 +03:00
[Inter::Connectors::] Connectors.
To manage link symbols.
@ =
2019-08-04 15:04:42 +03:00
inter_symbol *Inter::Connectors::plug(inter_tree *I, text_stream *plug_name, text_stream *wanted) {
inter_package *connectors = Inter::Connectors::connectors_package(I);
inter_symbol *plug = Inter::SymbolsTables::create_with_unique_name(
Inter::Packages::scope(connectors), plug_name);
2019-08-04 14:19:47 +03:00
Inter::SymbolsTables::make_plug(plug, wanted);
2019-08-09 15:24:05 +03:00
LOG("Plug I%d: %S\n", I->allocation_id, plug_name);
2019-08-04 14:19:47 +03:00
return plug;
}
2019-08-04 15:04:42 +03:00
inter_symbol *Inter::Connectors::socket(inter_tree *I, text_stream *socket_name, inter_symbol *wired_from) {
inter_package *connectors = Inter::Connectors::connectors_package(I);
inter_symbol *socket = Inter::SymbolsTables::create_with_unique_name(
Inter::Packages::scope(connectors), socket_name);
2019-08-04 14:19:47 +03:00
Inter::SymbolsTables::make_socket(socket, wired_from);
2019-08-09 15:24:05 +03:00
LOG("Socket I%d: %S (== $3)\n", I->allocation_id, socket_name, socket);
2019-08-04 14:19:47 +03:00
return socket;
}
2019-08-04 15:04:42 +03:00
inter_package *Inter::Connectors::connectors_package(inter_tree *I) {
if (I == NULL) internal_error("no tree for connectors");
inter_package *connectors = Inter::Tree::connectors_package(I);
2019-08-04 14:19:47 +03:00
if (connectors == NULL) {
2019-08-04 15:04:42 +03:00
inter_package *main_package = Inter::Tree::main_package(I);
if (main_package == NULL) internal_error("tree without main");
connectors = Inter::Packages::by_name(main_package, I"connectors");
if (connectors == NULL) {
inter_symbol *linkage = Inter::SymbolsTables::url_name_to_symbol(I, NULL, I"/_linkage");
if (linkage == NULL) internal_error("no linkage ptype");
inter_bookmark IBM = Inter::Bookmarks::at_end_of_this_package(main_package);
Inter::Package::new_package(&IBM, I"connectors", linkage,
(inter_t) Inter::Bookmarks::baseline(&IBM)+1, NULL, &(connectors));
}
if (connectors == NULL) internal_error("unable to create connector package");
Inter::Tree::set_connectors_package(I, connectors);
Inter::Packages::make_linklike(connectors);
2019-08-04 14:19:47 +03:00
}
return connectors;
}