1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 10:04:21 +03:00
inform7/inter/bytecode-module/Chapter 4/The Nop Construct.w

51 lines
1.9 KiB
OpenEdge ABL
Raw Normal View History

2022-03-01 02:41:22 +02:00
[NopInstruction::] The Nop Construct.
2019-02-05 02:44:07 +02:00
Defining the nop construct.
2022-03-11 01:54:43 +02:00
@h Definition.
This instruction does nothing at all, has no textual representation and is
nevertheless useful when constructing Inter in memory.
It exists as a convenience used by Inform when it needs to write simultaneously to
multiple positions within the same node's child list -- the idea being that
a nop statement acts as a divider. For example, by placing the A write
position just before a nop N, and the B write position just after, Inform
will generate A1, A2, A3, ..., N, B1, B2, ..., rather than (say) A1, B1, A2,
A3, B2, ... The extra N is simply ignored in code generation, so it causes
no problems to have it.
2022-02-24 01:37:43 +02:00
2019-02-05 02:44:07 +02:00
=
2022-03-01 02:41:22 +02:00
void NopInstruction::define_construct(void) {
inter_construct *IC = InterInstruction::create_construct(NOP_IST, I"nop");
2022-03-14 15:53:55 +02:00
InterInstruction::data_extent_always(IC, 0);
2022-03-01 02:41:22 +02:00
InterInstruction::allow_in_depth_range(IC, 0, INFINITELY_DEEP);
InterInstruction::permit(IC, OUTSIDE_OF_PACKAGES_ICUP);
InterInstruction::permit(IC, INSIDE_PLAIN_PACKAGE_ICUP);
InterInstruction::permit(IC, INSIDE_CODE_PACKAGE_ICUP);
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, NopInstruction::write);
2019-02-05 02:44:07 +02:00
}
2022-03-11 01:54:43 +02:00
@h Instructions.
In bytecode, the frame of a |nop| instruction consists only of the two
2022-03-14 00:08:41 +02:00
compulsory words -- see //Inter Nodes//.
2022-03-11 01:54:43 +02:00
=
inter_error_message *NopInstruction::new(inter_bookmark *IBM, inter_ti level,
inter_error_location *eloc) {
inter_tree_node *P = Inode::new_with_0_data_fields(IBM, NOP_IST,
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 Writing to textual Inter syntax.
The |nop| construct is not expressible in textual Inter, but can be printed out
all the same, purely so that a stack backtrace will show it.
2019-07-13 13:03:54 +03:00
2019-07-13 19:15:26 +03:00
=
2022-03-13 13:28:33 +02:00
void NopInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P) {
2019-07-13 13:03:54 +03:00
WRITE("nop");
}