From a340f32e205f11040c2d55cab409a2f2dfc9d2c6 Mon Sep 17 00:00:00 2001 From: lyon Date: Sun, 30 Jan 2022 21:45:43 +0800 Subject: [PATCH] add info when file no found, change compiling frefix --- tools/pikaCompiler/PyInfo.py | 4 +++- tools/pikaCompiler/src/compiler.rs | 11 +++++++++-- tools/pikaCompiler/src/main.rs | 8 +++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tools/pikaCompiler/PyInfo.py b/tools/pikaCompiler/PyInfo.py index a8135597f..be598d341 100644 --- a/tools/pikaCompiler/PyInfo.py +++ b/tools/pikaCompiler/PyInfo.py @@ -26,9 +26,11 @@ class PyMethod (SysObj): def makeMethodDefine(fp: str): pass + class PyClass(SysObj): obj = PyObj() - PyMethod() + PyMethod() + def setSuper(superClassName: str): pass diff --git a/tools/pikaCompiler/src/compiler.rs b/tools/pikaCompiler/src/compiler.rs index ef4be4d66..af52daa87 100644 --- a/tools/pikaCompiler/src/compiler.rs +++ b/tools/pikaCompiler/src/compiler.rs @@ -55,8 +55,15 @@ impl Compiler { } pub fn analyze_file(mut compiler: Compiler, file_name: String, is_top_pkg: bool) -> Compiler { - println!("analyzing file: {}{}.py", compiler.source_path, file_name); - let mut file = File::open(format!("{}{}.py", compiler.source_path, file_name)).unwrap(); + println!( + "(pikascript) compiling {}{}.py...", + compiler.source_path, file_name + ); + let file = File::open(format!("{}{}.py", compiler.source_path, file_name)); + let mut file = match file { + Ok(file) => file, + Err(_) => panic!("[error]: file: '{}{}.py' no found", compiler.source_path, file_name), + }; /* solve package as top class */ if file_name != "main" && is_top_pkg { let pkg_define = format!("class {}(TinyObj):", &file_name); diff --git a/tools/pikaCompiler/src/main.rs b/tools/pikaCompiler/src/main.rs index 875d7ad5f..1ddb79f93 100644 --- a/tools/pikaCompiler/src/main.rs +++ b/tools/pikaCompiler/src/main.rs @@ -8,15 +8,20 @@ mod object_info; mod py_arg; mod py_type; mod script; +mod version_info; use compiler::*; use std::fs::File; use std::io::prelude::*; +use version_info::*; fn main() { /* new a compiler, sellect to path */ let mut compiler = Compiler::new(String::from(""), String::from("pikascript-api/")); /* analyze file begin with main.py */ compiler = Compiler::analyze_file(compiler, String::from("main"), false); + /* new a version_info object */ + let mut version_info = VersionInfo::new(); + version_info = VersionInfo::analyze_file(version_info, String::from("requestment.txt")); /* write the infomatrion to compiler-info */ let mut compiler_info_file = File::create(format!("{}compiler-info.txt", compiler.dist_path)).unwrap(); @@ -122,7 +127,8 @@ fn main() { f.write("#include \"PikaObj.h\"\n".as_bytes()).unwrap(); f.write("#include \"PikaMain.h\"\n".as_bytes()).unwrap(); f.write("\n".as_bytes()).unwrap(); - f.write("PikaObj * pikaScriptInit(void);\n".as_bytes()).unwrap(); + f.write("PikaObj * pikaScriptInit(void);\n".as_bytes()) + .unwrap(); f.write("\n".as_bytes()).unwrap(); f.write("#endif\n".as_bytes()).unwrap(); }