pexports.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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,symconst,symtable,pbase,
  27. export,GenDef;
  28. procedure read_exports;
  29. var
  30. hp : pexported_item;
  31. code : integer;
  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. not(po_exports in pprocdef(pprocsym(srsym)^.definition)^.procoptions)) and
  57. (srsym^.typ<>varsym) and (srsym^.typ<>typedconstsym) then
  58. Message(parser_e_illegal_symbol_exported)
  59. else
  60. begin
  61. ProcName:=hp^.sym^.name;
  62. InternalProcName:=hp^.sym^.mangledname;
  63. delete(InternalProcName,1,1);
  64. DefString:=ProcName+'='+InternalProcName;
  65. end;
  66. if (idtoken=_INDEX) then
  67. begin
  68. consume(_INDEX);
  69. hp^.options:=hp^.options or eo_index;
  70. val(pattern,hp^.index,code);
  71. consume(_INTCONST);
  72. DefString:=ProcName+'='+InternalProcName;{Index ignored!}
  73. (* DefString:=ProcName+'@'+pattern+'='+InternalProcName;{Index ignored!} *)
  74. end;
  75. if (idtoken=_NAME) then
  76. begin
  77. consume(_NAME);
  78. hp^.name:=stringdup(pattern);
  79. hp^.options:=hp^.options or eo_name;
  80. consume(_CSTRING); {Bug fixed?}
  81. DefString:=hp^.name^+'='+InternalProcName;
  82. end;
  83. if (idtoken=_RESIDENT) then
  84. begin
  85. consume(_RESIDENT);
  86. hp^.options:=hp^.options or eo_resident;
  87. DefString:=ProcName+'='+InternalProcName;{Resident ignored!}
  88. end;
  89. if DefString<>''then
  90. DefFile.AddExport(DefString);
  91. if srsym^.typ=procsym then
  92. exportlib^.exportprocedure(hp)
  93. else
  94. begin
  95. exportlib^.exportvar(hp);
  96. end;
  97. end;
  98. end
  99. else
  100. consume(_ID);
  101. if token=_COMMA then
  102. consume(_COMMA)
  103. else
  104. break;
  105. end;
  106. consume(_SEMICOLON);
  107. if not DefFile.empty then
  108. DefFile.writefile;
  109. end;
  110. end.
  111. {
  112. $Log$
  113. Revision 1.12 1999-08-10 12:51:19 pierre
  114. * bind_win32_dll removed (Relocsection used instead)
  115. * now relocsection is true by default ! (needs dlltool
  116. for DLL generation)
  117. Revision 1.11 1999/08/04 13:02:54 jonas
  118. * all tokens now start with an underscore
  119. * PowerPC compiles!!
  120. Revision 1.10 1999/08/03 22:02:58 peter
  121. * moved bitmask constants to sets
  122. * some other type/const renamings
  123. Revision 1.9 1999/05/04 21:44:56 florian
  124. * changes to compile it with Delphi 4.0
  125. Revision 1.8 1999/03/26 00:05:35 peter
  126. * released valintern
  127. + deffile is now removed when compiling is finished
  128. * ^( compiles now correct
  129. + static directive
  130. * shrd fixed
  131. Revision 1.7 1999/02/22 02:44:12 peter
  132. * ag386bin doesn't use i386.pas anymore
  133. Revision 1.6 1998/12/11 00:03:31 peter
  134. + globtype,tokens,version unit splitted from globals
  135. Revision 1.5 1998/11/30 13:26:25 pierre
  136. * the code for ordering the exported procs/vars was buggy
  137. + added -WB to force binding (Ozerski way of creating DLL)
  138. this is off by default as direct writing of .edata section seems
  139. OK
  140. Revision 1.4 1998/11/30 09:43:21 pierre
  141. * some range check bugs fixed (still not working !)
  142. + added DLL writing support for win32 (also accepts variables)
  143. + TempAnsi for code that could be used for Temporary ansi strings
  144. handling
  145. Revision 1.3 1998/10/29 11:35:51 florian
  146. * some dll support for win32
  147. * fixed assembler writing for PalmOS
  148. Revision 1.2 1998/09/26 17:45:35 peter
  149. + idtoken and only one token table
  150. }