151c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom/*
251c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * Copyright (C) 2013 The Android Open Source Project
351c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom *
451c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * Licensed under the Apache License, Version 2.0 (the "License");
551c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * you may not use this file except in compliance with the License.
651c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * You may obtain a copy of the License at
751c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom *
851c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom *      http://www.apache.org/licenses/LICENSE-2.0
951c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom *
1051c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * Unless required by applicable law or agreed to in writing, software
1151c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * distributed under the License is distributed on an "AS IS" BASIS,
1251c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1351c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * See the License for the specific language governing permissions and
1451c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom * limitations under the License.
1551c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom */
1651c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_METHOD_REFERENCE_H_
18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_METHOD_REFERENCE_H_
1951c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
2051c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstromnamespace art {
2151c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
2251c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstromclass DexFile;
2351c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
2451c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom// A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile
2551c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstromtypedef std::pair<const DexFile*, uint32_t> ClassReference;
2651c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
2751c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom// A method is uniquely located by its DexFile and the method_ids_ table index into that DexFile
2851c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstromstruct MethodReference {
2951c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom  MethodReference(const DexFile* file, uint32_t index) : dex_file(file), dex_method_index(index) {
3051c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom  }
3151c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom  const DexFile* dex_file;
3251c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom  uint32_t dex_method_index;
3351c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom};
3451c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
3551c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstromstruct MethodReferenceComparator {
3651c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom  bool operator()(MethodReference mr1, MethodReference mr2) const {
3751c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom    if (mr1.dex_file == mr2.dex_file) {
3851c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom      return mr1.dex_method_index < mr2.dex_method_index;
3951c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom    } else {
4051c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom      return mr1.dex_file < mr2.dex_file;
4151c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom    }
4251c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom  }
4351c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom};
4451c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
4551c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom}  // namespace art
4651c2467e8771b56e25ae4f17f66522f979f57a7eBrian Carlstrom
47fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif  // ART_RUNTIME_METHOD_REFERENCE_H_
48