got some basics working!

This commit is contained in:
2023-12-27 14:32:00 -08:00
parent 7101b62efb
commit 53a9d081bb
9 changed files with 125 additions and 31 deletions

View File

@@ -43,6 +43,11 @@ pub enum BackendError {
InvalidTypeCast { from: PrimitiveType, to: Type },
#[error("Unknown string constant '{0}")]
UnknownString(ArcIntern<String>),
#[error("Compiler doesn't currently support function arguments")]
NoFunctionArguments {
function_name: String,
argument_name: String,
},
}
impl From<BackendError> for Diagnostic<usize> {
@@ -73,6 +78,13 @@ impl From<BackendError> for Diagnostic<usize> {
),
BackendError::UnknownString(str) => Diagnostic::error()
.with_message(format!("Unknown string found trying to compile: '{}'", str)),
BackendError::NoFunctionArguments {
function_name,
argument_name,
} => Diagnostic::error().with_message(format!(
"Function {} takes a function argument ({}), which is not supported",
function_name, argument_name
)),
}
}
}
@@ -128,6 +140,17 @@ impl PartialEq for BackendError {
BackendError::UnknownString(b) => a == b,
_ => false,
},
BackendError::NoFunctionArguments {
function_name: f1,
argument_name: a1,
} => match other {
BackendError::NoFunctionArguments {
function_name: f2,
argument_name: a2,
} => f1 == f2 && a1 == a2,
_ => false,
},
}
}
}