This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
forked from diem/diem
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
164 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::fs::File; | ||
use std::io::Read; | ||
use anyhow::Error; | ||
use crate::parser::ast::Definition; | ||
use std::borrow::Cow; | ||
|
||
/// Compiler interaction. | ||
pub trait Interact { | ||
/// Returns true if the compiler works on native fs, false otherwise. | ||
fn is_native_fs(&self) -> bool { | ||
true | ||
} | ||
|
||
/// Makes static string. | ||
fn static_str(&mut self, val: String) -> &'static str { | ||
Box::leak(Box::new(val)) | ||
} | ||
/// Gets move file content. | ||
fn file_access(&mut self, name: &'static str) -> Result<String, Error> { | ||
let mut f = File::open(name) | ||
.map_err(|err| std::io::Error::new(err.kind(), format!("{}: {}", err, name)))?; | ||
let mut source_buffer = String::new(); | ||
f.read_to_string(&mut source_buffer)?; | ||
let res = self.preprocess(name, Cow::Owned(source_buffer)); | ||
Ok(res.into_owned()) | ||
} | ||
/// Preprocess source. | ||
fn preprocess<'a>(&mut self, _: &'static str, source: Cow<'a, str>) -> Cow<'a, str> { | ||
source | ||
} | ||
|
||
/// Analyze AST. | ||
fn analyze_ast(&mut self, _: &[Definition]) { | ||
// no-op | ||
} | ||
/// Returns the list of required dependencies. | ||
fn required_dependencies(&mut self) -> Result<Vec<String>, Error> { | ||
Ok(vec![]) | ||
} | ||
} | ||
|
||
impl Interact for () {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.