Ast: add push method to blocks
This commit is contained in:
parent
2c15d8547d
commit
279c9d6135
12
src/ast.rs
12
src/ast.rs
|
@ -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("{ ");
|
||||||
|
|
Loading…
Reference in a new issue