mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-21 20:18:09 +03:00
fix import-related issues with tgc
This commit is contained in:
parent
4f13716e5b
commit
7d074f368d
@ -86,8 +86,18 @@ fn run_with_args(opt: Opt) -> Result<(), Box<dyn Error>> {
|
||||
fs::create_dir_all(target.clone())?;
|
||||
}
|
||||
|
||||
let cwd = config
|
||||
.extra
|
||||
.get("cwd")
|
||||
.map(|val| {
|
||||
let mut cwd = PathBuf::from(path);
|
||||
cwd.pop();
|
||||
cwd.join(&val.as_str().unwrap())
|
||||
})
|
||||
.unwrap_or(PathBuf::from(path));
|
||||
|
||||
// Write all files into the directory.
|
||||
let (initial, canonicalized, _type_inferenced) = generate_asts(path, text)?;
|
||||
let (initial, canonicalized, _type_inferenced) = generate_asts(cwd, text)?;
|
||||
|
||||
target.push("initial_ast.json");
|
||||
fs::write(target.clone(), initial)?;
|
||||
@ -102,18 +112,14 @@ fn run_with_args(opt: Opt) -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
/// Do what Compiler does - prepare 3 stages of AST: initial, canonicalized and type_inferenced
|
||||
fn generate_asts(path: &String, text: &String) -> Result<(String, String, String), Box<dyn Error>> {
|
||||
let mut ast = leo_parser::parse_ast(path, text)?;
|
||||
fn generate_asts(path: PathBuf, text: &String) -> Result<(String, String, String), Box<dyn Error>> {
|
||||
let mut ast = leo_parser::parse_ast(path.clone().into_os_string().into_string().unwrap(), text)?;
|
||||
let initial = ast.to_json_string()?;
|
||||
|
||||
ast.canonicalize()?;
|
||||
let canonicalized = ast.to_json_string()?;
|
||||
|
||||
let asg = Asg::new(
|
||||
thread_leaked_context(),
|
||||
&ast,
|
||||
&mut ImportParser::new(PathBuf::from(path)),
|
||||
)?;
|
||||
let asg = Asg::new(thread_leaked_context(), &ast, &mut ImportParser::new(path))?;
|
||||
|
||||
let type_inferenced = TypeInferencePhase::default()
|
||||
.phase_ast(&ast.into_repr(), &asg.clone().into_repr())
|
||||
|
Loading…
Reference in New Issue
Block a user