Although wordpress reads files of themes to get the theme information to display in the administraion panel, the load of active theme(such as load of theme specific functions) is done only after the name of the current theme is determined.
WordPress stores the name of the active theme in database table wp_options. wp_templating_constants() in wp-settings.php gets that name from “template” option and saves it in the TEMPLATEPATH constant. Then wp-settings.php will load the wodpress theme file “functions.php” in the directory wp-content\themes\TEMPLATEPATH\. In functions.php, you can load as many files of your theme as you wish, or call add_actions, add_filters,…, as done at plugin activation time. Knowing the mechanism wodpress gets active theme name, next time if the active theme is broken, and you even can not login to the administration panel to switch the theme, you can change the active theme in the database manually.