2018-02-21 02:31:28 -08:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
2018-11-06 16:47:34 -08:00
|
|
|
use ast::*;
|
2018-11-06 13:44:52 -08:00
|
|
|
|
2018-05-27 02:44:06 -07:00
|
|
|
pub type TypeName = Rc<String>;
|
2018-11-06 13:44:52 -08:00
|
|
|
|
|
|
|
pub struct TypeContext {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-06 16:47:34 -08:00
|
|
|
type TypeResult<T> = Result<T, TypeError>;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
struct TypeError { }
|
|
|
|
|
|
|
|
struct Type {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-06 13:44:52 -08:00
|
|
|
impl TypeContext {
|
|
|
|
pub fn new() -> TypeContext {
|
|
|
|
TypeContext { }
|
|
|
|
}
|
|
|
|
|
2018-11-06 16:47:34 -08:00
|
|
|
pub fn typecheck(&mut self, ast: &AST) -> Result<(), String> {
|
|
|
|
match self.infer_ast(ast) {
|
|
|
|
Ok(_) => Ok(()),
|
|
|
|
Err(err) => Err(format!("Type error: {:?}", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TypeContext {
|
|
|
|
fn infer_ast(&mut self, ast: &AST) -> TypeResult<()> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
|
|
fn basic_inference() {
|
|
|
|
|
2018-11-06 13:44:52 -08:00
|
|
|
}
|
|
|
|
}
|