Fix linker type-replacement for imported functions
This commit is contained in:
parent
1dd4bbbb05
commit
0ee9d3bf7d
@ -2,5 +2,8 @@ import triple_import_vec2::Vec2;
|
|||||||
|
|
||||||
struct Ship {
|
struct Ship {
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
velocity: Vec2,
|
}
|
||||||
}
|
|
||||||
|
impl Ship {
|
||||||
|
pub fn foo(&self, vec: Vec2) {}
|
||||||
|
}
|
@ -543,14 +543,14 @@ impl<'map> Pass for LinkerPass<'map> {
|
|||||||
function: &mut FunctionDefinition,
|
function: &mut FunctionDefinition,
|
||||||
state: PassState<Self::Data, Self::TError>,
|
state: PassState<Self::Data, Self::TError>,
|
||||||
) -> PassResult {
|
) -> PassResult {
|
||||||
if matches!(function.kind, FunctionDefinitionKind::Local(_, _)) {
|
let mod_id = state.scope.module_id.unwrap();
|
||||||
let mod_id = state.scope.module_id.unwrap();
|
let foreign_types = &state.scope.data.foreign_types.get(&mod_id);
|
||||||
let foreign_types = &state.scope.data.foreign_types.get(&mod_id);
|
if let Some(foreign_types) = foreign_types {
|
||||||
if let Some(foreign_types) = foreign_types {
|
dbg!(state.scope.module_id, foreign_types, &function.parameters);
|
||||||
function.return_type = function.return_type.update_imported(*foreign_types);
|
function.return_type = function.return_type.update_imported(*foreign_types);
|
||||||
for param in function.parameters.iter_mut() {
|
for param in function.parameters.iter_mut() {
|
||||||
param.ty = param.ty.update_imported(foreign_types);
|
param.ty = param.ty.update_imported(foreign_types);
|
||||||
}
|
dbg!(¶m.ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -585,8 +585,9 @@ impl<'map> Pass for LinkerPass<'map> {
|
|||||||
super::ExprKind::Borrow(..) => {}
|
super::ExprKind::Borrow(..) => {}
|
||||||
super::ExprKind::Deref(..) => {}
|
super::ExprKind::Deref(..) => {}
|
||||||
super::ExprKind::CastTo(_, type_kind) => *type_kind = type_kind.update_imported(foreign_types),
|
super::ExprKind::CastTo(_, type_kind) => *type_kind = type_kind.update_imported(foreign_types),
|
||||||
super::ExprKind::AssociatedFunctionCall(type_kind, _) => {
|
super::ExprKind::AssociatedFunctionCall(type_kind, fn_call) => {
|
||||||
*type_kind = type_kind.update_imported(foreign_types)
|
*type_kind = type_kind.update_imported(foreign_types);
|
||||||
|
fn_call.return_type = fn_call.return_type.update_imported(foreign_types);
|
||||||
}
|
}
|
||||||
super::ExprKind::Struct(key, _) => {
|
super::ExprKind::Struct(key, _) => {
|
||||||
*key = if let Some(mod_id) = foreign_types.get(&key) {
|
*key = if let Some(mod_id) = foreign_types.get(&key) {
|
||||||
|
Loading…
Reference in New Issue
Block a user