irgen of ast2
This commit is contained in:
parent
f6b956deee
commit
43c828d96f
4
Makefile
Normal file
4
Makefile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
test:
|
||||||
|
cargo run --bin main -- -i tests/legal/call.sea asm > asm.S
|
||||||
|
clang asm.S -c && clang asm.o -o asm && ./asm; echo $$?
|
149
src/ast2/mod.rs
149
src/ast2/mod.rs
|
@ -4502,10 +4502,15 @@ pub mod ast_gen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod ir_gen {
|
pub mod irgen {
|
||||||
|
|
||||||
|
use super::visitor::AstExt;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{symbol_table::syms2::Symbols, triples::*};
|
use crate::{
|
||||||
|
symbol_table::syms2::Symbols,
|
||||||
|
triples::{self, *},
|
||||||
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
struct IRGen {
|
struct IRGen {
|
||||||
ast: Ast,
|
ast: Ast,
|
||||||
|
@ -4514,5 +4519,143 @@ pub mod ir_gen {
|
||||||
ip: intern::InternPool,
|
ip: intern::InternPool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IRGen {}
|
impl IRGen {
|
||||||
|
fn build(&mut self) {
|
||||||
|
let mut mapping = HashMap::<Index, u32>::new();
|
||||||
|
self.ast.visitor().visit(
|
||||||
|
|ast, scopes, i, tag, data| {
|
||||||
|
// pre
|
||||||
|
match tag {
|
||||||
|
Tag::Root => todo!(),
|
||||||
|
Tag::File => todo!(),
|
||||||
|
Tag::FunctionProto => todo!(),
|
||||||
|
Tag::FunctionDecl => todo!(),
|
||||||
|
Tag::ParameterList => todo!(),
|
||||||
|
Tag::Parameter => todo!(),
|
||||||
|
Tag::Block => todo!(),
|
||||||
|
Tag::BlockTrailingExpr => todo!(),
|
||||||
|
Tag::Constant => todo!(),
|
||||||
|
Tag::ExprStmt => todo!(),
|
||||||
|
Tag::ReturnStmt => todo!(),
|
||||||
|
Tag::ReturnExprStmt => todo!(),
|
||||||
|
Tag::VarDecl => todo!(),
|
||||||
|
Tag::MutVarDecl => todo!(),
|
||||||
|
Tag::VarDeclAssignment => todo!(),
|
||||||
|
Tag::MutVarDeclAssignment => todo!(),
|
||||||
|
Tag::GlobalDecl => todo!(),
|
||||||
|
Tag::StructDecl => todo!(),
|
||||||
|
Tag::FieldDecl => todo!(),
|
||||||
|
Tag::DeclRef => todo!(),
|
||||||
|
Tag::DeclRefUnresolved => todo!(),
|
||||||
|
Tag::InternedType => todo!(),
|
||||||
|
Tag::TypeDeclRef => todo!(),
|
||||||
|
Tag::TypeDeclRefUnresolved => todo!(),
|
||||||
|
Tag::PointerType => todo!(),
|
||||||
|
Tag::ArrayType => todo!(),
|
||||||
|
Tag::CallExpr => todo!(),
|
||||||
|
Tag::FieldAccess => todo!(),
|
||||||
|
Tag::ArgumentList => todo!(),
|
||||||
|
Tag::Argument => todo!(),
|
||||||
|
Tag::NamedArgument => todo!(),
|
||||||
|
Tag::ExplicitCast => todo!(),
|
||||||
|
Tag::Deref => todo!(),
|
||||||
|
Tag::AddressOf => todo!(),
|
||||||
|
Tag::Not => todo!(),
|
||||||
|
Tag::Negate => todo!(),
|
||||||
|
Tag::Or => todo!(),
|
||||||
|
Tag::And => todo!(),
|
||||||
|
Tag::BitOr => todo!(),
|
||||||
|
Tag::BitXOr => todo!(),
|
||||||
|
Tag::BitAnd => todo!(),
|
||||||
|
Tag::Eq => todo!(),
|
||||||
|
Tag::NEq => todo!(),
|
||||||
|
Tag::Lt => todo!(),
|
||||||
|
Tag::Gt => todo!(),
|
||||||
|
Tag::Le => todo!(),
|
||||||
|
Tag::Ge => todo!(),
|
||||||
|
Tag::Shl => todo!(),
|
||||||
|
Tag::Shr => todo!(),
|
||||||
|
Tag::Add => todo!(),
|
||||||
|
Tag::Sub => todo!(),
|
||||||
|
Tag::Mul => todo!(),
|
||||||
|
Tag::Div => todo!(),
|
||||||
|
Tag::Rem => todo!(),
|
||||||
|
Tag::Assign => todo!(),
|
||||||
|
Tag::SubscriptExpr => todo!(),
|
||||||
|
Tag::IfExpr => todo!(),
|
||||||
|
Tag::IfElseExpr => todo!(),
|
||||||
|
Tag::Error => todo!(),
|
||||||
|
Tag::Undefined => todo!(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|ast, scopes, i, tag, data| {
|
||||||
|
// post
|
||||||
|
match tag {
|
||||||
|
Tag::Root => todo!(),
|
||||||
|
Tag::File => todo!(),
|
||||||
|
Tag::FunctionProto => todo!(),
|
||||||
|
Tag::FunctionDecl => {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
Tag::ParameterList => todo!(),
|
||||||
|
Tag::Parameter => todo!(),
|
||||||
|
Tag::Block => todo!(),
|
||||||
|
Tag::BlockTrailingExpr => todo!(),
|
||||||
|
Tag::Constant => todo!(),
|
||||||
|
Tag::ExprStmt => todo!(),
|
||||||
|
Tag::ReturnStmt => todo!(),
|
||||||
|
Tag::ReturnExprStmt => todo!(),
|
||||||
|
Tag::VarDecl => todo!(),
|
||||||
|
Tag::MutVarDecl => todo!(),
|
||||||
|
Tag::VarDeclAssignment => todo!(),
|
||||||
|
Tag::MutVarDeclAssignment => todo!(),
|
||||||
|
Tag::GlobalDecl => todo!(),
|
||||||
|
Tag::StructDecl => todo!(),
|
||||||
|
Tag::FieldDecl => todo!(),
|
||||||
|
Tag::DeclRef => todo!(),
|
||||||
|
Tag::DeclRefUnresolved => todo!(),
|
||||||
|
Tag::InternedType => todo!(),
|
||||||
|
Tag::TypeDeclRef => todo!(),
|
||||||
|
Tag::TypeDeclRefUnresolved => todo!(),
|
||||||
|
Tag::PointerType => todo!(),
|
||||||
|
Tag::ArrayType => todo!(),
|
||||||
|
Tag::CallExpr => todo!(),
|
||||||
|
Tag::FieldAccess => todo!(),
|
||||||
|
Tag::ArgumentList => todo!(),
|
||||||
|
Tag::Argument => todo!(),
|
||||||
|
Tag::NamedArgument => todo!(),
|
||||||
|
Tag::ExplicitCast => todo!(),
|
||||||
|
Tag::Deref => todo!(),
|
||||||
|
Tag::AddressOf => todo!(),
|
||||||
|
Tag::Not => todo!(),
|
||||||
|
Tag::Negate => todo!(),
|
||||||
|
Tag::Or => todo!(),
|
||||||
|
Tag::And => todo!(),
|
||||||
|
Tag::BitOr => todo!(),
|
||||||
|
Tag::BitXOr => todo!(),
|
||||||
|
Tag::BitAnd => todo!(),
|
||||||
|
Tag::Eq => todo!(),
|
||||||
|
Tag::NEq => todo!(),
|
||||||
|
Tag::Lt => todo!(),
|
||||||
|
Tag::Gt => todo!(),
|
||||||
|
Tag::Le => todo!(),
|
||||||
|
Tag::Ge => todo!(),
|
||||||
|
Tag::Shl => todo!(),
|
||||||
|
Tag::Shr => todo!(),
|
||||||
|
Tag::Add => todo!(),
|
||||||
|
Tag::Sub => todo!(),
|
||||||
|
Tag::Mul => todo!(),
|
||||||
|
Tag::Div => todo!(),
|
||||||
|
Tag::Rem => todo!(),
|
||||||
|
Tag::Assign => todo!(),
|
||||||
|
Tag::SubscriptExpr => todo!(),
|
||||||
|
Tag::IfExpr => todo!(),
|
||||||
|
Tag::IfElseExpr => todo!(),
|
||||||
|
Tag::Error => todo!(),
|
||||||
|
Tag::Undefined => todo!(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
6
tests/legal/custom_int.sea
Normal file
6
tests/legal/custom_int.sea
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
fn main() -> u32 {
|
||||||
|
let a: u10 = 16u10;
|
||||||
|
let b: u80 = 299;
|
||||||
|
|
||||||
|
return a as u32 + b as u32;
|
||||||
|
}
|
Loading…
Reference in a new issue