#include "ink.h"
|
|
|
|
int main(int argc, char** argv) {
|
|
struct context* ctx;
|
|
ctx = ink_make_default_context();
|
|
|
|
ink_compile(
|
|
ctx,
|
|
"macro five do 1 1 1 1 1 + + + + end"
|
|
);
|
|
|
|
ink_compile(
|
|
ctx,
|
|
"macro tens do five five + end"
|
|
);
|
|
|
|
ink_compile(
|
|
ctx,
|
|
"macro hundreds do tens tens tens tens tens tens tens tens tens tens + + + + + + + + + end"
|
|
);
|
|
|
|
ink_compile(
|
|
ctx,
|
|
"macro thousand do hundreds hundreds hundreds hundreds hundreds hundreds hundreds hundreds hundreds hundreds + + + + + + + + + end"
|
|
);
|
|
|
|
int coro = ink_compile(
|
|
ctx,
|
|
"thousand thousand * thousand / thousand thousand * thousand / thousand / * print_int"
|
|
);
|
|
|
|
ctx->routines[coro].panic = 0;
|
|
|
|
int increment = 1 << 16;
|
|
int counter = increment;
|
|
int c;
|
|
|
|
while(ink_can_run(ctx)) {
|
|
for(c = 0; c < 16; ++c)
|
|
ink_step_everyone(ctx);
|
|
|
|
|
|
if(ctx->steps < counter) {
|
|
ink_gc(ctx);
|
|
counter += increment;
|
|
}
|
|
}
|
|
|
|
return (ctx->routines[coro].panic != INK_ROUTINE_SUCCESS && ctx->routines[coro].panic != INK_ROUTINE_CAN_REUSE) || ctx->steps > 1000;
|
|
}
|