def _get_codegen(obj):
 if isinstance(obj, BaseContext):
  return obj.codegen()
 elif isinstance(obj, CodeLibrary):
  return obj.codegen
 elif isinstance(obj, CompileResult):
  return obj.target_context.codegen()
 else:
  raise TypeError(type(obj))

def _get_codegen ( obj ) : if isinstance ( obj , BaseContext ) : return obj . codegen ( ) elif isinstance ( obj , CodeLibrary ) : return obj . codegen elif isinstance ( obj , CompileResult ) : return obj . target_context . codegen ( ) else : raise TypeError ( type ( obj ) )
returns the codegen associated with the given object .