diff --git a/src/protocol/ast.rs b/src/protocol/ast.rs index 7657a9390ebffa00927a9cdc1bc6ae71225e0df2..b92a35cc3ebf01a92e04de55bbc52babd6d429a8 100644 --- a/src/protocol/ast.rs +++ b/src/protocol/ast.rs @@ -752,7 +752,7 @@ pub struct Variable { pub parser_type: ParserType, pub identifier: Identifier, // Validator/linker - pub relative_pos_in_block: u32, + pub relative_pos_in_block: i32, pub unique_id_in_scope: i32, // Temporary fix until proper bytecode/asm is generated } @@ -1170,7 +1170,7 @@ pub struct BlockStatement { pub scope_node: ScopeNode, pub first_unique_id_in_scope: i32, // Temporary fix until proper bytecode/asm is generated pub next_unique_id_in_scope: i32, // Temporary fix until proper bytecode/asm is generated - pub relative_pos_in_parent: u32, + pub relative_pos_in_parent: i32, pub locals: Vec, pub labels: Vec, pub next: StatementId, @@ -1224,6 +1224,7 @@ pub struct MemoryStatement { // Phase 1: parser pub span: InputSpan, pub variable: VariableId, + pub initial_expr: AssignmentExpressionId, // Phase 2: linker pub next: StatementId, } @@ -1241,7 +1242,7 @@ pub struct ChannelStatement { pub from: VariableId, // output pub to: VariableId, // input // Phase 2: linker - pub relative_pos_in_block: u32, + pub relative_pos_in_block: i32, pub next: StatementId, } @@ -1252,7 +1253,7 @@ pub struct LabeledStatement { pub label: Identifier, pub body: StatementId, // Phase 2: linker - pub relative_pos_in_block: u32, + pub relative_pos_in_block: i32, pub in_sync: SynchronousStatementId, // may be invalid } @@ -1357,8 +1358,9 @@ pub struct SelectStatement { #[derive(Debug, Clone)] pub struct SelectCase { - pub guard_var: MemoryStatementId, // invalid ID if there is no declaration of a variable - pub guard_expr: ExpressionStatementId, // if `guard_var.is_some()`, then always assignment expression + // The guard statement of a `select` is either a MemoryStatement or an + // ExpressionStatement. Nothing else is allowed by the initial parsing + pub guard: StatementId, pub block: BlockStatementId, } @@ -1410,6 +1412,7 @@ pub struct ExpressionStatement { #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum ExpressionParent { None, // only set during initial parsing + Memory(MemoryStatementId), If(IfStatementId), While(WhileStatementId), Return(ReturnStatementId),