first working code

```
int main() {
    long a = 0;
}
```

codegens correctly.
This commit is contained in:
nora 2023-05-28 18:52:51 +02:00
parent 92243712e7
commit d0be270de2
14 changed files with 235 additions and 160 deletions

View file

@ -138,12 +138,14 @@ pub enum StatementKind {
Store {
ptr: Operand,
value: Operand,
/// Amount of bytes to store.
size: Operand,
align: Operand,
},
Load {
result: Register,
ptr: Operand,
/// Amount of bytes to load.
size: Operand,
align: Operand,
},

View file

@ -8,43 +8,3 @@ pub mod ty;
pub use ctxt::LoweringCx;
pub use lower::lower_translation_unit;
use parser::Span;
#[derive(Debug)]
pub struct Error {
msg: String,
span: Option<Span>,
notes: Vec<Note>,
}
#[derive(Debug)]
struct Note {
msg: String,
span: Option<Span>,
}
impl Error {
pub fn new(msg: impl Into<String>, span: Span) -> Self {
Self {
msg: msg.into(),
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(),
}
}
pub fn note_spanned(mut self, msg: impl Into<String>, span: Span) -> Self {
self.notes.push(Note {
msg: msg.into(),
span: Some(span),
});
self
}
}

View file

@ -3,7 +3,7 @@ mod typeck;
use parser::{
ast::{self, ExprBinary},
Span, Symbol,
Error, Span, Symbol,
};
use rustc_hash::FxHashMap;
@ -15,7 +15,6 @@ use crate::{
VariableInfo, VariableInfoKind,
},
ty::{Ty, TyKind},
Error,
};
type Result<T, E = Error> = std::result::Result<T, E>;

View file

@ -1,14 +1,11 @@
use parser::{
ast::{IntSign, IntTy, IntTyKind},
Span,
Error, Span,
};
use smallvec::{smallvec, SmallVec};
use super::{FnLoweringCtxt, Result};
use crate::{
ty::{Ty, TyKind},
Error,
};
use crate::ty::{Ty, TyKind};
pub(super) type Coercions<'cx> = SmallVec<[(Coercion, Ty<'cx>); 2]>;