CompoundType.h revision c9410c7e62a33fd7599b2f3e025093a2d171577e
1c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#ifndef COMPOUND_TYPE_H_
2c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
3c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#define COMPOUND_TYPE_H_
4c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
5c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#include "Scope.h"
6c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
7c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#include <utils/Vector.h>
8c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
9c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Hubernamespace android {
10c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
11c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberstruct CompoundField {
12c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    CompoundField(const char *name, Type *type);
13c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
14c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    void dump(Formatter &out) const;
15c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
16c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberprivate:
17c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    std::string mName;
18c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    Type *mType;
19c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
20c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    DISALLOW_COPY_AND_ASSIGN(CompoundField);
21c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber};
22c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
23c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberstruct CompoundType : public Scope {
24c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    enum Style {
25c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber        STYLE_STRUCT,
26c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber        STYLE_UNION,
27c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    };
28c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
29c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    CompoundType(Style style, const char *name);
30c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
31c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    void setFields(Vector<CompoundField *> *fields);
32c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
33c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    void dump(Formatter &out) const override;
34c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
35c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberprivate:
36c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    Style mStyle;
37c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    Vector<CompoundField *> *mFields;
38c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
39c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber    DISALLOW_COPY_AND_ASSIGN(CompoundType);
40c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber};
41c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
42c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber}  // namespace android
43c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
44c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#endif  // COMPOUND_TYPE_H_
45c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber
46