| 707 | m_gen.Function.PopStack(); |
| 708 | } |
| 709 | void HLSLCompiler::translateIdentifierExpression(M4::HLSLIdentifierExpression* expression) |
| 710 | { |
| 711 | const std::string vname = std::string(expression->name); |
| 712 | bool found = false; |
| 713 | |
| 714 | // globals |
| 715 | for (int i = 0; i < m_globals.size(); i++) |
| 716 | if (m_globals[i].Name == vname) { |
| 717 | if (!m_isSet) { |
| 718 | if (m_usePointer) m_gen.Function.GetGlobalPointer(m_globals[i].ID); |
| 719 | else m_gen.Function.GetGlobal(m_globals[i].ID); |
| 720 | } |
| 721 | else |
| 722 | m_gen.Function.SetGlobal(m_globals[i].ID); |
| 723 | |
| 724 | found = true; |
| 725 | break; |
| 726 | } |
| 727 | |
| 728 | if (m_currentFunction.size() != 0 && !found) { |
| 729 | // locals |
| 730 | for (int i = 0; i < m_locals[m_currentFunction].size(); i++) { |
| 731 | if (m_locals[m_currentFunction][i] == vname) { |
| 732 | if (!m_isSet) { |
| 733 | if (m_usePointer) m_gen.Function.GetLocalPointer(i); |
| 734 | else m_gen.Function.GetLocal(i); |
| 735 | } |
| 736 | else |
| 737 | m_gen.Function.SetLocal(i); |
| 738 | |
| 739 | found = true; |
| 740 | break; |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | // arguments |
| 745 | for (int i = 0; i < m_func.size() && !found; i++) { |
| 746 | if (m_func[i].Name != m_currentFunction) |
| 747 | continue; |
| 748 | |
| 749 | for (int j = 0; j < m_func[i].Arguments.size(); j++) { |
| 750 | if (m_func[i].Arguments[j].Name == vname) { |
| 751 | bool isPtr = m_func[i].Arguments[j].Storage == sd::Variable::StorageType::Out; |
| 752 | |
| 753 | if (!m_isSet) { |
| 754 | if (m_usePointer) m_gen.Function.GetArgumentPointer(j); |
| 755 | else m_gen.Function.GetArgument(j); |
| 756 | } |
| 757 | else { |
| 758 | if (isPtr) { |
| 759 | m_gen.Function.GetArgument(j); |
| 760 | m_gen.Function.Assign(); |
| 761 | } else |
| 762 | m_gen.Function.SetArgument(j); |
| 763 | } |
| 764 | |
| 765 | found = true; |
| 766 | break; |