objcgutl.pas 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. {
  2. Copyright (c) 2009 by Jonas Maebe
  3. This unit implements some Objective-C helper routines at the code generator
  4. level.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. {$i fpcdefs.inc}
  19. unit objcgutl;
  20. interface
  21. uses
  22. cclasses,
  23. aasmbase;
  24. procedure objcfinishstringrefpoolentry(entry: phashsetitem; refsec, stringsec: tasmsectiontype);
  25. implementation
  26. uses
  27. globtype,
  28. aasmdata,aasmtai,
  29. cgbase,cgutils,
  30. symsym,
  31. verbose;
  32. procedure objcfinishstringrefpoolentry(entry: phashsetitem; refsec, stringsec: tasmsectiontype);
  33. var
  34. reflab,
  35. strlab : tasmlabel;
  36. pc : pchar;
  37. begin
  38. { have we already generated this selector? }
  39. if not assigned(entry^.Data) then
  40. begin
  41. { create new one
  42. (no getdatalabel, because these labels have to be local)
  43. }
  44. current_asmdata.getlabel(reflab,alt_data);
  45. current_asmdata.getlabel(strlab,alt_data);
  46. entry^.Data:=reflab;
  47. getmem(pc,entry^.keylength+1);
  48. move(entry^.key^,pc^,entry^.keylength);
  49. pc[entry^.keylength]:=#0;
  50. { add a pointer to the message name in the string references section }
  51. new_section(current_asmdata.asmlists[al_objc_data],refsec,reflab.name,sizeof(pint));
  52. current_asmdata.asmlists[al_objc_data].concat(Tai_label.Create(reflab));
  53. current_asmdata.asmlists[al_objc_data].concat(Tai_const.Create_sym(strlab));
  54. { and now add the message name to the associated strings section }
  55. new_section(current_asmdata.asmlists[al_objc_data],stringsec,strlab.name,1);
  56. current_asmdata.asmlists[al_objc_data].concat(Tai_label.Create(strlab));
  57. current_asmdata.asmlists[al_objc_data].concat(Tai_string.Create_pchar(pc,entry^.keylength+1));
  58. end;
  59. end;
  60. end.