Added method vptr condition
This commit is contained in:
@@ -412,13 +412,28 @@ impl ClassProcessedData {
|
|||||||
for method in &self.methods {
|
for method in &self.methods {
|
||||||
match method.item.visibility {
|
match method.item.visibility {
|
||||||
Visibility::Public => {
|
Visibility::Public => {
|
||||||
if method.item.is_override.is_none() {
|
let is_using_self = match method.item.params.0.get(0) {
|
||||||
gen_method_point(&method.item, ctx, cg);
|
Some(VarDecl { name, .. }) => {
|
||||||
}
|
if let Pattern::Path(_, v) = name {
|
||||||
|
v.0.len() == 1 && v.0[0].0 == "self"
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
|
||||||
let mut prefixed = method.clone();
|
if is_using_self {
|
||||||
prefixed.item.name.0.insert_str(0, "__m_");
|
if method.item.is_override.is_none() {
|
||||||
prefixed.gen_rust(ctx, cg);
|
gen_method_point(&method.item, ctx, cg);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut prefixed = method.clone();
|
||||||
|
prefixed.item.name.0.insert_str(0, "__m_");
|
||||||
|
prefixed.gen_rust(ctx, cg);
|
||||||
|
} else {
|
||||||
|
method.gen_rust(ctx, cg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
method.gen_rust(ctx, cg);
|
method.gen_rust(ctx, cg);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub class Animal<T> {
|
|||||||
|
|
||||||
pub class Mammal<T> : Animal<T> {
|
pub class Mammal<T> : Animal<T> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super -> Super::new();
|
super = Super::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args_test(*self, x i32, y *str) {}
|
pub fn args_test(*self, x i32, y *str) {}
|
||||||
@@ -31,7 +31,7 @@ pub class Mammal<T> : Animal<T> {
|
|||||||
|
|
||||||
pub class Dog : Mammal<i32> {
|
pub class Dog : Mammal<i32> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super -> Super::new();
|
super = Super::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub override(Animal<i32>) fn speak(*self) {
|
pub override(Animal<i32>) fn speak(*self) {
|
||||||
|
|||||||
Reference in New Issue
Block a user