mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
things
This commit is contained in:
parent
475a520de3
commit
683f11c997
6 changed files with 111 additions and 13 deletions
|
|
@ -7,5 +7,6 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
bumpalo = "3.10.0"
|
||||
lasso = "0.6.0"
|
||||
parser = { path = "../parser" }
|
||||
rustc-hash = "1.1.0"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
use lasso::Spur;
|
||||
use parser::Spanned;
|
||||
|
||||
pub type Symbol = Spur;
|
||||
|
||||
pub type Ident = Spanned<Symbol>;
|
||||
|
||||
pub struct Hir<'hir> {
|
||||
x: &'hir (),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,46 @@
|
|||
use parser::{
|
||||
ast::{self, Ident},
|
||||
Span,
|
||||
};
|
||||
use parser::{ast, Span};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::hir;
|
||||
use crate::hir::{self, Symbol};
|
||||
|
||||
pub struct LowerCtx<'hir> {
|
||||
hir_symbol_intern: lasso::Rodeo,
|
||||
hir_arena: &'hir bumpalo::Bump,
|
||||
global_symbols: FxHashMap<Ident, &'hir hir::ExternalDecl>,
|
||||
global_symbols: FxHashMap<Symbol, &'hir hir::ExternalDecl>,
|
||||
}
|
||||
|
||||
impl<'hir> LowerCtx<'hir> {
|
||||
pub fn lower_translation_unit(&mut self, unit: &ast::TranslationUnit) -> hir::Hir<'hir> {
|
||||
for decl in unit {}
|
||||
for _decl in unit {}
|
||||
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn lower_decl(&mut self, decl: &ast::ExternalDecl, span: Span) -> hir::ExternalDecl {
|
||||
fn lower_decl(&mut self, decl: &ast::ExternalDecl, _span: Span) -> hir::ExternalDecl {
|
||||
match decl {
|
||||
ast::ExternalDecl::Decl(_) => todo!(),
|
||||
ast::ExternalDecl::FunctionDef(func) => todo!(),
|
||||
ast::ExternalDecl::FunctionDef(_func) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_function_def(&mut self, def: &ast::FunctionDef, span: Span) -> hir::FunctionDef {
|
||||
fn lower_function_def(&mut self, def: &ast::FunctionDef, _span: Span) -> hir::FunctionDef {
|
||||
let decl = def.decl.uwnrap_normal();
|
||||
let (init_declarator, _declarator_span) = decl
|
||||
.init_declarators
|
||||
.get(0)
|
||||
.expect("single init declarator in function definition");
|
||||
let declarator = &init_declarator.declarator;
|
||||
|
||||
let ((name_ident, _name_span), _param_decls) = declarator.decl.unwrap_with_params();
|
||||
|
||||
let name_sym = self.hir_symbol_intern.get_or_intern(name_ident);
|
||||
|
||||
|
||||
if self.global_symbols.contains_key(&name_sym) {
|
||||
panic!("function declarated twice! return this error properly! lol!")
|
||||
}
|
||||
|
||||
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue