2019-03-23 02:06:09 +02:00
|
|
|
[Inter::Reference::] The Reference Construct.
|
|
|
|
|
|
|
|
Defining the Reference construct.
|
|
|
|
|
|
|
|
@
|
|
|
|
|
|
|
|
@e REFERENCE_IST
|
|
|
|
|
|
|
|
=
|
|
|
|
void Inter::Reference::define(void) {
|
|
|
|
inter_construct *IC = Inter::Defn::create_construct(
|
|
|
|
REFERENCE_IST,
|
|
|
|
L"reference",
|
|
|
|
I"reference", I"references");
|
|
|
|
IC->min_level = 1;
|
|
|
|
IC->max_level = 100000000;
|
2019-07-09 12:32:05 +03:00
|
|
|
IC->usage_permissions = INSIDE_CODE_PACKAGE + CAN_HAVE_CHILDREN;
|
2019-07-09 08:45:46 +03:00
|
|
|
METHOD_ADD(IC, CONSTRUCT_READ_MTID, Inter::Reference::read);
|
|
|
|
METHOD_ADD(IC, CONSTRUCT_VERIFY_MTID, Inter::Reference::verify);
|
|
|
|
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, Inter::Reference::write);
|
2019-07-08 13:21:00 +03:00
|
|
|
METHOD_ADD(IC, VERIFY_INTER_CHILDREN_MTID, Inter::Reference::verify_children);
|
2019-03-23 02:06:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@
|
|
|
|
|
|
|
|
@d BLOCK_RCE_IFLD 2
|
|
|
|
|
2019-07-09 12:32:05 +03:00
|
|
|
@d EXTENT_RCE_IFR 3
|
2019-03-23 02:06:09 +02:00
|
|
|
|
|
|
|
=
|
2019-07-09 08:45:46 +03:00
|
|
|
void Inter::Reference::read(inter_construct *IC, inter_reading_state *IRS, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
|
|
|
|
if (ilp->no_annotations > 0) { *E = Inter::Errors::plain(I"__annotations are not allowed", eloc); return; }
|
2019-03-23 02:06:09 +02:00
|
|
|
|
2019-07-09 08:45:46 +03:00
|
|
|
*E = Inter::Defn::vet_level(IRS, REFERENCE_IST, ilp->indent_level, eloc);
|
|
|
|
if (*E) return;
|
2019-03-23 02:06:09 +02:00
|
|
|
|
|
|
|
inter_symbol *routine = Inter::Defn::get_latest_block_symbol();
|
2019-07-09 08:45:46 +03:00
|
|
|
if (routine == NULL) { *E = Inter::Errors::plain(I"'reference' used outside function", eloc); return; }
|
2019-03-23 02:06:09 +02:00
|
|
|
|
2019-07-09 08:45:46 +03:00
|
|
|
*E = Inter::Reference::new(IRS, routine, ilp->indent_level, eloc);
|
2019-03-23 02:06:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inter_error_message *Inter::Reference::new(inter_reading_state *IRS, inter_symbol *routine, int level, inter_error_location *eloc) {
|
2019-07-09 12:32:05 +03:00
|
|
|
inter_frame P = Inter::Frame::fill_1(IRS, REFERENCE_IST, 0, eloc, (inter_t) level);
|
2019-07-12 13:33:52 +03:00
|
|
|
inter_error_message *E = Inter::Defn::verify_construct(IRS->current_package, P); if (E) return E;
|
2019-03-23 02:06:09 +02:00
|
|
|
Inter::Frame::insert(P, IRS);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-07-12 13:33:52 +03:00
|
|
|
void Inter::Reference::verify(inter_construct *IC, inter_frame P, inter_package *owner, inter_error_message **E) {
|
2019-07-09 08:45:46 +03:00
|
|
|
if (P.extent != EXTENT_RCE_IFR) { *E = Inter::Frame::error(&P, I"extent wrong", NULL); return; }
|
2019-03-23 02:06:09 +02:00
|
|
|
}
|
|
|
|
|
2019-07-09 08:45:46 +03:00
|
|
|
void Inter::Reference::write(inter_construct *IC, OUTPUT_STREAM, inter_frame P, inter_error_message **E) {
|
2019-03-23 02:06:09 +02:00
|
|
|
WRITE("reference");
|
|
|
|
}
|
|
|
|
|
2019-07-08 13:21:00 +03:00
|
|
|
void Inter::Reference::verify_children(inter_construct *IC, inter_frame P, inter_error_message **E) {
|
2019-07-10 12:27:52 +03:00
|
|
|
LOOP_THROUGH_INTER_CHILDREN(C, P) {
|
2019-07-08 13:21:00 +03:00
|
|
|
if ((C.data[0] != INV_IST) && (C.data[0] != REF_IST) && (C.data[0] != SPLAT_IST) && (C.data[0] != VAL_IST) && (C.data[0] != LABEL_IST)) {
|
|
|
|
*E = Inter::Frame::error(&C, I"only an inv, a ref, a splat, a val, or a label can be below a reference", NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-03-23 02:06:09 +02:00
|
|
|
}
|