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 DefaultValue Construct.w

65 lines
2.7 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Inter::DefaultValue::] The DefaultValue Construct.
Defining the defaultvalue construct.
@
@e DEFAULTVALUE_IST
=
void Inter::DefaultValue::define(void) {
inter_construct *IC = InterConstruct::create_construct(DEFAULTVALUE_IST, I"defaultvalue");
InterConstruct::specify_syntax(IC, I"defaultvalue IDENTIFIER = TOKENS");
InterConstruct::permit(IC, INSIDE_PLAIN_PACKAGE_ICUP);
2019-07-09 08:45:46 +03:00
METHOD_ADD(IC, CONSTRUCT_READ_MTID, Inter::DefaultValue::read);
METHOD_ADD(IC, CONSTRUCT_VERIFY_MTID, Inter::DefaultValue::verify);
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, Inter::DefaultValue::write);
2019-02-05 02:44:07 +02:00
}
@
@d KIND_DEF_IFLD 2
@d VAL1_DEF_IFLD 3
@d VAL2_DEF_IFLD 4
@d EXTENT_DEF_IFR 5
=
2019-07-14 12:44:07 +03:00
void Inter::DefaultValue::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
2022-02-09 12:33:49 +02:00
*E = InterConstruct::check_level_in_package(IBM, DEFAULTVALUE_IST, ilp->indent_level, eloc);
2019-07-09 08:45:46 +03:00
if (*E) return;
2019-02-05 02:44:07 +02:00
inter_symbol *con_kind = TextualInter::find_symbol(InterBookmark::tree(IBM), eloc, InterBookmark::scope(IBM), ilp->mr.exp[0], KIND_IST, E);
2019-07-09 08:45:46 +03:00
if (*E) return;
2019-02-05 02:44:07 +02:00
2020-07-01 02:58:55 +03:00
inter_ti con_val1 = 0;
inter_ti con_val2 = 0;
2022-01-27 01:59:02 +02:00
*E = Inter::Types::read(ilp->line, eloc, InterBookmark::tree(IBM), InterBookmark::package(IBM), con_kind, ilp->mr.exp[1], &con_val1, &con_val2, InterBookmark::scope(IBM));
2019-07-09 08:45:46 +03:00
if (*E) return;
2019-02-05 02:44:07 +02:00
2022-02-03 17:51:44 +02:00
*E = Inter::DefaultValue::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_kind), con_val1, con_val2, (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::DefaultValue::new(inter_bookmark *IBM, inter_ti KID, inter_ti val1, inter_ti val2, inter_ti level, inter_error_location *eloc) {
2022-01-28 01:38:14 +02:00
inter_tree_node *P = Inode::new_with_3_data_fields(IBM, DEFAULTVALUE_IST, KID, val1, val2, eloc, level);
2022-02-07 00:33:07 +02:00
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P); 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;
}
2019-07-24 20:15:07 +03:00
void Inter::DefaultValue::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_DEF_IFR) *E = Inode::error(P, I"extent wrong", NULL);
2022-01-30 15:32:38 +02:00
else *E = Inter::Verify::symbol(owner, P, P->W.instruction[KIND_DEF_IFLD], KIND_IST);
2019-02-05 02:44:07 +02:00
}
2019-07-24 20:15:07 +03:00
void Inter::DefaultValue::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
2022-02-03 17:51:44 +02:00
inter_symbol *con_kind = InterSymbolsTable::symbol_from_ID_at_node(P, KIND_DEF_IFLD);
2019-02-05 02:44:07 +02:00
if (con_kind) {
WRITE("defaultvalue %S = ", con_kind->symbol_name);
Inter::Types::write(OUT, P, con_kind,
2022-01-31 01:49:12 +02:00
P->W.instruction[VAL1_DEF_IFLD], P->W.instruction[VAL1_DEF_IFLD+1], InterPackage::scope_of(P), FALSE);
2019-02-05 02:44:07 +02:00
} else {
2020-05-11 17:21:29 +03:00
*E = Inode::error(P, I"defaultvalue can't be written", NULL);
2019-02-05 02:44:07 +02:00
}
}