goodness gracious it can do integer addition and pointer dereferencing!!!!
This commit is contained in:
parent
00359a306c
commit
f7ec585057
|
@ -322,6 +322,13 @@ impl Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pointee(&self) -> Option<&Type> {
|
||||||
|
match self {
|
||||||
|
Self::Pointer { pointee, .. } => Some(&pointee),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn equal_type(&self, rhs: &Self) -> Option<Type> {
|
pub fn equal_type(&self, rhs: &Self) -> Option<Type> {
|
||||||
match (self, rhs) {
|
match (self, rhs) {
|
||||||
(Self::ComptimeNumber, Self::Floating(_))
|
(Self::ComptimeNumber, Self::Floating(_))
|
||||||
|
|
|
@ -157,3 +157,13 @@ pub trait FallibleParse<I>: Iterator<Item = I> + Clone {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I, T> FallibleParse<I> for T where T: Iterator<Item = I> + Clone {}
|
impl<I, T> FallibleParse<I> for T where T: Iterator<Item = I> + Clone {}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! variant {
|
||||||
|
($value:expr => $pattern:pat) => {
|
||||||
|
let $pattern = $value else { unreachable!() };
|
||||||
|
};
|
||||||
|
($pattern:pat = $value:expr) => {
|
||||||
|
let $pattern = $value else { unreachable!() };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#![allow(unused_macros)]
|
#![allow(unused_macros)]
|
||||||
|
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
pub mod codegen;
|
// pub mod codegen;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod lexer;
|
pub mod lexer;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::{
|
||||||
string_table::{ImmOrIndex, Index, StringTable},
|
string_table::{ImmOrIndex, Index, StringTable},
|
||||||
symbol_table::{SymbolKind, SymbolTable},
|
symbol_table::{SymbolKind, SymbolTable},
|
||||||
tokens::Token,
|
tokens::Token,
|
||||||
|
variant,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
@ -132,23 +133,26 @@ impl Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_decls(&self) -> impl Iterator<Item = (Node, String)> {
|
pub fn global_decls(&self) -> Vec<(Node, String)> {
|
||||||
self.global_decls.iter().map(|decl| {
|
self.global_decls
|
||||||
let name = match self.nodes.get_node(*decl) {
|
.iter()
|
||||||
Tag::FunctionDecl { proto, body } => {
|
.map(|decl| {
|
||||||
let Tag::FunctionProto { name, .. } = self.nodes.get_node(*proto) else {
|
let name = match self.nodes.get_node(*decl) {
|
||||||
unreachable!()
|
Tag::FunctionDecl { proto, .. } => {
|
||||||
};
|
let Tag::FunctionProto { name, .. } = self.nodes.get_node(*proto) else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
self.get_ident_str(*name).unwrap().to_owned()
|
self.get_ident_str(*name).unwrap().to_owned()
|
||||||
}
|
}
|
||||||
Tag::GlobalDecl { name, .. } => self.get_ident_str(*name).unwrap().to_owned(),
|
Tag::GlobalDecl { name, .. } => self.get_ident_str(*name).unwrap().to_owned(),
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(*decl, name)
|
(*decl, name)
|
||||||
})
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
|
|
1243
src/triples.rs
1243
src/triples.rs
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue