Add semantic check for variables scopes

Semantic visitor checks for two scopes:
 - global scope: functions only (created on first scan)
 - local scope: modified on every block enter/exit
                all local vars live in this scope