-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm)!: improve and simplify wasm compiler interface (#2976)
- Loading branch information
1 parent
c6f660e
commit 1b5124b
Showing
14 changed files
with
100 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
fn main(x : u64, y : pub u64) { | ||
assert(x < y); | ||
} | ||
} |
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,29 @@ | ||
use js_sys::JsString; | ||
|
||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen(typescript_custom_section)] | ||
const COMPILE_ERROR: &'static str = r#" | ||
export type CompileError = Error; | ||
"#; | ||
|
||
/// `CompileError` is a raw js error. | ||
/// It'd be ideal that `CompileError` was a subclass of `Error`, but for that we'd need to use JS snippets or a js module. | ||
/// Currently JS snippets don't work with a nodejs target. And a module would be too much for just a custom error type. | ||
#[wasm_bindgen] | ||
extern "C" { | ||
#[wasm_bindgen(extends = js_sys::Error, js_name = "CompileError", typescript_type = "CompileError")] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub type JsCompileError; | ||
|
||
#[wasm_bindgen(constructor, js_class = "Error")] | ||
fn constructor(message: JsString) -> JsCompileError; | ||
} | ||
|
||
impl JsCompileError { | ||
/// Creates a new execution error with the given call stack. | ||
/// Call stacks won't be optional in the future, after removing ErrorLocation in ACVM. | ||
pub fn new(message: String) -> Self { | ||
JsCompileError::constructor(JsString::from(message)) | ||
} | ||
} |
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