Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 8, 2023
1 parent 6277fbf commit 5affb03
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use wasmtime_environ::{
GlobalInitializer, InstantiateModule, LoweredIndex, RuntimeImportIndex,
RuntimeInstanceIndex, StaticModuleIndex, Trampoline, TrampolineIndex,
},
fact::{FixedEncoding, Transcode},
EntityIndex, PrimaryMap,
};
use wasmtime_environ::{EntityIndex, PrimaryMap};
use wit_component::StringEncoding;
use wit_parser::abi::{AbiVariant, LiftLower};
use wit_parser::*;
Expand Down Expand Up @@ -355,12 +356,41 @@ impl<'a> Instantiator<'a, '_> {
// for now since it can't be tested and additionally JS doesn't
// support multi-memory which transcoders rely on anyway.
Trampoline::Transcoder {
op: _,
from: _,
from64: _,
to: _,
to64: _,
} => unimplemented!(),
op,
from,
from64,
to,
to64,
} => {
if *from64 || *to64 {
unimplemented!();
}
let create_transcoder = match op {
Transcode::Copy(FixedEncoding::Utf8) => {
self.gen.intrinsic(Intrinsic::CreateUtf8Copier)
}
Transcode::Copy(FixedEncoding::Utf16) => unimplemented!(),
Transcode::Copy(FixedEncoding::Latin1) => unimplemented!(),
Transcode::Latin1ToUtf16 => unimplemented!(),
Transcode::Latin1ToUtf8 => unimplemented!(),
Transcode::Utf16ToCompactProbablyUtf16 => unimplemented!(),
Transcode::Utf16ToCompactUtf16 => unimplemented!(),
Transcode::Utf16ToLatin1 => unimplemented!(),
Transcode::Utf16ToUtf8 => unimplemented!(),
Transcode::Utf8ToCompactUtf16 => unimplemented!(),
Transcode::Utf8ToLatin1 => unimplemented!(),
Transcode::Utf8ToUtf16 => unimplemented!(),
};

// println!("{:?}", signature);
uwriteln!(
self.src.js_init,
"const transcoder{} = {create_transcoder}(memory{}, memory{});",
i.as_u32(),
from.as_u32(),
to.as_u32()
);
}

Trampoline::LowerImport {
index,
Expand Down Expand Up @@ -722,7 +752,7 @@ impl<'a> Instantiator<'a, '_> {
CoreDef::Trampoline(i) => format!("trampoline{}", i.as_u32()),
CoreDef::InstanceFlags(i) => {
format!("instanceFlags{}", i.as_u32())
},
}
}
}

Expand Down

0 comments on commit 5affb03

Please sign in to comment.