Preserve argument names

This commit is contained in:
Caio
2019-03-14 08:46:42 -03:00
parent 90c3196b7b
commit 70f5373348
10 changed files with 97 additions and 14 deletions

View File

@ -165,7 +165,22 @@ fn shared_export<'a>(export: &'a ast::Export, intern: &'a Interner) -> Export<'a
}
fn shared_function<'a>(func: &'a ast::Function, _intern: &'a Interner) -> Function<'a> {
Function { name: &func.name }
let arg_names = func
.arguments
.iter()
.enumerate()
.map(|(idx, arg)| {
if let syn::Pat::Ident(ref x) = arg.pat {
x.ident.to_string()
} else {
format!("arg{}", idx)
}
})
.collect::<Vec<_>>();
Function {
name: &func.name,
arg_names,
}
}
fn shared_enum<'a>(e: &'a ast::Enum, intern: &'a Interner) -> Enum<'a> {
@ -364,6 +379,12 @@ impl<'a> Encode for &'a str {
}
}
impl<'a> Encode for String {
fn encode(&self, dst: &mut Encoder) {
self.as_bytes().encode(dst);
}
}
impl<T: Encode> Encode for Vec<T> {
fn encode(&self, dst: &mut Encoder) {
self.len().encode(dst);