• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_LIBDEXFILE_DEX_SIGNATURE_H_
18 #define ART_LIBDEXFILE_DEX_SIGNATURE_H_
19 
20 #include <iosfwd>
21 #include <string>
22 #include <string_view>
23 
24 #include <android-base/logging.h>
25 
26 #include "base/value_object.h"
27 
28 namespace art {
29 
30 namespace dex {
31 struct ProtoId;
32 }  // namespace dex
33 class DexFile;
34 
35 // Abstract the signature of a method.
36 class Signature : public ValueObject {
37  public:
38   std::string ToString() const;
39 
NoSignature()40   static Signature NoSignature() {
41     return Signature();
42   }
43 
44   bool IsVoid() const;
45   uint32_t GetNumberOfParameters() const;
46 
47   bool operator==(const Signature& rhs) const;
48   bool operator!=(const Signature& rhs) const {
49     return !(*this == rhs);
50   }
51 
52   bool operator==(std::string_view rhs) const;
53 
54  private:
Signature(const DexFile * dex,const dex::ProtoId & proto)55   Signature(const DexFile* dex, const dex::ProtoId& proto) : dex_file_(dex), proto_id_(&proto) {
56   }
57 
58   Signature() = default;
59 
60   friend class DexFile;
61 
62   const DexFile* const dex_file_ = nullptr;
63   const dex::ProtoId* const proto_id_ = nullptr;
64 };
65 std::ostream& operator<<(std::ostream& os, const Signature& sig);
66 
67 }  // namespace art
68 
69 #endif  // ART_LIBDEXFILE_DEX_SIGNATURE_H_
70