This commit is contained in:
JT
2021-10-26 09:04:23 +13:00
parent f84582ca2b
commit d29208dd9e
14 changed files with 265 additions and 81 deletions

View File

@@ -1,6 +1,6 @@
use std::ops::{Index, IndexMut};
use crate::{DeclId, Signature};
use crate::{DeclId, Signature, VarId};
use super::Statement;
@@ -9,6 +9,7 @@ pub struct Block {
pub signature: Box<Signature>,
pub stmts: Vec<Statement>,
pub exports: Vec<(Vec<u8>, DeclId)>, // Assuming just defs for now
pub captures: Vec<VarId>,
}
impl Block {
@@ -47,6 +48,7 @@ impl Block {
signature: Box::new(Signature::new("")),
stmts: vec![],
exports: vec![],
captures: vec![],
}
}
@@ -55,6 +57,7 @@ impl Block {
signature: self.signature,
stmts: self.stmts,
exports,
captures: self.captures,
}
}
}
@@ -68,6 +71,7 @@ where
signature: Box::new(Signature::new("")),
stmts: stmts.collect(),
exports: vec![],
captures: vec![],
}
}
}

View File

@@ -13,6 +13,7 @@ pub enum Expr {
RangeOperator,
),
Var(VarId),
VarDecl(VarId),
Call(Box<Call>),
ExternalCall(String, Span, Vec<Expression>),
Operator(Operator),

View File

@@ -77,6 +77,7 @@ impl Expression {
pub fn as_var(&self) -> Option<VarId> {
match self.expr {
Expr::Var(var_id) => Some(var_id),
Expr::VarDecl(var_id) => Some(var_id),
_ => None,
}
}