mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add info when file no found, change compiling frefix
This commit is contained in:
parent
60bc061789
commit
a340f32e20
@ -26,9 +26,11 @@ class PyMethod (SysObj):
|
|||||||
def makeMethodDefine(fp: str):
|
def makeMethodDefine(fp: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PyClass(SysObj):
|
class PyClass(SysObj):
|
||||||
obj = PyObj()
|
obj = PyObj()
|
||||||
PyMethod()
|
PyMethod()
|
||||||
|
|
||||||
def setSuper(superClassName: str):
|
def setSuper(superClassName: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -55,8 +55,15 @@ impl Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn analyze_file(mut compiler: Compiler, file_name: String, is_top_pkg: bool) -> 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);
|
println!(
|
||||||
let mut file = File::open(format!("{}{}.py", compiler.source_path, file_name)).unwrap();
|
"(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 */
|
/* solve package as top class */
|
||||||
if file_name != "main" && is_top_pkg {
|
if file_name != "main" && is_top_pkg {
|
||||||
let pkg_define = format!("class {}(TinyObj):", &file_name);
|
let pkg_define = format!("class {}(TinyObj):", &file_name);
|
||||||
|
@ -8,15 +8,20 @@ mod object_info;
|
|||||||
mod py_arg;
|
mod py_arg;
|
||||||
mod py_type;
|
mod py_type;
|
||||||
mod script;
|
mod script;
|
||||||
|
mod version_info;
|
||||||
use compiler::*;
|
use compiler::*;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
use version_info::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
/* new a compiler, sellect to path */
|
/* new a compiler, sellect to path */
|
||||||
let mut compiler = Compiler::new(String::from(""), String::from("pikascript-api/"));
|
let mut compiler = Compiler::new(String::from(""), String::from("pikascript-api/"));
|
||||||
/* analyze file begin with main.py */
|
/* analyze file begin with main.py */
|
||||||
compiler = Compiler::analyze_file(compiler, String::from("main"), false);
|
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 */
|
/* write the infomatrion to compiler-info */
|
||||||
let mut compiler_info_file =
|
let mut compiler_info_file =
|
||||||
File::create(format!("{}compiler-info.txt", compiler.dist_path)).unwrap();
|
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 \"PikaObj.h\"\n".as_bytes()).unwrap();
|
||||||
f.write("#include \"PikaMain.h\"\n".as_bytes()).unwrap();
|
f.write("#include \"PikaMain.h\"\n".as_bytes()).unwrap();
|
||||||
f.write("\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("\n".as_bytes()).unwrap();
|
||||||
f.write("#endif\n".as_bytes()).unwrap();
|
f.write("#endif\n".as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user