1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/inter/bytecode-module/Chapter 4/The Property Construct.w

88 lines
3.6 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Inter::Property::] The Property Construct.
Defining the property construct.
@
@e PROPERTY_IST
=
void Inter::Property::define(void) {
2019-07-09 08:45:46 +03:00
inter_construct *IC = Inter::Defn::create_construct(
2019-02-05 02:44:07 +02:00
PROPERTY_IST,
L"property (%i+) (%i+)",
I"property", I"properties");
2019-07-09 08:45:46 +03:00
METHOD_ADD(IC, CONSTRUCT_READ_MTID, Inter::Property::read);
METHOD_ADD(IC, CONSTRUCT_TRANSPOSE_MTID, Inter::Property::transpose);
2019-07-09 08:45:46 +03:00
METHOD_ADD(IC, CONSTRUCT_VERIFY_MTID, Inter::Property::verify);
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, Inter::Property::write);
2019-02-05 02:44:07 +02:00
}
@
@d DEFN_PROP_IFLD 2
@d KIND_PROP_IFLD 3
@d PERM_LIST_PROP_IFLD 4
@d EXTENT_PROP_IFR 5
=
2019-07-14 12:44:07 +03:00
void Inter::Property::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
*E = Inter::Defn::vet_level(IBM, PROPERTY_IST, ilp->indent_level, eloc);
2019-07-09 08:45:46 +03:00
if (*E) return;
2019-02-05 02:44:07 +02:00
2019-07-14 12:44:07 +03:00
inter_symbol *prop_name = Inter::Textual::new_symbol(eloc, Inter::Bookmarks::scope(IBM), ilp->mr.exp[0], E);
2019-07-09 08:45:46 +03:00
if (*E) return;
2019-07-23 01:34:28 +03:00
inter_symbol *prop_kind = Inter::Textual::find_symbol(Inter::Bookmarks::tree(IBM), eloc, Inter::Bookmarks::scope(IBM), ilp->mr.exp[1], KIND_IST, E);
2019-07-09 08:45:46 +03:00
if (*E) return;
2019-02-05 02:44:07 +02:00
2019-07-26 10:59:23 +03:00
Inter::Annotations::copy_set_to_symbol(&(ilp->set), prop_name);
2019-02-05 02:44:07 +02:00
2021-04-15 00:57:48 +03:00
*E = Inter::Property::new(IBM, InterSymbolsTables::id_from_IRS_and_symbol(IBM, prop_name), InterSymbolsTables::id_from_IRS_and_symbol(IBM, prop_kind), (inter_ti) ilp->indent_level, eloc);
2019-02-05 02:44:07 +02:00
}
2020-07-01 02:58:55 +03:00
inter_error_message *Inter::Property::new(inter_bookmark *IBM, inter_ti PID, inter_ti KID, inter_ti level, inter_error_location *eloc) {
inter_warehouse *warehouse = Inter::Bookmarks::warehouse(IBM);
2020-07-01 02:58:55 +03:00
inter_ti L1 = Inter::Warehouse::create_frame_list(warehouse);
Inter::Warehouse::attribute_resource(warehouse, L1, Inter::Bookmarks::package(IBM));
2020-05-11 17:21:29 +03:00
inter_tree_node *P = Inode::fill_3(IBM, PROPERTY_IST, PID, KID, L1, eloc, level);
2019-07-14 12:44:07 +03:00
inter_error_message *E = Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), P);
2019-02-05 02:44:07 +02:00
if (E) return E;
Inter::Bookmarks::insert(IBM, P);
2019-02-05 02:44:07 +02:00
return NULL;
}
2020-07-01 02:58:55 +03:00
void Inter::Property::transpose(inter_construct *IC, inter_tree_node *P, inter_ti *grid, inter_ti grid_extent, inter_error_message **E) {
2019-07-24 20:15:07 +03:00
P->W.data[PERM_LIST_PROP_IFLD] = grid[P->W.data[PERM_LIST_PROP_IFLD]];
}
2019-07-24 20:15:07 +03:00
void Inter::Property::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
2020-05-11 17:21:29 +03:00
if (P->W.extent != EXTENT_PROP_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
*E = Inter::Verify::defn(owner, P, DEFN_PROP_IFLD); if (*E) return;
2019-07-24 20:15:07 +03:00
*E = Inter::Verify::symbol(owner, P, P->W.data[KIND_PROP_IFLD], KIND_IST);
2019-02-05 02:44:07 +02:00
}
2020-07-01 02:58:55 +03:00
inter_ti Inter::Property::permissions_list(inter_symbol *prop_name) {
2019-02-05 02:44:07 +02:00
if (prop_name == NULL) return 0;
2019-07-24 20:15:07 +03:00
inter_tree_node *D = Inter::Symbols::definition(prop_name);
if (D == NULL) return 0;
2019-07-24 20:15:07 +03:00
return D->W.data[PERM_LIST_PROP_IFLD];
2019-02-05 02:44:07 +02:00
}
2019-07-24 20:15:07 +03:00
void Inter::Property::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
2021-04-15 00:57:48 +03:00
inter_symbol *prop_name = InterSymbolsTables::symbol_from_frame_data(P, DEFN_PROP_IFLD);
inter_symbol *prop_kind = InterSymbolsTables::symbol_from_frame_data(P, KIND_PROP_IFLD);
2019-02-05 02:44:07 +02:00
if ((prop_name) && (prop_kind)) {
WRITE("property %S %S", prop_name->symbol_name, prop_kind->symbol_name);
Inter::Symbols::write_annotations(OUT, P, prop_name);
2020-05-11 17:21:29 +03:00
} else { *E = Inode::error(P, I"cannot write property", NULL); return; }
2019-02-05 02:44:07 +02:00
}
inter_symbol *Inter::Property::kind_of(inter_symbol *prop_symbol) {
if (prop_symbol == NULL) return NULL;
2019-07-24 20:15:07 +03:00
inter_tree_node *D = Inter::Symbols::definition(prop_symbol);
if (D == NULL) return NULL;
2019-07-24 20:15:07 +03:00
if (D->W.data[ID_IFLD] != PROPERTY_IST) return NULL;
2021-04-15 00:57:48 +03:00
return InterSymbolsTables::symbol_from_frame_data(D, KIND_PROP_IFLD);
2019-02-05 02:44:07 +02:00
}