mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 11:16:42 +01:00
some cleanup, add skeleton of zola based website
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "site/themes/juice"]
|
||||||
|
path = site/themes/juice
|
||||||
|
url = https://github.com/huhu/juice
|
||||||
20
site/config.toml
Normal file
20
site/config.toml
Normal file
@@ -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"
|
||||||
11
site/content/_index.md
Normal file
11
site/content/_index.md
Normal file
@@ -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.
|
||||||
1
site/static/v0.1pre1/index.html
Normal file
1
site/static/v0.1pre1/index.html
Normal file
File diff suppressed because one or more lines are too long
15
site/templates/_variables.html
Normal file
15
site/templates/_variables.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
/* Primary theme color */
|
||||||
|
--primary-color: #202024;
|
||||||
|
/* Primary theme text color */
|
||||||
|
--primary-text-color: #808070;
|
||||||
|
/* Primary theme link color */
|
||||||
|
--primary-link-color: #8080a0;
|
||||||
|
/* Secondary color: the background body color */
|
||||||
|
--secondary-color: #e4dfd7;
|
||||||
|
--secondary-text-color: #303030;
|
||||||
|
/* Highlight text color of table of content */
|
||||||
|
--toc-highlight-text-color: #d46e13;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
14
site/templates/index.html
Normal file
14
site/templates/index.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{% extends "juice/templates/index.html" %}
|
||||||
|
{% block hero %}
|
||||||
|
<div>
|
||||||
|
<section>
|
||||||
|
<h1 class="text-center heading-text">A WebAssembly based sizecoding platform</h1>
|
||||||
|
</section>
|
||||||
|
<a href="v0.1pre1">
|
||||||
|
<div class="demonstration-gif" style="width:640px;height:512px;background-color:black"></div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endblock hero %}
|
||||||
|
|
||||||
|
{% block footer %}
|
||||||
|
{% endblock footer %}
|
||||||
1
site/themes/juice
Submodule
1
site/themes/juice
Submodule
Submodule site/themes/juice added at a5eb57d278
@@ -14,34 +14,9 @@ pub fn pack(source: &Path, dest: &Path, version: u32) -> Result<()> {
|
|||||||
let mut source_data = vec![];
|
let mut source_data = vec![];
|
||||||
File::open(source)?.read_to_end(&mut source_data)?;
|
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 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];
|
let mut dest_data = vec![version as u8];
|
||||||
dest_data.extend_from_slice(&result[8..]);
|
dest_data.extend_from_slice(&result[8..]);
|
||||||
File::create(dest)?.write_all(&dest_data)?;
|
File::create(dest)?.write_all(&dest_data)?;
|
||||||
@@ -49,125 +24,6 @@ pub fn pack(source: &Path, dest: &Path, version: u32) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Context {
|
|
||||||
base: BaseModule,
|
|
||||||
module: enc::Module,
|
|
||||||
type_mapping: HashMap<u32, u32>,
|
|
||||||
function_mapping: HashMap<u32, u32>,
|
|
||||||
next_function_index: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_type_section(
|
|
||||||
context: &mut Context,
|
|
||||||
mut reader: wasmparser::TypeSectionReader,
|
|
||||||
) -> Result<bool> {
|
|
||||||
use wasmparser::TypeDef;
|
|
||||||
|
|
||||||
let base_function_types: HashMap<base_module::FunctionType, u32> = 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<ValType> = 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<bool> {
|
|
||||||
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<ValType> {
|
fn to_val_type(type_: &wasmparser::Type) -> Result<ValType> {
|
||||||
use wasmparser::Type::*;
|
use wasmparser::Type::*;
|
||||||
Ok(match *type_ {
|
Ok(match *type_ {
|
||||||
@@ -239,8 +95,6 @@ impl<'a> ParsedModule<'a> {
|
|||||||
other => bail!("Unsupported section: {:?}", other),
|
other => bail!("Unsupported section: {:?}", other),
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg!(consumed);
|
|
||||||
|
|
||||||
offset += consumed;
|
offset += consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user