mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
codegen
This commit is contained in:
parent
f321d0e9e1
commit
ee0b311261
12 changed files with 265 additions and 36 deletions
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct LoweringCx<'cx> {
|
||||
pub struct LoweringCx<'cx> {
|
||||
tys: RefCell<FxHashSet<&'cx TyKind<'cx>>>,
|
||||
layouts: RefCell<FxHashSet<&'cx Layout>>,
|
||||
string_literals: RefCell<FxHashMap<&'cx [u8], DefId>>,
|
||||
|
|
@ -23,7 +23,7 @@ pub(crate) struct LoweringCx<'cx> {
|
|||
}
|
||||
|
||||
impl<'cx> LoweringCx<'cx> {
|
||||
pub(crate) fn new(arena: &'cx bumpalo::Bump) -> Self {
|
||||
pub fn new(arena: &'cx bumpalo::Bump) -> Self {
|
||||
LoweringCx {
|
||||
tys: RefCell::default(),
|
||||
layouts: RefCell::default(),
|
||||
|
|
|
|||
|
|
@ -2,17 +2,18 @@
|
|||
#![warn(rust_2018_idioms)]
|
||||
|
||||
mod ctxt;
|
||||
mod ir;
|
||||
pub mod ir;
|
||||
mod lower;
|
||||
mod ty;
|
||||
pub mod ty;
|
||||
|
||||
pub use ctxt::LoweringCx;
|
||||
pub use lower::lower_translation_unit;
|
||||
use parser::Span;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
msg: String,
|
||||
span: Span,
|
||||
span: Option<Span>,
|
||||
notes: Vec<Note>,
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +27,15 @@ impl Error {
|
|||
pub fn new(msg: impl Into<String>, span: Span) -> Self {
|
||||
Self {
|
||||
msg: msg.into(),
|
||||
span,
|
||||
span: Some(span),
|
||||
notes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_without_span(msg: impl Into<String>) -> Self {
|
||||
Self {
|
||||
msg: msg.into(),
|
||||
span: None,
|
||||
notes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,9 @@ use crate::{
|
|||
type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
|
||||
pub fn lower_translation_unit<'cx>(
|
||||
arena: &'cx bumpalo::Bump,
|
||||
lcx: &mut LoweringCx<'cx>,
|
||||
ast: &ast::TranslationUnit,
|
||||
) -> Result<Ir<'cx>, Error> {
|
||||
let mut lcx = LoweringCx::new(arena);
|
||||
|
||||
let mut ir = Ir {
|
||||
funcs: FxHashMap::default(),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue