Function types are encoded by the byte 0x60 followed by the respective vectors of parameter and result types.
Example:
(module
(func $add (param $lhs i32) (result i32)
get_local $lhs)| #[macro_export] | |
| macro_rules! num_enum { | |
| ($name:ident $type:ident [$($keys:tt)*] $impl:ident) => { | |
| impl From<$type> for $name { | |
| fn from(v: $type) -> Self { | |
| match v { | |
| $(x if x == $name::$keys as $type => $name::$keys),*, | |
| _ => panic!("Cannot convert {}", v) | |
| } | |
| } |
| use std::cell::RefCell; | |
| use std::collections::HashMap; | |
| use std::rc::Rc; | |
| use glutin_window::GlutinWindow as Window; | |
| use graphics::{clear, Transformed}; | |
| use graphics::Context; | |
| use image::{ImageBuffer, Rgba}; | |
| use opengl_graphics::{GlGraphics, GlyphCache, OpenGL, Texture, TextureSettings}; | |
| use piston::{Button, PressEvent}; | |
| use piston::event_loop::{Events, EventSettings}; |
| use std::thread; | |
| use std::time::Duration; | |
| use std::collections::LinkedList; | |
| extern crate num_cpus; | |
| fn main() { | |
| let num = num_cpus::get(); | |
| let mut handles = LinkedList::new(); |
| buildHuffmanTree(charData) { | |
| //Sort by lowest frequency | |
| let cmp = (a, b) => { | |
| if(a.fre < b.fre) { | |
| return -1; | |
| } | |
| return 1; | |
| }; | |
| //initially sorted list of nodes | |
| let data = charData |
| var cest, | |
| pest = math.ones(2), | |
| mea, | |
| kg, | |
| eest = math.ones(2), | |
| emea = math.ones(2); | |
| function kalman(m){ | |
| mea = m; |
| sigmoid(x, c1 = 1, c2 = 0) { | |
| return 1 / (1 + Math.pow(Math.E, -((c1 * x) - c2))); | |
| } | |
| derivative(x) { | |
| let sig = this.sigmoid(x); | |
| return sig * (1 - sig); | |
| } | |
| cost(X, y) { |
| epoch(d){ | |
| //keep track of how many times we go through the dataset | |
| this.ni++; | |
| //Shuffle our data first | |
| let data = this.shuffle(d); | |
| const N = data.length; | |
| for(let i = 0; i < N; i ++){ | |
| const x = data[i][0]; | |
| const y = data[i][1]; |
| epoch(data){ | |
| //keep track of how many times we go through the dataset | |
| this.ni++; | |
| const N = data.length; | |
| let bGrad = 0; | |
| let mGrad = 0; | |
| for(let i = 0; i < N; i ++){ | |
| const x = data[i][0]; | |
| const y = data[i][1]; | |
| const diff = (y - this.line(x)); |
| function NeuralNetwork(){ | |
| this.inputLayerSize = 2; | |
| this.outputLayerSize = 1; | |
| this.hiddenLayerSize = 3; | |
| this.W1 = math.randomInt([this.inputLayerSize, this.hiddenLayerSize]) | |
| .map(function(row){ | |
| return row.map(function(el){ return Math.random(); }); | |
| }); | |
| this.W2 = math.randomInt([this.hiddenLayerSize, this.outputLayerSize]) | |
| .map(function(row){ |