Expand description
This crate is part of the Goscript project. Please refer to https://goscript.dev for more information.
It’s a wapper of all the parts of the Goscript project. It also implements the standard library, the standard library part is still under development, only a few parts are implemented.
§Example:
use std::path::{Path, PathBuf};
use go_engine::{Config, ErrorList, SourceReader, run};
fn run_file(path: &str, trace: bool) -> Result<(), ErrorList> {
let mut cfg = Config::default();
cfg.trace_parser = trace;
cfg.trace_checker = trace;
let sr = SourceReader::local_fs(PathBuf::from("../std/"), PathBuf::from("./"));
let result = run(cfg, &sr, Path::new(path), None);
if let Err(el) = &result {
el.sort();
eprint!("{}", el);
}
result
}
§Feature
The project is entended to be enbedded, so it has a lot of feature flags to turn on/off different parts.
read_fs
: Read source code from local file systemread_zip
: Read source code from zip fileasync
: Channel and goroutine supportgo_std
: Enable the Go standard librarybtree_map
: Make it use BTreeMap instead of HashMapcodegen
: Enable codegeninstruction_pos
: Add instruction position to bytecode for debuggingserde_borsh
: Serde support for bytecode using Borshwasm
: Enable wasm support
Modules§
Structs§
- Compound
Fs - Config
- Engine
- Error
List - FileSet
- Import
Key - ImportKey identifies an imported package by import path and source directory (directory containing the file containing the import). In practice, the directory may always be the same, or may not matter. Given an (import path, directory), an importer must always return the same package (but given two different import paths, an importer may still return the same package by mapping them to the same package paths).
- Source
Reader - VfsFs
- VfsMap