mirror of
https://github.com/circify/circ.git
synced 2026-04-21 03:00:54 -04:00
return stmt
This commit is contained in:
@@ -12,9 +12,9 @@ use std::fmt::{self, Display, Formatter};
|
||||
|
||||
|
||||
pub struct FnInfo {
|
||||
name: String,
|
||||
args: Vec<ParameterDeclaration>,
|
||||
body: Statement,
|
||||
pub name: String,
|
||||
pub args: Vec<ParameterDeclaration>,
|
||||
pub body: Statement,
|
||||
}
|
||||
|
||||
impl FnInfo {
|
||||
|
||||
@@ -92,29 +92,35 @@ impl CGen {
|
||||
Self { source, tu, mode }
|
||||
}
|
||||
|
||||
fn gen_stmt(&mut self, stmt: Statement) {
|
||||
// fn gen_expr(&self, ) {
|
||||
|
||||
// }
|
||||
|
||||
fn gen_stmt(&self, stmt: Statement) {
|
||||
match stmt {
|
||||
Statement::Compound(nodes) => {
|
||||
for node in nodes {
|
||||
match node.node {
|
||||
BlockItem::Declaration(decl) => {
|
||||
_ => panic!("Declaration not supported yet"),
|
||||
}
|
||||
BlockItem::Declaration(_decl) => unimplemented!("Declaration not supported yet"),
|
||||
BlockItem::Statement(stmt) => {
|
||||
self.gen_stmt(stmt.node);
|
||||
}
|
||||
BlockItem::StaticAssert(sa) => {
|
||||
_ => panic!("Static Assert not supported yet"),
|
||||
}
|
||||
BlockItem::StaticAssert(_sa) => unimplemented!("Static Assert not supported yet"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Statement::Return(ret) => {
|
||||
// Return is Optional type here
|
||||
println!("{:#?}", ret);
|
||||
// self.gen_expr(ret);
|
||||
}
|
||||
Statement::Expression(expr) => {
|
||||
}
|
||||
_ => unimplemented!("Statement {:#?} hasn't been implemented", stmt),
|
||||
}
|
||||
}
|
||||
|
||||
fn gen(&mut self) {
|
||||
fn gen(&self) {
|
||||
let TranslationUnit(nodes) = &self.tu;
|
||||
for n in nodes.iter() {
|
||||
match n.node {
|
||||
@@ -123,6 +129,7 @@ impl CGen {
|
||||
}
|
||||
ExternalDeclaration::FunctionDefinition(ref fn_def) => {
|
||||
let fn_info = ast_utils::get_fn_info(&fn_def.node);
|
||||
self.gen_stmt(fn_info.body.clone());
|
||||
println!("{}", fn_info);
|
||||
}
|
||||
_ => panic!("Haven't implemented node: {:?}", n.node),
|
||||
|
||||
Reference in New Issue
Block a user