CallConvention.cpp 1005 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <ostream>
  2. #include <cassert>
  3. #include "CallConvention.h"
  4. #include <QtCore/QTextStream>
  5. CConv *CConv::create(Type v)
  6. {
  7. static C_CallingConvention *c_call = nullptr;
  8. static Pascal_CallingConvention *p_call = nullptr;
  9. static Unknown_CallingConvention *u_call= nullptr;
  10. if(nullptr==c_call)
  11. c_call = new C_CallingConvention;
  12. if(nullptr==p_call)
  13. p_call = new Pascal_CallingConvention;
  14. if(nullptr==u_call)
  15. u_call = new Unknown_CallingConvention;
  16. switch(v) {
  17. case eUnknown: return u_call;
  18. case eCdecl: return c_call;
  19. case ePascal: return p_call;
  20. }
  21. assert(false);
  22. return nullptr;
  23. }
  24. void C_CallingConvention::writeComments(QTextStream & ostr)
  25. {
  26. ostr << " * C calling convention.\n";
  27. }
  28. void Pascal_CallingConvention::writeComments(QTextStream & ostr)
  29. {
  30. ostr << " * Pascal calling convention.\n";
  31. }
  32. void Unknown_CallingConvention::writeComments(QTextStream & ostr)
  33. {
  34. ostr << " * Unknown calling convention.\n";
  35. }