1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-16 22:14:23 +03:00
inform7/inter/bytecode-module/Chapter 4/The PackageType Construct.w

56 lines
2 KiB
OpenEdge ABL
Raw Normal View History

2022-03-01 02:41:22 +02:00
[PackageTypeInstruction::] The PackageType Construct.
2019-02-05 02:44:07 +02:00
Defining the packagetype construct.
2022-03-11 01:54:43 +02:00
@h Definition.
For what this does and why it is used, see //inter: Textual Inter//.
2019-02-05 02:44:07 +02:00
=
2022-03-01 02:41:22 +02:00
void PackageTypeInstruction::define_construct(void) {
inter_construct *IC = InterInstruction::create_construct(PACKAGETYPE_IST, I"packagetype");
InterInstruction::defines_symbol_in_fields(IC, DEFN_PTYPE_IFLD, -1);
InterInstruction::specify_syntax(IC, I"packagetype _IDENTIFIER");
2022-03-14 15:53:55 +02:00
InterInstruction::data_extent_always(IC, 1);
2022-03-01 02:41:22 +02:00
METHOD_ADD(IC, CONSTRUCT_READ_MTID, PackageTypeInstruction::read);
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, PackageTypeInstruction::write);
InterInstruction::permit(IC, OUTSIDE_OF_PACKAGES_ICUP);
2019-02-05 02:44:07 +02:00
}
2022-03-11 01:54:43 +02:00
@h Instructions.
2022-03-14 00:08:41 +02:00
In bytecode, the frame of a |packagetype| instruction is laid out with the
compulsory words -- see //Inter Nodes// -- followed by:
2019-02-05 02:44:07 +02:00
2022-03-14 00:08:41 +02:00
@d DEFN_PTYPE_IFLD (DATA_IFLD + 0)
2019-02-05 02:44:07 +02:00
=
2022-03-11 01:54:43 +02:00
inter_error_message *PackageTypeInstruction::new(inter_bookmark *IBM, inter_symbol *ptype,
inter_ti level, inter_error_location *eloc) {
inter_tree_node *P = Inode::new_with_1_data_field(IBM, PACKAGETYPE_IST,
2022-03-11 23:38:53 +02:00
/* DEFN_PTYPE_IFLD: */ InterSymbolsTable::id_at_bookmark(IBM, ptype),
2022-03-11 01:54:43 +02:00
eloc, level);
2022-03-01 02:41:22 +02:00
inter_error_message *E = VerifyingInter::instruction(InterBookmark::package(IBM), P);
2019-02-05 02:44:07 +02:00
if (E) return E;
2022-01-27 01:59:02 +02:00
NodePlacement::move_to_moving_bookmark(P, IBM);
2019-02-05 02:44:07 +02:00
return NULL;
}
2022-03-11 01:54:43 +02:00
@h Creating from textual Inter syntax.
=
void PackageTypeInstruction::read(inter_construct *IC, inter_bookmark *IBM,
inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
inter_symbol *ptype_name =
TextualInter::new_symbol(eloc, InterBookmark::scope(IBM), ilp->mr.exp[0], E);
if (*E) return;
*E = PackageTypeInstruction::new(IBM, ptype_name, (inter_ti) ilp->indent_level, eloc);
}
@h Writing to textual Inter syntax.
=
2022-03-13 13:28:33 +02:00
void PackageTypeInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P) {
2022-02-03 17:51:44 +02:00
inter_symbol *ptype_name = InterSymbolsTable::symbol_from_ID_at_node(P, DEFN_PTYPE_IFLD);
2022-03-11 01:54:43 +02:00
WRITE("packagetype %S", InterSymbol::identifier(ptype_name));
2019-02-05 02:44:07 +02:00
}