Ast: add push method to blocks
This commit is contained in:
parent
2c15d8547d
commit
279c9d6135
1 changed files with 12 additions and 0 deletions
12
src/ast.rs
12
src/ast.rs
|
@ -46,6 +46,12 @@ pub struct GlobalBlock {
|
|||
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 {
|
||||
fn to_string(&self) -> String {
|
||||
let mut s = String::new();
|
||||
|
@ -64,6 +70,12 @@ pub struct Block {
|
|||
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 {
|
||||
fn to_string(&self) -> String {
|
||||
let mut s = String::from("{ ");
|
||||
|
|
Loading…
Reference in a new issue