Skip to content

Instantly share code, notes, and snippets.

View simonask's full-sized avatar

Simon Ask Ulsnes simonask

View GitHub Profile
/*
My very own setjmp.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
typedef struct Continuation {
void* rip;
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
typedef unsigned char byte;
typedef struct Continuation {
void* rip;
void* rsp;
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#define NOINLINE __attribute__((noinline))
typedef unsigned char byte;
typedef struct Continuation {
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#define NOINLINE __attribute__((noinline))
const size_t CONTINUATION_STACK_SIZE = 8192;
/*
cc === "current continuation"
*/
bar: {
foo()
}
foo: {
foo: [a, b, *rest] {
bar: [*args] {
baz(*rest, *args)
local a, b: *args
}
}
a: 123
foo: {
a: 456
}
foo()
puts(a) // 123 eller 456?
obj.set_instance_var(:@foo, 123)
@foo = 456
obj.instance_eval {
puts @foo #=> 123
}
static int n = 0;
class A {
public:
virtual void foo() {
++n;
}
};
class B : public A {
static int n = 0;
int make(int t) { return t; }
void foo_a() { ++n; }
void foo_b() { ++n; }
void foo_c() { ++n; }
void foo_d() { ++n; }
int foo(int t)