refactorize CodeGen name lookup