File tree Expand file tree Collapse file tree 3 files changed +11
-33
lines changed Expand file tree Collapse file tree 3 files changed +11
-33
lines changed Original file line number Diff line number Diff line change @@ -116,11 +116,14 @@ static inline std::string replaceChar(const std::string &str,
116
116
* @return true if given type is of type T or is an alias for type T.
117
117
*/
118
118
template <typename T> static inline bool isAliasForType (Type *type) {
119
- if (isInstanceOf<TypeDef>(type)) {
120
- auto *typeDef = dynamic_cast <TypeDef *>(type);
119
+ if (isInstanceOf<T>(type)) {
120
+ return true ;
121
+ }
122
+ auto *typeDef = dynamic_cast <TypeDef *>(type);
123
+ if (typeDef) {
121
124
return isAliasForType<T>(typeDef->getType ().get ());
122
125
}
123
- return isInstanceOf<T>(type) ;
126
+ return false ;
124
127
}
125
128
126
129
#endif // UTILS_H
Original file line number Diff line number Diff line change @@ -74,19 +74,15 @@ Function::~Function() {
74
74
}
75
75
76
76
bool Function::isLegalScalaNativeFunction () const {
77
- /* structs and unions are used only through corresponding TypeDefs so it's
78
- * okay to cast only to TypeDef.
79
- * Return type and parameters types cannot be array types because array type
77
+ /* Return type and parameters types cannot be array types because array type
80
78
* in this case is always represented as a pointer to element type */
81
- auto *typeDef = dynamic_cast <TypeDef *>(retType.get ());
82
- if (typeDef &&
83
- (typeDef->isAliasFor <Struct>() || typeDef->isAliasFor <ArrayType>())) {
79
+ if (isAliasForType<Struct>(retType.get ()) ||
80
+ isAliasForType<Union>(retType.get ())) {
84
81
return false ;
85
82
}
86
83
for (const auto ¶meter : parameters) {
87
- typeDef = dynamic_cast <TypeDef *>(parameter->getType ().get ());
88
- if (typeDef && (typeDef->isAliasFor <Struct>() ||
89
- typeDef->isAliasFor <ArrayType>())) {
84
+ if (isAliasForType<Struct>(parameter->getType ().get ()) ||
85
+ isAliasForType<Union>(parameter->getType ().get ())) {
90
86
return false ;
91
87
}
92
88
}
Original file line number Diff line number Diff line change @@ -23,27 +23,6 @@ class TypeDef : public TypeAndName, public Type {
23
23
24
24
std::shared_ptr<Location> getLocation () const ;
25
25
26
- /* *
27
- * @tparam T Type
28
- * @return true if the typedef is an alias for give type directly or through
29
- * a chain of typedefs
30
- */
31
- template <typename T> bool isAliasFor () const {
32
- /* if body is moved to cpp file then linker gives undefined symbols
33
- * error */
34
- if (!type) {
35
- return false ;
36
- }
37
- if (dynamic_cast <T *>(type.get ())) {
38
- return true ;
39
- }
40
- auto *typeDef = dynamic_cast <TypeDef *>(type.get ());
41
- if (typeDef) {
42
- return typeDef->isAliasFor <T>();
43
- }
44
- return false ;
45
- }
46
-
47
26
private:
48
27
/* *
49
28
* nullptr if type is generated.
You can’t perform that action at this time.
0 commit comments