diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-28 17:37:24 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-28 17:37:24 +0100 |
| commit | 6b4b3d9d01057c27909bab7675c2ad3ec5e910a9 (patch) | |
| tree | 98c7c53d434ad0010092174172bc10ed17884988 /src/lib.rs | |
| parent | 89bdd138aa5e0843d57fc847cb4026220c06209e (diff) | |
| download | sylt-6b4b3d9d01057c27909bab7675c2ad3ec5e910a9.tar.gz | |
run strings from temporary files
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -47,6 +47,13 @@ pub fn run_file(path: &Path, print: bool, functions: Vec<(String, RustFunction)> run(path, print, functions) } +pub fn run_string(source: &str, print: bool, functions: Vec<(String, RustFunction)>) -> Result<(), Vec<Error>> { + let mut path = std::env::temp_dir(); + path.push(format!("test_{}.sy", rand::random::<u32>())); + std::fs::write(path.clone(), source).expect("Failed to write source to temporary file"); + run(&path, print, functions) +} + fn run(path: &Path, print: bool, functions: Vec<(String, RustFunction)>) -> Result<(), Vec<Error>> { let sections = sectionizer::sectionize(path); match compiler::Compiler::new(sections).compile("main", path, &functions) { |
