Ast: add push method to blocks

This commit is contained in:
Akemi Izuko 2023-11-16 17:35:59 -07:00
parent 2c15d8547d
commit 279c9d6135
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC

View file

@ -46,6 +46,12 @@ pub struct GlobalBlock {
statements: Vec<Box<dyn Statement>>, statements: Vec<Box<dyn Statement>>,
} }
impl GlobalBlock {
pub fn push_node(&mut self, node: Box<dyn Statement>) {
self.statements.push(node);
}
}
impl ToString for GlobalBlock { impl ToString for GlobalBlock {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let mut s = String::new(); let mut s = String::new();
@ -64,6 +70,12 @@ pub struct Block {
statements: Vec<Box<dyn Statement>>, statements: Vec<Box<dyn Statement>>,
} }
impl Block {
pub fn push_node(&mut self, node: Box<dyn Statement>) {
self.statements.push(node);
}
}
impl ToString for Block { impl ToString for Block {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let mut s = String::from("{ "); let mut s = String::from("{ ");