-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat: add the vfs in 'kclvm-vfs' #1154
Conversation
Signed-off-by: zongz <[email protected]>
@@ -153,6 +155,39 @@ pub fn parse_file_force_errors(filename: &str, code: Option<String>) -> Result<a | |||
} | |||
} | |||
|
|||
pub fn parse_file_with_session_vfs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vfs
here should replace the SourceMap field in ParseSession
, rather than being a separate parameter.
opts: LoadProgramOptions, | ||
missing_pkgs: Vec<String>, | ||
module_cache: Option<KCLModuleCache>, | ||
file_graph: FileGraph, | ||
compile_entries: Entries, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/compile_entries/entries
} | ||
|
||
impl Loader { | ||
fn new_vfs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vfs here should replace the SourceMap field in ParseSession, rather than being a separate parameter and separate function new_vfs
@@ -307,30 +342,67 @@ pub fn load_program( | |||
Loader::new(sess, paths, opts, module_cache).load_main() | |||
} | |||
|
|||
pub fn load_program_vfs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vfs here should replace the SourceMap field in ParseSession, rather than being a separate parameter and a separate function.
@@ -0,0 +1,3 @@ | |||
pub mod entry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest layering the VFS package, placing the general part in compiler_base
, and incorporating KCL specific semantics through extension.
sf_inner: Arc<RwLock<kclvm_span::SourceFile>>, | ||
} | ||
|
||
pub struct SourceMapVfs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming here feels strange, as SourceMap
and VFS
are actually similar concepts and it is not appropriate to juxtapose them.
} | ||
} | ||
|
||
impl VFS for SourceMapVfs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do they appear simultaneously e.g., VFS
and Vfs
. Considering using the same name Vfs
.
|
||
pub trait VFS { | ||
// TODO: More actions to be get SourceFile directly | ||
fn write(&self, path: String, contents: Option<Vec<u8>>) -> Result<()>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering a AsRef<Path>
or AsRef<Utf8Path>
parameter for the path
variable.
Close due to inactive state |
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
re #966
2. What is the scope of this PR (e.g. component or file name):
kclvm-vfs
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: