I've been thinking about trying to build something like terra but with javascript as the host language and wasm as the low level thing you metaprogram for. Could be used to just "jit" expensive functions and call them from javascript or to build a fully wasm program but metaprogram it from javascript or whatever inbetween. One of the things I think I need to get that to be nice is to be able to have a struct implementation that can be easily shared between wasm and js.
This file contains 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
#[derive(Clone, Copy)] | |
enum Move { | |
Rock, | |
Paper, | |
Scissors | |
} | |
impl Move { | |
pub fn from(s: &str) -> Move{ | |
use Move::*; |
This file contains 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
fn main() { | |
let input = include_str!("day01_input.txt"); | |
let mut elf_totals = vec![]; | |
let mut total = 0; | |
for line in input.split('\n') { | |
if line == "" { | |
elf_totals.push(total); | |
total = 0; | |
} else { |
This file contains 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
/** | |
* We use the convention of zero as an error term, | |
* since we also use `null_ptr()` to indicate an error. | |
* So for consistency, a zero term is an error in both cases. | |
*/ | |
#define polar_POLAR_FAILURE 0 | |
#define polar_POLAR_SUCCESS 1 | |
typedef struct polar_Polar polar_Polar; |
This file contains 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
BasedOnStyle: LLVM | |
IndentWidth: 4 |
This file contains 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
#include <stdio.h> | |
#include <string.h> | |
typedef char Sudoku[9][9]; | |
typedef struct { | |
Sudoku board; | |
int x; | |
int y; | |
char i; | |
} Choice; |
This file contains 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
include <stdlib.h> | |
#include <stddef.h> | |
#include <assert.h> | |
#include <webassembly.h> | |
typedef uint8_t u8; | |
typedef uint32_t u32; | |
typedef uint64_t u64; | |
typedef int32_t i32; |
This file contains 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
// Collections and helpers for c programming. | |
// Version: 0.1.3 | |
// Shoutouts to @nothings and @pervognsen who I learned / copied most of this from | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <assert.h> |
I hereby claim:
- I am saolsen on github.
- I am saolsen (https://keybase.io/saolsen) on keybase.
- I have a public key ASD9j8N4AtK0fUZlAh1XujYN4d4bSiK7GJ3_RQuP7_pj5wo
To claim this, I am signing this object:
This file contains 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
#include <windows.h> | |
#include <d3d11.h> | |
#include <dxgi1_2.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#define LEN(e) (sizeof(e)/sizeof(e[0])) |