add info when file no found, change compiling frefix

This commit is contained in:
lyon 2022-01-30 21:45:43 +08:00
parent 60bc061789
commit a340f32e20
3 changed files with 19 additions and 4 deletions

View File

@ -26,9 +26,11 @@ class PyMethod (SysObj):
def makeMethodDefine(fp: str):
pass
class PyClass(SysObj):
obj = PyObj()
PyMethod()
PyMethod()
def setSuper(superClassName: str):
pass

View File

@ -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);

View File

@ -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();
}