mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Fix #56
This commit is contained in:
parent
842fe10353
commit
53f665355b
2 changed files with 2 additions and 19 deletions
|
@ -53,7 +53,6 @@ pub enum CodeObjFlags {
|
||||||
FutureAnnotations = 0x10_0000,
|
FutureAnnotations = 0x10_0000,
|
||||||
// Erg-specific flags
|
// Erg-specific flags
|
||||||
EvmDynParam = 0x1000_0000,
|
EvmDynParam = 0x1000_0000,
|
||||||
EvmDynamic = 0x2000_0000,
|
|
||||||
EvmNoGC = 0x4000_0000,
|
EvmNoGC = 0x4000_0000,
|
||||||
Illegal = 0x0000,
|
Illegal = 0x0000,
|
||||||
}
|
}
|
||||||
|
@ -82,7 +81,6 @@ impl From<u32> for CodeObjFlags {
|
||||||
0x10_0000 => Self::FutureAnnotations,
|
0x10_0000 => Self::FutureAnnotations,
|
||||||
// EVM flags
|
// EVM flags
|
||||||
0x1000_0000 => Self::EvmDynParam,
|
0x1000_0000 => Self::EvmDynParam,
|
||||||
0x2000_0000 => Self::EvmDynamic,
|
|
||||||
0x4000_0000 => Self::EvmNoGC,
|
0x4000_0000 => Self::EvmNoGC,
|
||||||
_ => Self::Illegal,
|
_ => Self::Illegal,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! コンパイラーを定義する
|
//! コンパイラーを定義する
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use erg_common::codeobj::{CodeObj, CodeObjFlags};
|
use erg_common::codeobj::CodeObj;
|
||||||
use erg_common::color::{GREEN, RESET};
|
use erg_common::color::{GREEN, RESET};
|
||||||
use erg_common::config::{ErgConfig, Input};
|
use erg_common::config::{ErgConfig, Input};
|
||||||
use erg_common::error::MultiErrorDisplay;
|
use erg_common::error::MultiErrorDisplay;
|
||||||
|
@ -158,26 +158,14 @@ impl Compiler {
|
||||||
|
|
||||||
pub fn compile(&mut self, src: Str, mode: &str) -> Result<CodeObj, CompileErrors> {
|
pub fn compile(&mut self, src: Str, mode: &str) -> Result<CodeObj, CompileErrors> {
|
||||||
log!("{GREEN}[DEBUG] the compiling process has started.{RESET}");
|
log!("{GREEN}[DEBUG] the compiling process has started.{RESET}");
|
||||||
let mut dynamic = true;
|
|
||||||
let mut cfg = self.cfg.copy();
|
let mut cfg = self.cfg.copy();
|
||||||
cfg.input = Input::Str(src);
|
cfg.input = Input::Str(src);
|
||||||
let mut parser = ParserRunner::new(cfg);
|
let mut parser = ParserRunner::new(cfg);
|
||||||
let ast = parser.parse()?;
|
let ast = parser.parse()?;
|
||||||
if ast.is_empty() {
|
|
||||||
return Ok(CodeObj::empty(
|
|
||||||
vec![],
|
|
||||||
Str::rc(self.input().enclosed_name()),
|
|
||||||
"<module>",
|
|
||||||
1,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
let (hir, warns) = self
|
let (hir, warns) = self
|
||||||
.lowerer
|
.lowerer
|
||||||
.lower(ast, mode)
|
.lower(ast, mode)
|
||||||
.map_err(|errs| self.convert(errs))?;
|
.map_err(|errs| self.convert(errs))?;
|
||||||
if warns.is_empty() {
|
|
||||||
dynamic = false;
|
|
||||||
}
|
|
||||||
if self.cfg.verbose >= 2 {
|
if self.cfg.verbose >= 2 {
|
||||||
let warns = self.convert(warns);
|
let warns = self.convert(warns);
|
||||||
warns.fmt_all_stderr();
|
warns.fmt_all_stderr();
|
||||||
|
@ -190,10 +178,7 @@ impl Compiler {
|
||||||
let hir = ownership_checker
|
let hir = ownership_checker
|
||||||
.check(hir)
|
.check(hir)
|
||||||
.map_err(|errs| self.convert(errs))?;
|
.map_err(|errs| self.convert(errs))?;
|
||||||
let mut codeobj = self.code_generator.codegen(hir);
|
let codeobj = self.code_generator.codegen(hir);
|
||||||
if dynamic {
|
|
||||||
codeobj.flags += CodeObjFlags::EvmDynamic as u32;
|
|
||||||
}
|
|
||||||
log!("{GREEN}code object:\n{}", codeobj.code_info());
|
log!("{GREEN}code object:\n{}", codeobj.code_info());
|
||||||
log!(
|
log!(
|
||||||
"[DEBUG] the compiling process has completed, found errors: {}{RESET}",
|
"[DEBUG] the compiling process has completed, found errors: {}{RESET}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue