CallConvention.cpp 968 B

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