void bug_with_is_major_block() { Block block; Term* f = block.compile("def f() {}"); test_assert(is_major_block(nested_contents(f))); // There was a bug where, if the function was patched with a native handler, it // would no longer be considered a major block. install_function(f, my_native_patch); test_assert(is_major_block(nested_contents(f))); }
Block* get_parent_block_major(Block* block) { if (block->owningTerm == NULL) return NULL; if (is_major_block(block)) return NULL; return block->owningTerm->owningBlock; }
Block* find_enclosing_major_block(Block* block) { while (true) { if (block == NULL) return NULL; if (is_major_block(block)) return block; block = get_parent_block(block); } return NULL; }