Fixed args
This commit is contained in:
@@ -535,11 +535,22 @@ pub fn gen_method_point(method: &FunctionDecl, ctx: &mut Context, cg: &mut RustC
|
||||
method.generics.get_rust(),
|
||||
));
|
||||
|
||||
for (i, param) in method.params.0.iter().enumerate() {
|
||||
if i > 0 {
|
||||
let params = method
|
||||
.params
|
||||
.0
|
||||
.clone()
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(idx, mut v)| {
|
||||
v.name = construct_pattern(&v.name, idx);
|
||||
(idx, v)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for (i, param) in ¶ms {
|
||||
if *i > 0 {
|
||||
cg.add(", ");
|
||||
}
|
||||
|
||||
param.gen_rust(ctx, cg);
|
||||
}
|
||||
|
||||
@@ -570,7 +581,9 @@ pub fn gen_method_point(method: &FunctionDecl, ctx: &mut Context, cg: &mut RustC
|
||||
.filter_map(|v| v.type_)
|
||||
.collect();
|
||||
|
||||
if !param_types.is_empty() {
|
||||
param_types.remove(0);
|
||||
}
|
||||
|
||||
param_types.insert(
|
||||
0,
|
||||
@@ -588,10 +601,20 @@ pub fn gen_method_point(method: &FunctionDecl, ctx: &mut Context, cg: &mut RustC
|
||||
);
|
||||
|
||||
cg.add(&TypeExpr::StaticFn(param_types, method.return_type.clone().map(Box::new)).get_rust());
|
||||
|
||||
cg.addln(" = std::mem::transmute(func_ptr);");
|
||||
|
||||
cg.add_indentedln("func(self._m_oop.1)");
|
||||
cg.add_indented("func(self._m_oop.1");
|
||||
|
||||
for (i, param) in ¶ms {
|
||||
if *i == 0 {
|
||||
continue; // self._m_oop.1 already fulfills it
|
||||
}
|
||||
cg.add(", ");
|
||||
ctx.expr_ensure_semicolon = false;
|
||||
param.name.gen_rust(ctx, cg);
|
||||
}
|
||||
|
||||
cg.addln(");");
|
||||
|
||||
cg.indent -= 1;
|
||||
cg.add_indentedln("}");
|
||||
|
||||
@@ -21,6 +21,8 @@ pub class Mammal<T> : Animal<T> {
|
||||
std::ptr::write(&mut super, Super::new());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn args_test(*self, x i32, y *str) {}
|
||||
}
|
||||
|
||||
pub class Dog : Mammal<i32> {
|
||||
@@ -38,5 +40,7 @@ pub class Dog : Mammal<i32> {
|
||||
pub fn run_tests() {
|
||||
let dawg = Dog::new();
|
||||
|
||||
dawg.args_test(10, "hello");
|
||||
|
||||
dawg.test_speak();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user