diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3c79e9c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "site/themes/juice"] + path = site/themes/juice + url = https://github.com/huhu/juice diff --git a/site/config.toml b/site/config.toml new file mode 100644 index 0000000..1f3c07b --- /dev/null +++ b/site/config.toml @@ -0,0 +1,20 @@ +# The URL the site will be built for +base_url = "https://exoticorn.github.io/microw8" + +# Whether to automatically compile all Sass files in the sass directory +compile_sass = true + +# Whether to build a search index to be used later on by a JavaScript library +build_search_index = false + +theme = "juice" + +[markdown] +# Whether to do syntax highlighting +# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola +highlight_code = true + +[extra] +# Put all your custom variables here +juice_logo_name = "MicroW8" +juice_logo_path = "microw8.svg" diff --git a/site/content/_index.md b/site/content/_index.md new file mode 100644 index 0000000..efbbe01 --- /dev/null +++ b/site/content/_index.md @@ -0,0 +1,11 @@ ++++ ++++ + +## Versions + +* [v0.1pre1](v0.1pre1) + +## Examples + +* [Technotunnel](v0.1pre1#AQrDAQHAAQIBfwp9A0AgAUEAsiABQcACb7JDmhkgQ5MiBCAEIASUIAFBwAJtQYABa7IiBSAFlJKRIgaVIgcgByAAskHQD7KVIgIQAEPNzEw/lCIDlCAHIAeUIAOUIAOUQQGykiADIAOUk5GSIgiUIAOTQQqylCACkiIJqCAFIAaVIAiUQQqylCACkiIKqHMgCEEyspQgBpUiCyACkkEUspSocUEFcbJBArIgC5OUQRaylJeoOgB4IAFBAWoiAUGAgAVIDQALCw==) (199 bytes): A port of my [entry](https://tic80.com/play?cart=1873) in the Outline'21 bytebattle quater final +* [XorScroll](v0.1pre1#AQovAS0BAX8DQCABIAFBwAJvIABBCm1qIAFBwAJtczoAeCABQQFqIgFBgIAFSA0ACws=) (50 bytes): A simple scrolling XOR pattern. Fun fact: This is the pre-loaded effect when entering a bytebattle. \ No newline at end of file diff --git a/site/static/v0.1pre1/index.html b/site/static/v0.1pre1/index.html new file mode 100644 index 0000000..101ce92 --- /dev/null +++ b/site/static/v0.1pre1/index.html @@ -0,0 +1 @@ +MicroW8
\ No newline at end of file diff --git a/site/templates/_variables.html b/site/templates/_variables.html new file mode 100644 index 0000000..e61fb1e --- /dev/null +++ b/site/templates/_variables.html @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/site/templates/index.html b/site/templates/index.html new file mode 100644 index 0000000..dcc1c39 --- /dev/null +++ b/site/templates/index.html @@ -0,0 +1,14 @@ +{% extends "juice/templates/index.html" %} +{% block hero %} +
+
+

A WebAssembly based sizecoding platform

+
+ +
+
+
+{% endblock hero %} + +{% block footer %} +{% endblock footer %} \ No newline at end of file diff --git a/site/themes/juice b/site/themes/juice new file mode 160000 index 0000000..a5eb57d --- /dev/null +++ b/site/themes/juice @@ -0,0 +1 @@ +Subproject commit a5eb57d2781eed43301215e27679c0bb7b4cbedf diff --git a/uw8-tool/src/pack.rs b/uw8-tool/src/pack.rs index b45f996..269d75d 100644 --- a/uw8-tool/src/pack.rs +++ b/uw8-tool/src/pack.rs @@ -14,34 +14,9 @@ pub fn pack(source: &Path, dest: &Path, version: u32) -> Result<()> { let mut source_data = vec![]; File::open(source)?.read_to_end(&mut source_data)?; - let parsed_module = dbg!(ParsedModule::parse(&source_data)?); + let parsed_module = ParsedModule::parse(&source_data)?; let result = parsed_module.pack(&base)?; - /* - let module = enc::Module::new(); - - let mut context = Context { - base, - module, - type_mapping: HashMap::new(), - function_mapping: HashMap::new(), - next_function_index: 0, - }; - - for payload in wasmparser::Parser::new(0).parse_all(&source_data) { - let payload = payload?; - - use wasmparser::Payload::*; - - let _copy = match payload { - Version { .. } => false, - TypeSection(reader) => process_type_section(&mut context, reader)?, - ImportSection(reader) => process_import_section(&mut context, reader)?, - _ => true, - }; - } - */ - let mut dest_data = vec![version as u8]; dest_data.extend_from_slice(&result[8..]); File::create(dest)?.write_all(&dest_data)?; @@ -49,125 +24,6 @@ pub fn pack(source: &Path, dest: &Path, version: u32) -> Result<()> { Ok(()) } -struct Context { - base: BaseModule, - module: enc::Module, - type_mapping: HashMap, - function_mapping: HashMap, - next_function_index: u32, -} - -fn process_type_section( - context: &mut Context, - mut reader: wasmparser::TypeSectionReader, -) -> Result { - use wasmparser::TypeDef; - - let base_function_types: HashMap = context - .base - .types - .iter() - .enumerate() - .map(|(i, t)| (t.clone(), i as u32)) - .collect(); - - for src_index in 0..reader.get_count() { - match reader.read()? { - TypeDef::Func(fnc) => { - let params: Vec = to_val_type_vec(&fnc.params)?; - if fnc.returns.len() > 1 { - bail!("Multi-value not yet supported, sorry."); - } - let result = to_val_type_vec(&fnc.returns)?.into_iter().next(); - - let func_type = base_module::FunctionType { params, result }; - if let Some(index) = base_function_types.get(&func_type) { - context.type_mapping.insert(src_index, *index); - } else { - bail!("Function type not found in base: {:?}", func_type); - } - } - TypeDef::Instance(_) | TypeDef::Module(_) => { - bail!("Instance and module types are not supported") - } - } - } - - Ok(false) -} - -fn process_import_section( - context: &mut Context, - mut reader: wasmparser::ImportSectionReader, -) -> Result { - let mut found_memory = false; - - let function_import_map: HashMap<(String, String), (u32, u32)> = context - .base - .function_imports - .iter() - .enumerate() - .map(|(index, (module, name, type_))| { - ((module.to_string(), name.clone()), (*type_, index as u32)) - }) - .collect(); - - for _ in 0..reader.get_count() { - let import = reader.read()?; - if let Some(field) = import.field { - match import.ty { - ImportSectionEntryType::Memory(ref mem) => { - if import.module != "env" || field != "memory" { - bail!("Wrong import name for memory: {}.{}", import.module, field); - } - if mem.memory64 || mem.shared { - bail!("Bad memory options"); - } - if mem.initial > context.base.memory as u64 - || mem.maximum.unwrap_or(0) > context.base.memory as u64 - { - bail!("Import memory too large"); - } - found_memory = true; - } - ImportSectionEntryType::Function(type_) => { - if let Some((base_type, base_index)) = - function_import_map.get(&(import.module.to_string(), field.to_string())) - { - if let Some(type_) = context.type_mapping.get(&type_) { - if type_ == base_type { - context - .function_mapping - .insert(context.next_function_index, *base_index); - context.next_function_index += 1; - } else { - bail!("Import function {}.{} has wrong type", import.module, field); - } - } else { - bail!("Malformed input (Type {} does not exist)", type_); - } - } else { - bail!( - "Import function {}.{} does not exist in base", - import.module, - field - ); - } - } - _ => bail!("Unsupported import type {:?}", import.ty), - } - } else { - bail!("Found import without field: {}", import.module); - } - } - - if !found_memory { - bail!("No memory import found"); - } - - Ok(false) -} - fn to_val_type(type_: &wasmparser::Type) -> Result { use wasmparser::Type::*; Ok(match *type_ { @@ -239,8 +95,6 @@ impl<'a> ParsedModule<'a> { other => bail!("Unsupported section: {:?}", other), } - dbg!(consumed); - offset += consumed; }