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
[package] | |
name = "loop" | |
version = "0.0.1" | |
edition = "2018" | |
[lib] | |
crate-type = [ "cdylib" ] | |
[dependencies] | |
chrono = "0.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
# emcc: `-fwasm-exceptions` and node: `--experimental-wasm-eh` are available but not super well | |
# supported right now, so C++ exceptions will exit the wasm runtime via a JS exception. | |
CXX = em++ | |
LD = emcc | |
CXXFLAGS = -O3 -std=c++20 | |
EMFLAGS = -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ALLOW_MEMORY_GROWTH=1 --no-entry | |
loop.wasm: loop.o |
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 "v8.h" | |
#include "libplatform/libplatform.h" | |
using namespace v8; | |
void GCEpilogueCallback(Isolate* isolate, GCType type, GCCallbackFlags flags) { | |
printf("gc epilogue\n"); | |
isolate->TerminateExecution(); | |
} |
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
// Matrix of any type which holds a value for each position in a room | |
template <typename Type, typename Store, size_t Pack, bool Packed = sizeof(Store) << 3 != Pack> | |
class local_matrix_store_t {}; | |
template <typename Type, typename Store, size_t Pack> | |
class local_matrix_store_t<Type, Store, Pack, false> { | |
protected: | |
std::array<Store, 2500> costs; | |
using reference = Type&; | |
using const_reference = typename std::conditional<std::is_trivial<Type>::value && sizeof(Type) <= sizeof(size_t), Type, const Type&>::type; |
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
marcel@localhost ~/isolated-vm $ g++ thing.cc -std=c++11 | |
thing.cc: In instantiation of 'void MakeThing(Args&& ...) [with Args = {}]': | |
thing.cc:16:12: required from here | |
thing.cc:12:44: error: use of deleted function 'Thing::Thing(const Thing&)' | |
Thing instance(std::forward<Args>(args)...); | |
^ | |
thing.cc:5:2: note: declared here | |
Thing(const Thing&) = delete; | |
^ |
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 <stdint.h> | |
#include <string.h> | |
#define HI(n) ((uint64_t)(n)>>32) | |
#define LO(n) ((uint64_t)(n)&0xffffffff) | |
#define U128(hi,lo) ((my_uint128_t){ .high = hi, .low = lo}) | |
typedef struct { | |
uint64_t high; | |
uint64_t low; |
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
let Long = require('long'); | |
class Long128 { | |
constructor(lo, hi) { | |
this.lo = lo; | |
this.hi = hi; | |
} | |
static mul64(left, right) { | |
let u1 = new Long(left.low, 0, true); |
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
marcel@marcel-2 ~ $ node -v | |
v5.10.1 | |
marcel@marcel-2 ~ $ cat a.js | |
"use strict"; | |
switch (1) { | |
case 2: | |
let foo; | |
} | |
foo.bar; | |
marcel@marcel-2 ~ $ node a.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
getPx('https://s3.amazonaws.com/static.screeps.com/map2/'+ roomName+ '.png', function(err, pixels) { | |
if (err) { | |
throw err; | |
} | |
let kyskip = 50 * 3 * 3 * 4; | |
let kxskip = 3 * 4; | |
for (let yy = 0; yy < 50; ++yy) { | |
for (let xx = 0; xx < 50; ++xx) { | |
let px = pixels.data[xx * kxskip + yy * kyskip] * 0x10000 + pixels.data[xx * kxskip + yy * kyskip + 1] * 0x100 + pixels.data[xx * kxskip + yy * kyskip + 2]; | |
switch (px) { |
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
[...] | |
// Reverse of parseRoomName | |
renderRoomName(room) { | |
if (room[0] === 255) { | |
return 'sim'; | |
} | |
return ( | |
(room[0] < 0 ? 'W'+ (-room[0] - 1) : 'E'+ room[0])+ | |
(room[1] < 0 ? 'N'+ (-room[1] - 1) : 'S'+ room[1]) | |
); |
NewerOlder