| 164 | // variable lookup with all the rules |
| 165 | |
| 166 | Module * getCurrentSearchModule(Program * program, Function * func, const char * _moduleName) { |
| 167 | string moduleName = _moduleName ? _moduleName : ""; |
| 168 | if ( moduleName=="_" ) { |
| 169 | moduleName = "*"; |
| 170 | return program->thisModule.get(); |
| 171 | } else if ( moduleName=="__" ) { |
| 172 | moduleName = program->thisModule->name; |
| 173 | return program->thisModule.get(); |
| 174 | } else if ( func ) { |
| 175 | if ( func->fromGeneric ) { |
| 176 | auto origin = func->getOrigin(); |
| 177 | if ( moduleName.empty() ) { // ::foo in generic means generic::goo, not this::foo |
| 178 | moduleName = origin->module->name; |
| 179 | } |
| 180 | return origin->module; |
| 181 | } else { |
| 182 | return func->module; |
| 183 | } |
| 184 | } else { |
| 185 | return program->thisModule.get(); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | bool canAccessGlobalVariable ( const VariablePtr & pVar, Module * mod, Module * thisMod ) { |
| 190 | if ( !pVar->private_variable ) { |
no test coverage detected