Implicit virtual on override
This commit is contained in:
@@ -16,7 +16,7 @@ pub struct ClassProcessedData {
|
||||
items: Vec<ClassItem>,
|
||||
methods: Vec<Spanned<FunctionDecl>>,
|
||||
v_table: Vec<Identifier>,
|
||||
override_v_table: HashMap<Override, Spanned<Vec<Identifier>>>,
|
||||
override_v_table: HashMap<Override, Spanned<Vec<(Identifier, bool)>>>,
|
||||
}
|
||||
|
||||
impl ClassProcessedData {
|
||||
@@ -64,7 +64,7 @@ impl ClassProcessedData {
|
||||
item: Vec::new(),
|
||||
})
|
||||
.item
|
||||
.push(method.item.name.clone());
|
||||
.push((method.item.name.clone(), method.item.is_virtual));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,13 +191,13 @@ impl ClassProcessedData {
|
||||
.as_ref()
|
||||
.unwrap_or(self.inherits.as_ref().unwrap())
|
||||
.get_rust();
|
||||
for method_ident in &overriden_method_idents.item {
|
||||
for (method_ident, is_virtual) in &overriden_method_idents.item {
|
||||
cg.add_indentedln(&format!(
|
||||
"table[{}::__FN_{}] = {}::__m_{} as *const std::ffi::c_void;",
|
||||
"table[{}::__FN_{}] = {}::{} as *const std::ffi::c_void;",
|
||||
base_class_path,
|
||||
method_ident.0.to_uppercase(),
|
||||
self.self_path.get_rust(),
|
||||
method_ident.get_rust()
|
||||
get_virtual_name(method_ident, *is_virtual)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -618,3 +618,11 @@ pub fn get_type_from_path(path: &ExprPath) -> TypeExpr {
|
||||
path.0.last().unwrap().generics.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_virtual_name(name: &Identifier, is_virtual: bool) -> String {
|
||||
if is_virtual {
|
||||
format!("__m_{}", name.get_rust())
|
||||
} else {
|
||||
name.get_rust()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ pub class Dog : Mammal
|
||||
super = Super::new();
|
||||
}
|
||||
|
||||
pub virtual String speak(&self) override(Animal)
|
||||
pub String speak(&self) override(Animal)
|
||||
{
|
||||
"Woof!".to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user