void test_compile_inner() { const char *tokensv[] = { "4" }; unsigned int tokensc = 1; const char *expected_calls[] = { "output_header", "stack_enter", "output_stack_enter", "lex_look_ahead", "lex_advance", "output_term", "lex_look_ahead", "output_statements_complete", "stack_leave", "output_stack_leave", "output_os_return", }; unsigned int count = 11; int expect_termsv[] = { 4 }; unsigned int termsc = 1; ecc_context *ctx = init_fake_context(tokensv, tokensc); compile_inner(ctx); check_expected_calls(ctx, "test_compile_inner", expected_calls, count); check_expected_terms(ctx, "test_compile_inner", expect_termsv, termsc); free_fake_context(ctx); }
combinator compile(unsigned nargs, unsigned const * tree) { unsigned long size = eval_mem(tree); char * mmem = mallocx(size); it = 0; compile_prologue(mmem); it += prologue_size(); for(int i=nodes-1;i>=0 ;--i) { if (tree[i]) { compile_leaf(mmem + it, tree[i]); it += leaf_size(); } else { compile_inner(mmem + it); it += inner_size(); } } compile_epilogue(mmem + it, nargs); return (combinator) mmem; }
void compile(ecc_context *ctx) { ctx->read_file(ctx); compile_inner(ctx); ctx->write_file(ctx); }