------------------------------------------------------------- * hash all array items ***************************************************************/
| 775 | * hash all array items |
| 776 | ***************************************************************/ |
| 777 | void |
| 778 | ArrayVariable::hash(std::ostream& out) const |
| 779 | { |
| 780 | if (collective != 0) return; |
| 781 | vector<string> field_names; |
| 782 | vector<const Type *> field_types; |
| 783 | vector<int> included_fields; |
| 784 | // for unions, find the fields that we don't want to hash due to union field read rules. So FactUnion.cpp |
| 785 | vector<int> excluded_fields; |
| 786 | if (type->eType == eUnion) { |
| 787 | FactMgr* fm = get_fact_mgr_for_func(GetFirstFunction()); |
| 788 | assert(fm); |
| 789 | for (size_t i=0; i<field_vars.size(); i++) { |
| 790 | if (!FactUnion::is_field_readable(this, i, fm->global_facts)) { |
| 791 | excluded_fields.push_back(i); |
| 792 | } |
| 793 | } |
| 794 | } |
| 795 | type->get_int_subfield_names("", field_names, field_types, excluded_fields); |
| 796 | assert(field_names.size() == field_types.size()); |
| 797 | // if not a suitable type for hashing, give up |
| 798 | if (field_names.size() == 0) return; |
| 799 | |
| 800 | size_t i, j; |
| 801 | int indent = 1; |
| 802 | //ISSUE: ugly hack to make sure we use the latest ctrl_vars, which is generated |
| 803 | // from the call of OutputArrayInitializers in OutputMgr.cpp |
| 804 | const vector<const Variable*>& cvs = Variable::get_last_ctrl_vars(); |
| 805 | for (i=0; i<get_dimension(); i++) { |
| 806 | output_tab(out, indent); |
| 807 | out << "for ("; |
| 808 | out << cvs[i]->get_actual_name(); |
| 809 | out << " = 0; "; |
| 810 | out << cvs[i]->get_actual_name(); |
| 811 | out << " < " << sizes[i] << "; "; |
| 812 | out << cvs[i]->get_actual_name(); |
| 813 | if (CGOptions::post_incr_operator()) { |
| 814 | out << "++)"; |
| 815 | } |
| 816 | else { |
| 817 | out << " = " << cvs[i]->get_actual_name() << " + 1)"; |
| 818 | } |
| 819 | outputln(out); |
| 820 | output_open_encloser("{", out, indent); |
| 821 | } |
| 822 | string vname; |
| 823 | ostringstream oss; |
| 824 | output_with_indices(oss, cvs); |
| 825 | vname = oss.str(); |
| 826 | if (CGOptions::compute_hash()) { |
| 827 | for (j=0; j<field_names.size(); j++) { |
| 828 | if (field_types[j]->eType == eSimple && field_types[j]->simple_type == eFloat) { |
| 829 | output_tab(out, indent); |
| 830 | out << "transparent_crc_bytes(&" << vname << field_names[j] << ", "; |
| 831 | out << "sizeof(" << vname << field_names[j] << "), "; |
| 832 | out << "\"" << vname << field_names[j] << "\", print_hash_value);" << endl; |
| 833 | } else { |
| 834 | output_tab(out, indent); |
nothing calls this directly
no test coverage detected