mirror of https://github.com/mtshiba/pylyzer
use `PylyzerStatus`
This commit is contained in:
parent
009eb02d14
commit
eafc5f97fa
|
|
@ -253,7 +253,7 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
|||
[[package]]
|
||||
name = "els"
|
||||
version = "0.1.17"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#99db34b61c925e751a53f03d514131b9c2ea59bb"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#305763f251edb5c535214bbc3d2ff1ad913780d0"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
@ -274,7 +274,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "erg_common"
|
||||
version = "0.6.5"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#99db34b61c925e751a53f03d514131b9c2ea59bb"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#305763f251edb5c535214bbc3d2ff1ad913780d0"
|
||||
dependencies = [
|
||||
"backtrace-on-stack-overflow",
|
||||
"hermit-abi",
|
||||
|
|
@ -285,7 +285,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "erg_compiler"
|
||||
version = "0.6.5"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#99db34b61c925e751a53f03d514131b9c2ea59bb"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#305763f251edb5c535214bbc3d2ff1ad913780d0"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_parser",
|
||||
|
|
@ -294,7 +294,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "erg_parser"
|
||||
version = "0.6.5"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#99db34b61c925e751a53f03d514131b9c2ea59bb"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#305763f251edb5c535214bbc3d2ff1ad913780d0"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"unicode-xid 0.2.4",
|
||||
|
|
@ -349,9 +349,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.27.1"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec"
|
||||
checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use std::io::Write;
|
||||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use erg_common::config::Input;
|
||||
use erg_common::log;
|
||||
use erg_compiler::context::register::PylyzerStatus;
|
||||
use erg_compiler::hir::{Expr, HIR};
|
||||
use erg_compiler::ty::HasType;
|
||||
|
||||
|
|
@ -30,12 +32,19 @@ fn escape_type(typ: String) -> String {
|
|||
typ.replace('%', "Type_")
|
||||
}
|
||||
|
||||
pub fn gen_decl_er(hir: HIR, status: CheckStatus) -> DeclFile {
|
||||
let mut code = if status.is_failed() {
|
||||
"# failed\n".to_string()
|
||||
pub fn gen_decl_er(input: &Input, hir: HIR, status: CheckStatus) -> DeclFile {
|
||||
let timestamp = if let Input::File(file) = input {
|
||||
let metadata = std::fs::metadata(file).unwrap();
|
||||
metadata.modified().unwrap()
|
||||
} else {
|
||||
"# succeed\n".to_string()
|
||||
std::time::SystemTime::now()
|
||||
};
|
||||
let status = PylyzerStatus {
|
||||
succeed: status.is_succeed(),
|
||||
file: input.full_path(),
|
||||
timestamp,
|
||||
};
|
||||
let mut code = format!("{status}\n");
|
||||
for chunk in hir.module.into_iter() {
|
||||
match chunk {
|
||||
Expr::Def(def) => {
|
||||
|
|
@ -60,7 +69,7 @@ pub fn gen_decl_er(hir: HIR, status: CheckStatus) -> DeclFile {
|
|||
}
|
||||
|
||||
pub fn dump_decl_er(input: Input, hir: HIR, status: CheckStatus) {
|
||||
let file = gen_decl_er(hir, status);
|
||||
let file = gen_decl_er(&input, hir, status);
|
||||
let mut path = if let Input::File(path) = input {
|
||||
path
|
||||
} else {
|
||||
|
|
@ -72,7 +81,7 @@ pub fn dump_decl_er(input: Input, hir: HIR, status: CheckStatus) {
|
|||
if !pycache_dir.exists() {
|
||||
std::fs::create_dir(pycache_dir).unwrap();
|
||||
}
|
||||
let f = std::fs::File::create(pycache_dir.join(file.filename)).unwrap();
|
||||
let mut f = std::io::BufWriter::new(f);
|
||||
let f = File::create(pycache_dir.join(file.filename)).unwrap();
|
||||
let mut f = BufWriter::new(f);
|
||||
f.write_all(file.code.as_bytes()).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue