[Refactoring] TemplateInstance::semantic()

- Remove a goto jump
- Reduce code indent level
- Use ModToStc in TemplateThisParameter resolution
[Refactoring] Add Module::rootImports() and use it in TemplateInstance::needsCodegen()

it would make compilation a little faster so `rootImports` cache the result.
[Refactoring] Remove the hack code introduced in #1760

AST identity issue has been properly fixed in #3383 (fceb16bbf7).
Merge pull request #3945 from 9rnsr/refactor_template

[Refactoring] template.c
Error on escaping slice of local static arrays
Mark if(__ctfe) blocks as SCOPEctfe

Allows e.g. allocating in an if(__ctfe) block in a @nogc function
Skip escape check on CTFE scope