File tree Expand file tree Collapse file tree 7 files changed +19
-9
lines changed Expand file tree Collapse file tree 7 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,16 @@ uint64_t Enumerator::getValue() {
13
13
return value;
14
14
}
15
15
16
- Enum::Enum (std::string name, std::vector<Enumerator> enumerators)
17
- : name(std::move(name)), enumerators(std::move(enumerators)) {}
16
+ Enum::Enum (std::string name, std::string type, std:: vector<Enumerator> enumerators)
17
+ : name(std::move(name)), type(std::move(type)), enumerators(std::move(enumerators)) {}
18
18
19
19
bool Enum::isAnonymous () const {
20
20
return name.empty ();
21
21
}
22
22
23
23
TypeDef Enum::generateTypeDef () const {
24
24
assert (!isAnonymous ());
25
- return TypeDef (" enum_" + name, " native.CInt " );
25
+ return TypeDef (" enum_" + name, type );
26
26
}
27
27
28
28
llvm::raw_ostream &operator <<(llvm::raw_ostream &s, const Enum &e) {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class Enumerator {
23
23
24
24
class Enum {
25
25
public:
26
- Enum (std::string name, std::vector<Enumerator> enumerators);
26
+ Enum (std::string name, std::string type, std:: vector<Enumerator> enumerators);
27
27
28
28
bool isAnonymous () const ;
29
29
@@ -33,6 +33,7 @@ class Enum {
33
33
34
34
private:
35
35
std::string name; // might be empty
36
+ std::string type;
36
37
std::vector<Enumerator> enumerators;
37
38
};
38
39
Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ void IR::addTypeDef(std::string name, std::string type) {
17
17
typeDefs.push_back (TypeDef (std::move (name), std::move (type)));
18
18
}
19
19
20
- void IR::addEnum (std::string name, std::vector<Enumerator> enumerators) {
21
- enums.push_back (Enum (std::move (name), std::move (enumerators)));
20
+ void IR::addEnum (std::string name, std::string type, std:: vector<Enumerator> enumerators) {
21
+ enums.push_back (Enum (std::move (name), std::move (type), std::move ( enumerators)));
22
22
}
23
23
24
24
void IR::addStruct (std::string name, std::vector<Field> fields, uint64_t typeSize) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class IR {
19
19
20
20
void addTypeDef (std::string name, std::string type);
21
21
22
- void addEnum (std::string name, std::vector<Enumerator> enumerators);
22
+ void addEnum (std::string name, std::string type, std:: vector<Enumerator> enumerators);
23
23
24
24
void addStruct (std::string name, std::vector<Field> fields, uint64_t typeSize);
25
25
Original file line number Diff line number Diff line change @@ -7,3 +7,8 @@ enum days {
7
7
SATURDAY = 3 ,
8
8
SUNDAY // = 4
9
9
};
10
+
11
+ enum bigValues {
12
+ A = 10000000000 , // does not fit into int
13
+ B // 10000000001
14
+ };
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ import scala.scalanative.native.Nat._
5
5
@ native.link(" Enum" )
6
6
@ native.extern
7
7
object Enum {
8
- type enum_days = native.CInt
8
+ type enum_days = native.CUnsignedInt
9
+ type enum_bigValues = native.CUnsignedLong
9
10
}
10
11
11
12
import Enum ._
@@ -18,4 +19,7 @@ object EnumEnums {
18
19
final val enum_days_FRIDAY = 5
19
20
final val enum_days_SATURDAY = 3
20
21
final val enum_days_SUNDAY = 4
22
+
23
+ final val enum_bigValues_A = 10000000000
24
+ final val enum_bigValues_B = 10000000001
21
25
}
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ bool TreeVisitor::VisitEnumDecl(clang::EnumDecl *enumdecl) {
67
67
enumerators.push_back (Enumerator (en->getNameAsString (), value));
68
68
}
69
69
70
- ir->addEnum (name, enumerators);
70
+ ir->addEnum (name, typeTranslator. Translate (enumdecl-> getIntegerType ()), enumerators);
71
71
72
72
return true ;
73
73
}
You can’t perform that action at this time.
0 commit comments