| 844 | |
| 845 | |
| 846 | void cSemanticASTVisitor::VisitUnpackTarget(cASTUnpackTarget& node) |
| 847 | { |
| 848 | node.GetExpression()->Accept(*this); |
| 849 | |
| 850 | // Make sure that the expression can be used as an array |
| 851 | checkCast(node.GetExpression()->GetType(), TYPEINFO(ARRAY)); |
| 852 | |
| 853 | // Check each named variable and determine if it exists |
| 854 | for (int var = 0; var < node.GetSize(); var++) { |
| 855 | int var_id = -1; |
| 856 | bool global = false; |
| 857 | if (lookupVariable(node.GetVarName(var), var_id, global)) { |
| 858 | node.SetVar(var, var_id, global, (global ? m_global_symtbl : m_cur_symtbl)->GetVariableType(var_id)); |
| 859 | } else { |
| 860 | SEMANTIC_ERROR(VARIABLE_UNDEFINED, (const char*)node.GetVarName(var)); |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | // Check if last named is of array type |
| 865 | const int last = node.GetSize() - 1; |
| 866 | if (node.IsLastNamed() && node.GetVarID(last) != -1 && node.GetVarType(last) != TYPE(ARRAY)) |
| 867 | SEMANTIC_ERROR(UNPACK_WILD_NONARRAY, (const char*)node.GetVarName(last)); |
| 868 | |
| 869 | // Rest of variable type checking must be done at runtime |
| 870 | } |
| 871 | |
| 872 | void cSemanticASTVisitor::PostCheck() |
| 873 | { |
nothing calls this directly
no test coverage detected