continued on register allocator rewrite, slow progress as scoping is
proving to be a challenge
This commit is contained in:
+10
-9
@@ -289,12 +289,7 @@ pub enum Expression {
|
||||
// Post-Semantic Analysis
|
||||
type_id: Option<TypeId>,
|
||||
},
|
||||
Number {
|
||||
value: isize,
|
||||
|
||||
// Post-Semantic Analysis
|
||||
type_id: Option<TypeId>,
|
||||
},
|
||||
Number(Number),
|
||||
StringLiteral(String),
|
||||
CharLiteral(char),
|
||||
ArrayLiteral {
|
||||
@@ -308,6 +303,12 @@ pub enum Expression {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Number {
|
||||
Signed(i32, Option<TypeId>),
|
||||
Unsigned(u32, Option<TypeId>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Call {
|
||||
pub name: Name,
|
||||
@@ -342,9 +343,9 @@ impl Expression {
|
||||
|
||||
pub fn type_id(&self) -> Result<TypeId, CompilerError> {
|
||||
match self {
|
||||
Expression::Number { type_id, .. } => {
|
||||
type_id.clone().ok_or(CompilerError::UnknownType)
|
||||
}
|
||||
Expression::Number(
|
||||
Number::Signed(_, type_id) | Number::Unsigned(_, type_id),
|
||||
) => type_id.clone().ok_or(CompilerError::UnknownType),
|
||||
Expression::StringLiteral(_) => Ok(TypeId::Ptr(Box::new(TypeId::Char))),
|
||||
Expression::CharLiteral(_) => Ok(TypeId::Char),
|
||||
Expression::Call { type_id, .. } => {
|
||||
|
||||
Reference in New Issue
Block a user