From a8d32a917fd1f5aa591434b7a702e4830df9414f Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 21 Jul 2023 21:40:41 -0700 Subject: [PATCH] lift the inference engine up a level --- src/compiler.rs | 2 +- src/ir.rs | 4 +--- src/lib.rs | 1 + src/repl.rs | 2 +- src/{ir => }/type_infer.rs | 0 src/{ir => }/type_infer/ast.rs | 0 src/{ir => }/type_infer/convert.rs | 2 +- src/{ir => }/type_infer/finalize.rs | 0 src/{ir => }/type_infer/solve.rs | 0 9 files changed, 5 insertions(+), 6 deletions(-) rename src/{ir => }/type_infer.rs (100%) rename src/{ir => }/type_infer/ast.rs (100%) rename src/{ir => }/type_infer/convert.rs (99%) rename src/{ir => }/type_infer/finalize.rs (100%) rename src/{ir => }/type_infer/solve.rs (100%) diff --git a/src/compiler.rs b/src/compiler.rs index 14eae47..b94a200 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -1,5 +1,5 @@ use crate::syntax::Program as Syntax; -use crate::{backend::Backend, ir::TypeInferenceResult}; +use crate::{backend::Backend, type_infer::TypeInferenceResult}; use codespan_reporting::{ diagnostic::Diagnostic, files::SimpleFiles, diff --git a/src/ir.rs b/src/ir.rs index cc006d4..af38b02 100644 --- a/src/ir.rs +++ b/src/ir.rs @@ -12,10 +12,8 @@ //! validating syntax, and then figuring out how to turn it into Cranelift //! and object code. After that point, however, this will be the module to //! come to for analysis and optimization work. -mod ast; +pub mod ast; mod eval; mod strings; -mod type_infer; pub use ast::*; -pub use type_infer::{TypeInferenceError, TypeInferenceResult, TypeInferenceWarning}; diff --git a/src/lib.rs b/src/lib.rs index 3906811..c155075 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,7 @@ pub mod eval; mod examples; pub mod ir; pub mod syntax; +pub mod type_infer; /// Implementation module for the high-level compiler. mod compiler; diff --git a/src/repl.rs b/src/repl.rs index a4e2849..5aa0c9b 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -1,5 +1,5 @@ use crate::backend::{Backend, BackendError}; -use crate::ir::TypeInferenceResult; +use crate::type_infer::TypeInferenceResult; use crate::syntax::{ConstantType, Location, ParserError, Statement}; use codespan_reporting::diagnostic::Diagnostic; use codespan_reporting::files::SimpleFiles; diff --git a/src/ir/type_infer.rs b/src/type_infer.rs similarity index 100% rename from src/ir/type_infer.rs rename to src/type_infer.rs diff --git a/src/ir/type_infer/ast.rs b/src/type_infer/ast.rs similarity index 100% rename from src/ir/type_infer/ast.rs rename to src/type_infer/ast.rs diff --git a/src/ir/type_infer/convert.rs b/src/type_infer/convert.rs similarity index 99% rename from src/ir/type_infer/convert.rs rename to src/type_infer/convert.rs index 8db9753..5806153 100644 --- a/src/ir/type_infer/convert.rs +++ b/src/type_infer/convert.rs @@ -1,7 +1,7 @@ use super::ast as ir; use super::ast::Type; use crate::eval::PrimitiveType; -use crate::ir::type_infer::solve::Constraint; +use crate::type_infer::solve::Constraint; use crate::syntax::{self, ConstantType}; use internment::ArcIntern; use std::collections::HashMap; diff --git a/src/ir/type_infer/finalize.rs b/src/type_infer/finalize.rs similarity index 100% rename from src/ir/type_infer/finalize.rs rename to src/type_infer/finalize.rs diff --git a/src/ir/type_infer/solve.rs b/src/type_infer/solve.rs similarity index 100% rename from src/ir/type_infer/solve.rs rename to src/type_infer/solve.rs