Fix typedefinition in scope
This commit is contained in:
parent
82758ae333
commit
8b79959288
@ -1,8 +1,9 @@
|
|||||||
// Arithmetic, function calls and imports!
|
// Arithmetic, function calls and imports!
|
||||||
|
|
||||||
|
import std::allocate;
|
||||||
|
|
||||||
fn main() -> u8 {
|
fn main() -> u8 {
|
||||||
let mut ptr = malloc(4);
|
let mut ptr = allocate(4);
|
||||||
|
|
||||||
ptr[0] = 5;
|
ptr[0] = 5;
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ impl ast::Module {
|
|||||||
block.into_mir(module_id),
|
block.into_mir(module_id),
|
||||||
(*range).as_meta(module_id),
|
(*range).as_meta(module_id),
|
||||||
),
|
),
|
||||||
|
source: module_id,
|
||||||
};
|
};
|
||||||
functions.push(def);
|
functions.push(def);
|
||||||
}
|
}
|
||||||
@ -70,6 +71,7 @@ impl ast::Module {
|
|||||||
.map(|p| (p.0, p.1 .0.into_mir(module_id)))
|
.map(|p| (p.0, p.1 .0.into_mir(module_id)))
|
||||||
.collect(),
|
.collect(),
|
||||||
kind: mir::FunctionDefinitionKind::Extern(false),
|
kind: mir::FunctionDefinitionKind::Extern(false),
|
||||||
|
source: module_id,
|
||||||
};
|
};
|
||||||
functions.push(def);
|
functions.push(def);
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ impl Display for Metadata {
|
|||||||
|
|
||||||
impl Display for SourceModuleId {
|
impl Display for SourceModuleId {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "Mod {}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ impl Display for TypeKind {
|
|||||||
Display::fmt(len, f)?;
|
Display::fmt(len, f)?;
|
||||||
f.write_char(']')
|
f.write_char(']')
|
||||||
}
|
}
|
||||||
TypeKind::CustomType(CustomTypeKey(name, mod_id)) => write!(f, "{}:{}", mod_id, name),
|
TypeKind::CustomType(CustomTypeKey(name, mod_id)) => write!(f, "{}@{}", name, mod_id),
|
||||||
TypeKind::Borrow(type_kind, false) => {
|
TypeKind::Borrow(type_kind, false) => {
|
||||||
write!(f, "&")?;
|
write!(f, "&")?;
|
||||||
Display::fmt(type_kind, f)
|
Display::fmt(type_kind, f)
|
||||||
|
@ -320,6 +320,7 @@ impl<'map> Pass for LinkerPass<'map> {
|
|||||||
return_type: return_type,
|
return_type: return_type,
|
||||||
parameters: param_tys,
|
parameters: param_tys,
|
||||||
kind: super::FunctionDefinitionKind::Extern(true),
|
kind: super::FunctionDefinitionKind::Extern(true),
|
||||||
|
source: imported_mod_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,7 @@ pub struct FunctionDefinition {
|
|||||||
pub return_type: TypeKind,
|
pub return_type: TypeKind,
|
||||||
pub parameters: Vec<(String, TypeKind)>,
|
pub parameters: Vec<(String, TypeKind)>,
|
||||||
pub kind: FunctionDefinitionKind,
|
pub kind: FunctionDefinitionKind,
|
||||||
|
pub source: SourceModuleId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -295,7 +295,7 @@ impl Module {
|
|||||||
scope
|
scope
|
||||||
.types
|
.types
|
||||||
.set(
|
.set(
|
||||||
CustomTypeKey(typedef.name.clone(), self.module_id),
|
CustomTypeKey(typedef.name.clone(), typedef.source_module),
|
||||||
typedef.clone(),
|
typedef.clone(),
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -322,6 +322,7 @@ impl Expression {
|
|||||||
// Check that the resolved type is at least a struct, no
|
// Check that the resolved type is at least a struct, no
|
||||||
// need for further resolution.
|
// need for further resolution.
|
||||||
let kind = expr_ty.resolve_weak().unwrap();
|
let kind = expr_ty.resolve_weak().unwrap();
|
||||||
|
dbg!(&state.scope);
|
||||||
match kind {
|
match kind {
|
||||||
CustomType(key) => {
|
CustomType(key) => {
|
||||||
let struct_ty = state
|
let struct_ty = state
|
||||||
|
Loading…
Reference in New Issue
Block a user