mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
idk
This commit is contained in:
parent
81de426f39
commit
4abbd3ca76
3 changed files with 133 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -33,6 +33,7 @@ name = "analysis"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
|
"indexmap",
|
||||||
"lasso",
|
"lasso",
|
||||||
"parser",
|
"parser",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bumpalo = "3.10.0"
|
bumpalo = "3.10.0"
|
||||||
|
indexmap = "1.9.1"
|
||||||
lasso = "0.6.0"
|
lasso = "0.6.0"
|
||||||
parser = { path = "../parser" }
|
parser = { path = "../parser" }
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use indexmap::IndexMap;
|
||||||
use lasso::Spur;
|
use lasso::Spur;
|
||||||
use parser::Spanned;
|
use parser::Spanned;
|
||||||
|
|
||||||
|
|
@ -9,8 +10,138 @@ pub struct Hir<'hir> {
|
||||||
x: &'hir (),
|
x: &'hir (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct HirId(u32);
|
||||||
|
pub struct DefId(HirId);
|
||||||
|
|
||||||
|
pub enum IntTySignedness {
|
||||||
|
Signed,
|
||||||
|
Unsigned,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for IntTySignedness {
|
||||||
|
fn default() -> Self {
|
||||||
|
// C defaults to unsigned for integers.
|
||||||
|
Self::Signed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum IntTyKind {
|
||||||
|
Short,
|
||||||
|
Int,
|
||||||
|
Long,
|
||||||
|
LongLong,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct IntTy {
|
||||||
|
pub sign: IntTySignedness,
|
||||||
|
pub kind: IntTyKind,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct UnionTy {
|
||||||
|
variants: IndexMap<Symbol, Ty>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct StructTy {
|
||||||
|
fields: IndexMap<Symbol, Ty>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EnumTy {
|
||||||
|
variants: IndexMap<Symbol, i128>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum TyKind {
|
||||||
|
Void,
|
||||||
|
Char,
|
||||||
|
SChar,
|
||||||
|
UChar,
|
||||||
|
Integer(IntTy),
|
||||||
|
Float,
|
||||||
|
Double,
|
||||||
|
LongDouble,
|
||||||
|
Bool,
|
||||||
|
Union(UnionTy),
|
||||||
|
Struct(StructTy),
|
||||||
|
Enum(EnumTy),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Ty {
|
||||||
|
def_id: DefId,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Node {
|
||||||
|
id: HirId,
|
||||||
|
kind: NodeKind,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum NodeKind {
|
||||||
|
FunctionDef(FunctionDef),
|
||||||
|
}
|
||||||
|
|
||||||
pub struct ExternalDecl;
|
pub struct ExternalDecl;
|
||||||
|
|
||||||
pub struct FunctionDef {
|
pub struct FunctionDef {
|
||||||
|
name: Symbol,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Expr<'hir> {
|
||||||
|
kind: ExprKind<'hir>,
|
||||||
|
ty: Ty,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ExprKind<'hir> {
|
||||||
|
Var(DefId),
|
||||||
|
Binary(BinaryOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
|
||||||
|
Unary(UnaryOp, &'hir Expr<'hir>),
|
||||||
|
Cast(CastExpr<'hir>),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CastExpr<'hir> {
|
||||||
|
from: Ty,
|
||||||
|
to: Ty,
|
||||||
|
expr: &'hir Expr<'hir>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum UnaryOp {
|
||||||
|
AddrOf,
|
||||||
|
Deref,
|
||||||
|
Plus,
|
||||||
|
Minus,
|
||||||
|
Tilde,
|
||||||
|
Bang,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ArithOpKind {
|
||||||
|
Mul,
|
||||||
|
Div,
|
||||||
|
Mod,
|
||||||
|
Add,
|
||||||
|
Sub,
|
||||||
|
Shl,
|
||||||
|
Shr,
|
||||||
|
BitAnd,
|
||||||
|
BitXor,
|
||||||
|
BitOr,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ComparisonKind {
|
||||||
|
Lt,
|
||||||
|
Gt,
|
||||||
|
LtEq,
|
||||||
|
GtEq,
|
||||||
|
Eq,
|
||||||
|
Neq,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum BinaryOp {
|
||||||
|
Arith(ArithOpKind),
|
||||||
|
LogicalAnd,
|
||||||
|
LogicalOr,
|
||||||
|
Comparison(ComparisonKind),
|
||||||
|
Comma,
|
||||||
|
Index, // lhs[rhs]
|
||||||
|
Assign(Option<ArithOpKind>),
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue