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,
116116 * @return true if given type is of type T or is an alias for type T.
117117 */
118118template <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) {
121124 return isAliasForType<T>(typeDef->getType ().get ());
122125 }
123- return isInstanceOf<T>(type) ;
126+ return false ;
124127}
125128
126129#endif // UTILS_H
Original file line number Diff line number Diff line change @@ -74,19 +74,15 @@ Function::~Function() {
7474}
7575
7676bool 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
8078 * 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 ())) {
8481 return false ;
8582 }
8683 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 ())) {
9086 return false ;
9187 }
9288 }
Original file line number Diff line number Diff line change @@ -23,27 +23,6 @@ class TypeDef : public TypeAndName, public Type {
2323
2424 std::shared_ptr<Location> getLocation () const ;
2525
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-
4726 private:
4827 /* *
4928 * nullptr if type is generated.
You can’t perform that action at this time.
0 commit comments