Defining the Evaluation construct.
- §1. Definition
- §2. Instructions
- §4. Creating from textual Inter syntax
- §5. Writing to textual Inter syntax
§1. Definition. For what this does and why it is used, see Textual Inter (in inter).
void EvaluationInstruction::define_construct(void) { inter_construct *IC = InterInstruction::create_construct(EVALUATION_IST, I"evaluation"); InterInstruction::specify_syntax(IC, I"evaluation"); InterInstruction::data_extent_always(IC, 0); InterInstruction::allow_in_depth_range(IC, 1, INFINITELY_DEEP); InterInstruction::permit(IC, INSIDE_CODE_PACKAGE_ICUP); InterInstruction::permit(IC, CAN_HAVE_CHILDREN_ICUP); METHOD_ADD(IC, CONSTRUCT_READ_MTID, EvaluationInstruction::read); METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, EvaluationInstruction::write); METHOD_ADD(IC, CONSTRUCT_VERIFY_CHILDREN_MTID, EvaluationInstruction::verify_children); }
§2. Instructions. In bytecode, the frame of an evaluation instruction is laid out with just the two compulsory words — see Inter Nodes.
inter_error_message *EvaluationInstruction::new(inter_bookmark *IBM, int level, inter_error_location *eloc) { inter_tree_node *P = Inode::new_with_0_data_fields(IBM, EVALUATION_IST, eloc, (inter_ti) level); inter_error_message *E = VerifyingInter::instruction(InterBookmark::package(IBM), P); if (E) return E; NodePlacement::move_to_moving_bookmark(P, IBM); return NULL; }
§3. Verification consists only of sanity checks.
void EvaluationInstruction::verify_children(inter_construct *IC, inter_tree_node *P, inter_error_message **E) { LOOP_THROUGH_INTER_CHILDREN(C, P) { if ((C->W.instruction[0] != INV_IST) && (C->W.instruction[0] != SPLAT_IST) && (C->W.instruction[0] != VAL_IST) && (C->W.instruction[0] != LABEL_IST) && (C->W.instruction[0] != EVALUATION_IST)) { *E = Inode::error(C, I"only a value can be below an evaluation", NULL); return; } } }
§4. Creating from textual Inter syntax.
void EvaluationInstruction::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) { *E = EvaluationInstruction::new(IBM, ilp->indent_level, eloc); }
§5. Writing to textual Inter syntax.
void EvaluationInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P) { WRITE("evaluation"); }