blob: 86c8f50a23923a6ca285d6e09549ae2e68a350e5 [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#ifndef METHOD_H_
2
3#define METHOD_H_
4
5#include <android-base/macros.h>
6#include <string>
Andreas Huber3599d922016-08-09 10:42:57 -07007#include <utils/KeyedVector.h>
Andreas Huber881227d2016-08-02 14:20:21 -07008#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -07009
10namespace android {
11
Andreas Huber3599d922016-08-09 10:42:57 -070012struct Annotation;
Andreas Huberc9410c72016-07-28 12:18:40 -070013struct Formatter;
14struct Type;
Andreas Huber31629bc2016-08-03 09:06:40 -070015struct TypedVar;
Andreas Huberc9410c72016-07-28 12:18:40 -070016
17struct Method {
18 Method(const char *name,
Andreas Huber881227d2016-08-02 14:20:21 -070019 std::vector<TypedVar *> *args,
Andreas Huber3599d922016-08-09 10:42:57 -070020 std::vector<TypedVar *> *results,
21 KeyedVector<std::string, Annotation *> *annotations);
Andreas Huberc9410c72016-07-28 12:18:40 -070022
Andreas Huber881227d2016-08-02 14:20:21 -070023 std::string name() const;
24 const std::vector<TypedVar *> &args() const;
25 const std::vector<TypedVar *> &results() const;
Andreas Huber3599d922016-08-09 10:42:57 -070026 const KeyedVector<std::string, Annotation *> &annotations() const;
Andreas Huber881227d2016-08-02 14:20:21 -070027
28 static std::string GetSignature(const std::vector<TypedVar *> &args);
29
Andreas Huber3599d922016-08-09 10:42:57 -070030 void dumpAnnotations(Formatter &out) const;
31
Andreas Huberc9410c72016-07-28 12:18:40 -070032private:
33 std::string mName;
Andreas Huber881227d2016-08-02 14:20:21 -070034 std::vector<TypedVar *> *mArgs;
35 std::vector<TypedVar *> *mResults;
Andreas Huber3599d922016-08-09 10:42:57 -070036 KeyedVector<std::string, Annotation *> *mAnnotationsByName;
Andreas Huberc9410c72016-07-28 12:18:40 -070037
38 DISALLOW_COPY_AND_ASSIGN(Method);
39};
40
Andreas Huber31629bc2016-08-03 09:06:40 -070041struct TypedVar {
42 TypedVar(const char *name, Type *type);
43
44 std::string name() const;
45 const Type &type() const;
46
47private:
48 std::string mName;
49 Type *mType;
50
51 DISALLOW_COPY_AND_ASSIGN(TypedVar);
52};
53
Andreas Huberc9410c72016-07-28 12:18:40 -070054} // namespace android
55
56#endif // METHOD_H_
57