Mercurial > python-compiler.rs
comparison src/ast_type.rs @ 3:326d7f2a94d4
Remove useless abstraction of function name as Expr.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 31 May 2016 02:36:24 +0100 |
parents | 5fc7c2790d8c |
children | f27a4aee9dfa |
comparison
equal
deleted
inserted
replaced
2:5fc7c2790d8c | 3:326d7f2a94d4 |
---|---|
42 fn visit_statement(&mut self, statement: Statement) -> Type { | 42 fn visit_statement(&mut self, statement: Statement) -> Type { |
43 match statement { | 43 match statement { |
44 Statement::ClassDef(name, classes, body) => { | 44 Statement::ClassDef(name, classes, body) => { |
45 Type::Bottom | 45 Type::Bottom |
46 }, | 46 }, |
47 Statement::FunctionDef(Expr::Name(name), arguments, body) => { | 47 Statement::FunctionDef(name, arguments, body) => { |
48 let mut env = self.environment.pop().unwrap(); | 48 let mut env = self.environment.pop().unwrap(); |
49 self.environment.push(env.clone()); | 49 self.environment.push(env.clone()); |
50 | 50 |
51 let nb_args = arguments.len(); | 51 let nb_args = arguments.len(); |
52 for expr in arguments { | 52 for expr in arguments { |
68 for _ in 0..nb_args { | 68 for _ in 0..nb_args { |
69 self.next_id += 1; | 69 self.next_id += 1; |
70 types.push(Type::Top(self.next_id)); | 70 types.push(Type::Top(self.next_id)); |
71 } | 71 } |
72 Type::Bottom | 72 Type::Bottom |
73 }, | |
74 Statement::FunctionDef(_, _, _) => { | |
75 println!("Statement:FunctionDef Error"); | |
76 panic!() | |
77 }, | 73 }, |
78 Statement::Global(_) => { | 74 Statement::Global(_) => { |
79 Type::Bottom | 75 Type::Bottom |
80 }, | 76 }, |
81 Statement::If(test, body, orelse) => { | 77 Statement::If(test, body, orelse) => { |