ast_t* program_load(const char* path, pass_opt_t* options) { ast_t* program = ast_blank(TK_PROGRAM); ast_scope(program); if(package_load(program, path, options) == NULL) { ast_free(program); return NULL; } if(!program_passes(program, options)) { ast_free(program); return NULL; } return program; }
bool type_passes(ast_t* type, pass_opt_t* options) { ast_t* module = ast_parent(type); ast_t* package = ast_parent(module); frame_push(&options->check, NULL); frame_push(&options->check, package); frame_push(&options->check, module); bool ok = package_passes(type, options); if(ok) ok = program_passes(type, options); frame_pop(&options->check); frame_pop(&options->check); frame_pop(&options->check); return ok; }