1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-03 07:24:58 +03:00
inform7/inter/bytecode-module/Chapter 4/The Version Construct.w

52 lines
1.8 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Inter::Version::] The Version Construct.
Defining the version construct.
@
@e VERSION_IST
=
void Inter::Version::define(void) {
inter_construct *IC = Inter::Defn::create_construct(
VERSION_IST,
L"version (%d+)",
I"version", I"versions");
IC->usage_permissions = OUTSIDE_OF_PACKAGES;
2019-07-09 08:45:46 +03:00
METHOD_ADD(IC, CONSTRUCT_READ_MTID, Inter::Version::read);
METHOD_ADD(IC, CONSTRUCT_VERIFY_MTID, Inter::Version::verify);
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, Inter::Version::write);
2019-02-05 02:44:07 +02:00
}
@
@d NUMBER_VERSION_IFLD 2
@d EXTENT_VERSION_IFR 3
=
2019-07-14 12:44:07 +03:00
void Inter::Version::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, VERSION_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-26 10:59:23 +03:00
if (Inter::Annotations::exist(&(ilp->set))) { *E = Inter::Errors::plain(I"__annotations are not allowed", eloc); return; }
2019-02-05 02:44:07 +02:00
2020-07-01 02:58:55 +03:00
*E = Inter::Version::new(IBM, Str::atoi(ilp->mr.exp[0], 0), (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::Version::new(inter_bookmark *IBM, int V, inter_ti level, inter_error_location *eloc) {
2022-01-28 01:38:14 +02:00
inter_tree_node *P = Inode::new_with_1_data_field(IBM, VERSION_IST, (inter_ti) V, eloc, level);
2022-01-27 01:59:02 +02:00
inter_error_message *E = Inter::Defn::verify_construct(InterBookmark::package(IBM), P); if (E) return E;
NodePlacement::move_to_moving_bookmark(P, IBM);
2019-02-05 02:44:07 +02:00
return NULL;
}
2019-07-24 20:15:07 +03:00
void Inter::Version::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_VERSION_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
2022-01-30 15:32:38 +02:00
if (P->W.instruction[NUMBER_VERSION_IFLD] < 1) { *E = Inode::error(P, I"version out of range", NULL); return; }
2019-02-05 02:44:07 +02:00
}
2019-07-24 20:15:07 +03:00
void Inter::Version::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
2022-01-30 15:32:38 +02:00
WRITE("version %d", P->W.instruction[NUMBER_VERSION_IFLD]);
2019-02-05 02:44:07 +02:00
}