mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
solve import in main.py as new_package_Obj
This commit is contained in:
parent
4034383f13
commit
cf480c2b85
Binary file not shown.
@ -21,7 +21,7 @@ impl Compiler {
|
||||
};
|
||||
return compiler;
|
||||
}
|
||||
pub fn analyze_main_line(mut compiler: Compiler, line: String) -> Compiler {
|
||||
pub fn analyze_main_line(mut compiler: Compiler, line: &String) -> Compiler {
|
||||
let file_name = "main".to_string();
|
||||
let class_name = "PikaMain".to_string();
|
||||
let class_now = match compiler.class_list.get_mut(&"PikaMain".to_string()) {
|
||||
@ -39,6 +39,9 @@ impl Compiler {
|
||||
if line.starts_with("from ") {
|
||||
return compiler;
|
||||
}
|
||||
if line.starts_with("import ") {
|
||||
return compiler;
|
||||
}
|
||||
class_now.script_list.add(&line);
|
||||
return compiler;
|
||||
}
|
||||
@ -58,6 +61,10 @@ impl Compiler {
|
||||
|
||||
pub fn analyze_line(mut compiler: Compiler, line: String, file_name: &String) -> Compiler {
|
||||
let line = line.replace("\r", "");
|
||||
if file_name == "main" {
|
||||
compiler = Compiler::analyze_main_line(compiler, &line);
|
||||
}
|
||||
|
||||
if line.starts_with("import ") {
|
||||
let tokens: Vec<&str> = line.split(" ").collect();
|
||||
let file = tokens[1];
|
||||
@ -91,10 +98,6 @@ impl Compiler {
|
||||
return compiler;
|
||||
}
|
||||
|
||||
if file_name == "main" {
|
||||
return Compiler::analyze_main_line(compiler, line);
|
||||
}
|
||||
|
||||
if line.starts_with(" ")
|
||||
&& line.contains("(")
|
||||
&& line.contains(")")
|
||||
|
Loading…
x
Reference in New Issue
Block a user