diff src/ast_convert.rs @ 69:a73eaf42bea1

Add ast.AsyncDefFunction.
author Bastien Orivel <eijebong@bananium.fr>
date Mon, 13 Jun 2016 17:54:19 +0200
parents c59ad5ccd8a6
children 2c1e2ce41263
line wrap: on
line diff
--- a/src/ast_convert.rs
+++ b/src/ast_convert.rs
@@ -525,6 +525,7 @@ fn parse_statement(py: Python, ast: PyOb
     let ast_type = ast_module.get(py, "AST").unwrap();
     let class_def_type = ast_module.get(py, "ClassDef").unwrap();
     let function_def_type = ast_module.get(py, "FunctionDef").unwrap();
+    let async_function_def_type = ast_module.get(py, "AsyncFunctionDef").unwrap();
     let global_type = ast_module.get(py, "Global").unwrap();
     let nonlocal_type = ast_module.get(py, "Nonlocal").unwrap();
     let assign_type = ast_module.get(py, "Assign").unwrap();
@@ -575,7 +576,7 @@ fn parse_statement(py: Python, ast: PyOb
         let decorator_list = parse_list(py, decorator_list, parse_expr);
 
         stmt::ClassDef(name, bases, keywords, body, decorator_list)
-    } else if is_instance(&ast, &function_def_type) {
+    } else if is_instance(&ast, &function_def_type) || is_instance(&ast, &async_function_def_type) {
         let name = ast.getattr(py, "name").unwrap();
         let args = ast.getattr(py, "args").unwrap();
         let body = ast.getattr(py, "body").unwrap();
@@ -588,7 +589,7 @@ fn parse_statement(py: Python, ast: PyOb
         let decorator_list = parse_list(py, decorator_list, parse_expr);
         let returns = parse_optional_expr(py, returns);
 
-        stmt::FunctionDef(name, args, body, decorator_list, returns)
+        stmt::FunctionDef(name, args, body, decorator_list, returns, is_instance(&ast, &async_function_def_type))
     } else if is_instance(&ast, &global_type) {
         let names = ast.getattr(py, "names").unwrap();
         let names = parse_list(py, names, get_str);