| 283 | } |
| 284 | |
| 285 | void GLSLCompiler::translateVariableIdentifier(glsl::astVariableIdentifier *expression) { |
| 286 | glsl::astVariable* vdata = (glsl::astVariable*)expression->variable; |
| 287 | |
| 288 | bool found = false; |
| 289 | |
| 290 | // globals |
| 291 | for (int i = 0; i < m_globals.size(); i++) |
| 292 | if (m_globals[i].Name == vdata->name) { |
| 293 | if (!m_isSet) { |
| 294 | if (m_usePointer) m_gen.Function.GetGlobalPointer(m_globals[i].ID); |
| 295 | else m_gen.Function.GetGlobal(m_globals[i].ID); |
| 296 | } else |
| 297 | m_gen.Function.SetGlobal(m_globals[i].ID); |
| 298 | |
| 299 | found = true; |
| 300 | break; |
| 301 | } |
| 302 | |
| 303 | if (m_currentFunction.size() != 0 && !found) { |
| 304 | // locals |
| 305 | for (int i = 0; i < m_locals[m_currentFunction].size(); i++) { |
| 306 | if (m_locals[m_currentFunction][i] == vdata->name) { |
| 307 | if (!m_isSet) { |
| 308 | if (m_usePointer) m_gen.Function.GetLocalPointer(i); |
| 309 | else m_gen.Function.GetLocal(i); |
| 310 | } else |
| 311 | m_gen.Function.SetLocal(i); |
| 312 | |
| 313 | found = true; |
| 314 | break; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | // arguments |
| 319 | for (int i = 0; i < m_func.size() && !found; i++) { |
| 320 | if (m_func[i].Name != m_currentFunction) |
| 321 | continue; |
| 322 | |
| 323 | for (int j = 0; j < m_func[i].Arguments.size(); j++) { |
| 324 | if (m_func[i].Arguments[j].Name == vdata->name) { |
| 325 | bool isPtr = m_func[i].Arguments[j].Storage == sd::Variable::StorageType::Out; |
| 326 | |
| 327 | if (!m_isSet) { |
| 328 | if (m_usePointer) m_gen.Function.GetArgumentPointer(j); |
| 329 | else m_gen.Function.GetArgument(j); |
| 330 | } |
| 331 | else { |
| 332 | if (isPtr) { |
| 333 | m_gen.Function.GetArgument(j); |
| 334 | m_gen.Function.Assign(); |
| 335 | } |
| 336 | else |
| 337 | m_gen.Function.SetArgument(j); |
| 338 | } |
| 339 | |
| 340 | found = true; |
| 341 | break; |
| 342 | } |