Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. ##ArrayHelper.h
  2. #ifndef ARRAYHELPER_H
  3. #define ARRAYHELPER_H
  4.  
  5. #include <iostream>
  6. #include <queue>
  7. #include <string>
  8. #include "TypeHelper.h"
  9. #include "../IdentTypes/ArrayType.h"
  10.  
  11. using namespace std;
  12.  
  13. class ArrayHelper : public TypeHelper {
  14. public:
  15. ArrayHelper(const string& type_name);
  16. ~ArrayHelper();
  17.  
  18. bool setTypePtr(IdentRecord* type); //problematic function
  19.  
  20. bool sendToSt(STObject* st);
  21.  
  22. private:
  23. struct Range {
  24. int low;
  25. int high;
  26. };
  27. queue<Range*> ranges;
  28.  
  29. bool validate(void);
  30.  
  31. IdentRecord* typePtr;
  32. };
  33.  
  34. #endif
  35.  
  36. ##ArrayHelper.cpp
  37. ArrayHelper::ArrayHelper(const string& type_name) : TypeHelper(type_name) {
  38. typePtr = NULL;
  39. }
  40.  
  41. bool ArrayHelper::setTypePtr(IdentRecord* type) {
  42. if (typePtr != NULL) { //Segfaults here
  43. clean = false;
  44. cout << "Error: type already set." << endl;
  45. return false;
  46. } else if (type == NULL) {
  47. clean = false;
  48. cout << "Error: cannot set NULL typePtr." << endl;
  49. return false;
  50. } else {
  51. cout << "DEBUG: type successfully set for " << typeName << endl;
  52. typePtr = type;
  53. return true;
  54. }
  55. }
Add Comment
Please, Sign In to add comment