|
6 | 6 | * https://github.com/micropython/micropython/blob/master/py/compile.c |
7 | 7 | */ |
8 | 8 |
|
9 | | -externcrate rustpython_parser; |
10 | | - |
11 | | -useself::rustpython_parser::{ast, parser}; |
12 | 9 | usesuper::bytecode::{self,CallType,CodeObject,Instruction}; |
13 | 10 | usesuper::pyobject::{PyObject,PyObjectKind,PyResult}; |
14 | 11 | usesuper::vm::VirtualMachine; |
| 12 | +use num_complex::Complex64; |
| 13 | +use rustpython_parser::{ast, parser}; |
15 | 14 |
|
16 | 15 | structCompiler{ |
17 | 16 | code_object_stack:Vec<CodeObject>, |
@@ -846,6 +845,9 @@ impl Compiler { |
846 | 845 | let const_value =match value{ |
847 | 846 | ast::Number::Integer{ value} => bytecode::Constant::Integer{value:*value}, |
848 | 847 | ast::Number::Float{ value} => bytecode::Constant::Float{value:*value}, |
| 848 | + ast::Number::Complex{ real, imag} => bytecode::Constant::Complex{ |
| 849 | +value:Complex64::new(*real,*imag), |
| 850 | +}, |
849 | 851 | }; |
850 | 852 | self.emit(Instruction::LoadConst{value: const_value}); |
851 | 853 | } |
@@ -1301,8 +1303,8 @@ mod tests { |
1301 | 1303 | usesuper::bytecode::CodeObject; |
1302 | 1304 | usesuper::bytecode::Constant::*; |
1303 | 1305 | usesuper::bytecode::Instruction::*; |
1304 | | -usesuper::rustpython_parser::parser; |
1305 | 1306 | usesuper::Compiler; |
| 1307 | +use rustpython_parser::parser; |
1306 | 1308 | fncompile_exec(source:&str) ->CodeObject{ |
1307 | 1309 | letmut compiler =Compiler::new(); |
1308 | 1310 | compiler.push_new_code_object(Option::None,"<module>".to_string()); |
|