refactor typing and compilation
This commit is contained in:
parent
e8deab19cc
commit
ba838292f6
8 changed files with 175 additions and 131 deletions
|
|
@ -1,11 +1,10 @@
|
|||
use crate::typing::Type;
|
||||
use std::path::Path;
|
||||
|
||||
pub mod expr;
|
||||
pub mod typed;
|
||||
|
||||
pub use expr::Expr;
|
||||
|
||||
use crate::typing::Type;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum BinaryOperator {
|
||||
// Logic
|
||||
|
|
@ -38,6 +37,19 @@ pub struct ModulePath {
|
|||
components: Vec<String>,
|
||||
}
|
||||
|
||||
impl ModulePath {
|
||||
pub fn concat(lhs: &ModulePath, rhs: &ModulePath) -> ModulePath {
|
||||
ModulePath {
|
||||
components: Vec::from_iter(
|
||||
lhs.components
|
||||
.iter()
|
||||
.chain(rhs.components.iter())
|
||||
.map(Clone::clone),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ModulePath {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!("{}", self.components.join("::")))
|
||||
|
|
@ -136,6 +148,13 @@ impl Module {
|
|||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn full_func_path(&self, func: usize) -> ModulePath {
|
||||
ModulePath::concat(
|
||||
&self.path,
|
||||
&ModulePath::from(self.functions[func].name.as_str()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue