pexports.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Florian Klaempfl
  4. This unit handles the exports parsing
  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. unit pexports;
  19. interface
  20. { reads an exports statement in a library }
  21. procedure read_exports;
  22. implementation
  23. uses
  24. globtype,systems,tokens,
  25. strings,cobjects,globals,verbose,
  26. scanner,symtable,pbase,
  27. export,GenDef;
  28. procedure read_exports;
  29. var
  30. hp : pexported_item;
  31. code : word;
  32. DefString:string;
  33. ProcName:string;
  34. InternalProcName:string;
  35. begin
  36. DefString:='';
  37. InternalProcName:='';
  38. consume(_EXPORTS);
  39. while true do
  40. begin
  41. hp:=new(pexported_item,init);
  42. if token=ID then
  43. begin
  44. getsym(pattern,true);
  45. if srsym^.typ=unitsym then
  46. begin
  47. consume(ID);
  48. consume(POINT);
  49. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  50. end;
  51. consume(ID);
  52. if assigned(srsym) then
  53. begin
  54. hp^.sym:=srsym;
  55. if ((srsym^.typ<>procsym) or
  56. ((pprocdef(pprocsym(srsym)^.definition)^.options and poexports)=0)) and
  57. (srsym^.typ<>varsym) and (srsym^.typ<>typedconstsym) then
  58. {* Changes made by Ozerski 23.10.1998}
  59. Message(parser_e_illegal_symbol_exported)
  60. else
  61. begin
  62. ProcName:=hp^.sym^.name;
  63. InternalProcName:=hp^.sym^.mangledname;
  64. delete(InternalProcName,1,1);
  65. DefString:=ProcName+'='+InternalProcName;
  66. end;
  67. {* End changes}
  68. if (idtoken=_INDEX) then
  69. begin
  70. consume(_INDEX);
  71. hp^.options:=hp^.options or eo_index;
  72. val(pattern,hp^.index,code);
  73. consume(INTCONST);
  74. {* Changes made by Ozerski 23.10.1998}
  75. DefString:=ProcName+'='+InternalProcName;{Index ignored!}
  76. {* End changes}
  77. end;
  78. if (idtoken=_NAME) then
  79. begin
  80. consume(_NAME);
  81. hp^.name:=stringdup(pattern);
  82. hp^.options:=hp^.options or eo_name;
  83. {* Changes made by Ozerski 23.10.1998}
  84. consume(CSTRING); {Bug fixed?}
  85. DefString:=hp^.name^+'='+InternalProcName;
  86. {* End changes}
  87. end;
  88. if (idtoken=_RESIDENT) then
  89. begin
  90. consume(_RESIDENT);
  91. hp^.options:=hp^.options or eo_resident;
  92. {* Changes made by Ozerski 23.10.1998}
  93. DefString:=ProcName+'='+InternalProcName;{Resident ignored!}
  94. {* End changes}
  95. end;
  96. {* Changes made by Ozerski 23.10.1998}
  97. if DefString<>''then
  98. DefFile.AddExport(DefString);
  99. {* End changes}
  100. if srsym^.typ=procsym then
  101. exportlib^.exportprocedure(hp)
  102. else
  103. exportlib^.exportvar(hp);
  104. end;
  105. end
  106. else
  107. consume(ID);
  108. if token=COMMA then
  109. consume(COMMA)
  110. else
  111. break;
  112. end;
  113. consume(SEMICOLON);
  114. {* Changes made by Ozerski 23.10.1998}
  115. if not DefFile.exportlist.empty then
  116. begin
  117. deffile.fname:='DEF.$$$';
  118. deffile.writefile;
  119. end;
  120. {* End changes}
  121. end;
  122. end.
  123. {
  124. $Log$
  125. Revision 1.6 1998-12-11 00:03:31 peter
  126. + globtype,tokens,version unit splitted from globals
  127. Revision 1.5 1998/11/30 13:26:25 pierre
  128. * the code for ordering the exported procs/vars was buggy
  129. + added -WB to force binding (Ozerski way of creating DLL)
  130. this is off by default as direct writing of .edata section seems
  131. OK
  132. Revision 1.4 1998/11/30 09:43:21 pierre
  133. * some range check bugs fixed (still not working !)
  134. + added DLL writing support for win32 (also accepts variables)
  135. + TempAnsi for code that could be used for Temporary ansi strings
  136. handling
  137. Revision 1.3 1998/10/29 11:35:51 florian
  138. * some dll support for win32
  139. * fixed assembler writing for PalmOS
  140. Revision 1.2 1998/09/26 17:45:35 peter
  141. + idtoken and only one token table
  142. }