1# 2# Copyright (C) 2006 Holger Hans Peter Freyther 3# 4# SPDX-License-Identifier: GPL-2.0-only 5# 6 7from bb.utils import better_compile, better_exec 8 9def insert_method(modulename, code, fn, lineno): 10 """ 11 Add code of a module should be added. The methods 12 will be simply added, no checking will be done 13 """ 14 comp = better_compile(code, modulename, fn, lineno=lineno) 15 better_exec(comp, None, code, fn) 16 17compilecache = {} 18 19def compile_cache(code): 20 h = hash(code) 21 if h in compilecache: 22 return compilecache[h] 23 return None 24 25def compile_cache_add(code, compileobj): 26 h = hash(code) 27 compilecache[h] = compileobj 28