diff --git a/src/protocol/ast.rs b/src/protocol/ast.rs index 5ba51755ee94a3ca7ac27b1ef375c73608ea19f8..da5ba6db6c6a05dde8bafa165679eda350dd7256 100644 --- a/src/protocol/ast.rs +++ b/src/protocol/ast.rs @@ -699,21 +699,32 @@ impl<'a> Iterator for ConcreteTypeIter<'a> { pub enum Scope { Definition(DefinitionId), Regular(BlockStatementId), - Synchronous((SynchronousStatementId, BlockStatementId)), + Synchronous(SynchronousStatementId, BlockStatementId), } impl Scope { + pub(crate) fn new_invalid() -> Scope { + return Scope::Definition(DefinitionId::new_invalid()); + } + + pub(crate) fn is_invalid(&self) -> bool { + match self { + Scope::Definition(id) => id.is_invalid(), + _ => false, + } + } + pub fn is_block(&self) -> bool { match &self { Scope::Definition(_) => false, Scope::Regular(_) => true, - Scope::Synchronous(_) => true, + Scope::Synchronous(_, _) => true, } } pub fn to_block(&self) -> BlockStatementId { match &self { Scope::Regular(id) => *id, - Scope::Synchronous((_, id)) => *id, + Scope::Synchronous(_, id) => *id, _ => panic!("unable to get BlockStatement from Scope") } } @@ -726,13 +737,15 @@ impl Scope { pub struct ScopeNode { pub parent: Scope, pub nested: Vec, + pub relative_pos_in_parent: i32, } impl ScopeNode { pub(crate) fn new_invalid() -> Self { ScopeNode{ - parent: Scope::Definition(DefinitionId::new_invalid()), + parent: Scope::new_invalid(), nested: Vec::new(), + relative_pos_in_parent: -1, } } } @@ -1170,7 +1183,6 @@ 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: i32, pub locals: Vec, pub labels: Vec, pub next: StatementId,