Created
June 30, 2023 03:29
-
-
Save stephanos/195b2b5da1fc2481f6055d368d815fc7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let mut component = Component::new(); | |
component.section(&ModuleSection(&module)); | |
let mut names = ComponentNameSection::new(); | |
let mut func_names = NameMap::new(); | |
func_names.append(0, "main"); | |
names.core_funcs(&func_names); | |
names.funcs(&func_names); | |
let mut instance_names = NameMap::new(); | |
instance_names.append(0, "main"); | |
names.core_instances(&instance_names); | |
component.section(&names); | |
let mut types = ComponentTypeSection::new(); | |
let no_params: Vec<(&str, ComponentValType)> = Vec::new(); | |
types | |
.function() | |
.params(no_params) | |
.result(PrimitiveValType::S32); | |
component.section(&types); | |
let mut instances = InstanceSection::new(); | |
let no_args: Vec<(String, ModuleArg)> = Vec::new(); | |
instances.instantiate(0, no_args); | |
component.section(&instances); | |
let mut functions = CanonicalFunctionSection::new(); | |
functions.lift(0, 0, [CanonicalOption::UTF8]); | |
component.section(&functions); | |
let mut exports = ComponentExportSection::new(); | |
let name = ComponentExternName::Kebab("main"); | |
exports.export(name, ComponentExportKind::Func, 0, None); | |
component.section(&exports); | |
return component.finish(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment