datex_core/compiler/precompiler/
scope.rs

1use crate::collections::HashMap;
2
3#[derive(Default, Debug, Clone)]
4pub struct PrecompilerScope {
5    pub realm_index: usize,
6    pub variable_ids_by_name: HashMap<String, usize>,
7}
8
9impl PrecompilerScope {
10    pub fn new_with_realm_index(realm_index: usize) -> Self {
11        PrecompilerScope {
12            realm_index,
13            variable_ids_by_name: HashMap::new(),
14        }
15    }
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub enum NewScopeType {
20    // no new scope, just continue in the current scope
21    None,
22    // create a new scope, but do not increment the realm index
23    NewScope,
24    // create a new scope and increment the realm index (e.g. for remote execution calls)
25    NewScopeWithNewRealm,
26}