Skip to content

Instantly share code, notes, and snippets.

View pepyakin's full-sized avatar

Sergei Shulepov pepyakin

View GitHub Profile
extern crate parity_wasm;
use std::env;
use std::fmt;
use std::rc::Rc;
use parity_wasm::elements::Module;
use parity_wasm::interpreter::{Error as InterpreterError, HostModule, HostModuleBuilder,
ModuleInstance, UserError};
#[derive(Debug)]
extern crate parity_wasm;
use std::env;
use std::fmt;
use std::rc::Rc;
use parity_wasm::elements::Module;
use parity_wasm::interpreter::{Error as InterpreterError, HostModule, HostModuleBuilder,
ModuleInstance, UserError};
#[derive(Debug)]
extern crate parity_wasm;
use std::env;
use std::fmt;
use std::rc::Rc;
use parity_wasm::elements::Module;
use parity_wasm::interpreter::{
Error as InterpreterError, HostModule, HostModuleBuilder,
ModuleInstance, UserError, HostState, StateKey};
#![feature(prelude_import)]
#![no_std]
// Copyright 2017 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
@pepyakin
pepyakin / macro.rs
Last active January 3, 2018 14:52
cargo expand
struct Resolver;
impl<'a> Data<'a> {
fn resolver() -> Resolver {
Resolver
}
}
impl ImportResolver for Resolver {
fn resolve_func(&self, name: &str, _signature: &FunctionType) -> FuncRef {
if name == "add" {
// #![feature(log_syntax)]
// #![feature(trace_macros)]
// trace_macros!(true);
#[derive(Debug, PartialEq, Eq)]
pub struct FuncInstance;
pub struct MemoryInstance;
/* The Computer Language Benchmarks Game
* http://benchmarksgame.alioth.debian.org/
*
* contributed by Christoph Bauer
*
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
(module
(type $0 (func))
(type $1 (func (param i32)))
(type $2 (func (param i32 i32) (result i32)))
(type $3 (func (param i32 i32 i32 i32) (result i32)))
(type $4 (func (result i32)))
(import "env" "abort" (func $import$0))
(import "env" "exit" (func $import$1 (param i32)))
(table 0 anyfunc)
(memory $0 17)
(module
(type $FUNCSIG$vi (func (param i32)))
(import "env" "exit" (func $exit (param i32)))
(table 0 anyfunc)
(memory $0 17)
(data (i32.const 4) " \00\10\00")
(data (i32.const 12) "\00\00\00\00")
(export "memory" (memory $0))
(export "f" (func $f))
(export "main" (func $main))
a;
struct b h;
struct b {
struct {
struct {
int c
} d
} e
} f(struct b *i) {
for (; a < i->e.d.c; a++) {