Skip to content

Commit 7884755

Browse files
coolreader18Centril
authored andcommitted
wip
switch to sats-based deserialization ModuleInstance impl wip
1 parent ad9ad60 commit 7884755

14 files changed

Lines changed: 1230 additions & 18 deletions

File tree

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"tabWidth": 4,
3+
"useTabs": false,
4+
"semi": true,
5+
"singleQuote": true,
6+
"arrowParens": "avoid",
7+
"jsxSingleQuote": false,
8+
"trailingComma": "es5",
9+
"endOfLine": "auto",
10+
"printWidth": 100
11+
}

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ termcolor = "1.2.0"
262262
thin-vec = "0.2.13"
263263
thiserror = "1.0.37"
264264
tokio = { version = "1.37", features = ["full"] }
265-
tokio_metrics = { version = "0.4.0" }
266265
tokio-postgres = { version = "0.7.8", features = ["with-chrono-0_4"] }
267266
tokio-stream = "0.1.17"
268267
tokio-tungstenite = { version = "0.26.2", features = ["native-tls"] }

crates/core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ jwks.workspace = true
118118
async_cache = "0.3.1"
119119
faststr = "0.2.23"
120120
core_affinity = "0.8"
121+
num-traits = "0.2"
122+
# sourcemap = "9"
121123

122124
[target.'cfg(not(target_env = "msvc"))'.dependencies]
123125
tikv-jemallocator = {workspace = true}

crates/core/src/host/v8/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.js

crates/core/src/host/v8/de.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![allow(dead_code)]
22

3-
use super::error::{exception_already_thrown, ExceptionThrown};
3+
use super::error::{exception_already_thrown, ExceptionThrown, TypeError};
44
use super::from_value::{cast, FromValue};
5+
use super::util::Throwable;
56
use core::fmt;
67
use core::iter::{repeat_n, RepeatN};
78
use core::mem::MaybeUninit;
@@ -55,14 +56,24 @@ pub(super) enum Error<'scope> {
5556
Custom(String),
5657
}
5758

59+
impl Throwable for Error<'_> {
60+
fn throw(self, scope: &mut HandleScope<'_>) -> ExceptionThrown {
61+
match self {
62+
Self::Value(exception) => exception.throw(scope),
63+
Self::Exception(thrown) => thrown,
64+
Self::Custom(msg) => TypeError(msg).throw(scope),
65+
}
66+
}
67+
}
68+
5869
impl de::Error for Error<'_> {
5970
fn custom(msg: impl fmt::Display) -> Self {
6071
Self::Custom(msg.to_string())
6172
}
6273
}
6374

6475
/// Returns a scratch buffer to fill when deserializing strings.
65-
fn scratch_buf<const N: usize>() -> [MaybeUninit<u8>; N] {
76+
pub(super) fn scratch_buf<const N: usize>() -> [MaybeUninit<u8>; N] {
6677
[const { MaybeUninit::uninit() }; N]
6778
}
6879

crates/core/src/host/v8/error.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ impl<M: IntoJsString> IntoException for TypeError<M> {
3434
}
3535
}
3636

37+
/// A type converting into a JS `RangeError` exception.
38+
#[derive(Copy, Clone)]
39+
pub struct RangeError<M>(pub M);
40+
41+
impl<M: IntoJsString> IntoException for RangeError<M> {
42+
fn into_exception<'scope>(self, scope: &mut HandleScope<'scope>) -> Local<'scope, Value> {
43+
let msg = self.0.into_string(scope);
44+
Exception::range_error(scope, msg)
45+
}
46+
}
47+
3748
#[derive(Debug)]
3849
pub(super) struct ExceptionThrown {
3950
_priv: (),

0 commit comments

Comments
 (0)