pexports.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. {* Changes made by Ozerski 23.10.1998}
  25. cobjects,globals,scanner,symtable,pbase,verbose,
  26. export,GenDef,Strings;
  27. {* End changes}
  28. procedure read_exports;
  29. var
  30. hp : pexported_item;
  31. code : word;
  32. {* Changes made by Ozerski 23.10.1998}
  33. DefString:string;
  34. ProcName:string;
  35. InternalProcName:string;
  36. begin
  37. DefString:='';
  38. InternalProcName:='';
  39. {* End changes}
  40. consume(_EXPORTS);
  41. while true do
  42. begin
  43. hp:=new(pexported_item,init);
  44. if token=ID then
  45. begin
  46. getsym(pattern,true);
  47. if srsym^.typ=unitsym then
  48. begin
  49. consume(ID);
  50. consume(POINT);
  51. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  52. end;
  53. consume(ID);
  54. if assigned(srsym) then
  55. begin
  56. hp^.sym:=srsym;
  57. if ((srsym^.typ<>procsym) or
  58. ((pprocdef(pprocsym(srsym)^.definition)^.options and poexports)=0)) and
  59. (srsym^.typ<>varsym) and (srsym^.typ<>typedconstsym) then
  60. {* Changes made by Ozerski 23.10.1998}
  61. Message(parser_e_illegal_symbol_exported)
  62. else
  63. begin
  64. ProcName:=hp^.sym^.name;
  65. InternalProcName:=hp^.sym^.mangledname;
  66. delete(InternalProcName,1,1);
  67. DefString:=ProcName+'='+InternalProcName;
  68. end;
  69. {* End changes}
  70. if (idtoken=_INDEX) then
  71. begin
  72. consume(_INDEX);
  73. hp^.options:=hp^.options or eo_index;
  74. val(pattern,hp^.index,code);
  75. consume(INTCONST);
  76. {* Changes made by Ozerski 23.10.1998}
  77. DefString:=ProcName+'='+InternalProcName;{Index ignored!}
  78. {* End changes}
  79. end;
  80. if (idtoken=_NAME) then
  81. begin
  82. consume(_NAME);
  83. hp^.name:=stringdup(pattern);
  84. hp^.options:=hp^.options or eo_name;
  85. {* Changes made by Ozerski 23.10.1998}
  86. consume(CSTRING); {Bug fixed?}
  87. DefString:=hp^.name^+'='+InternalProcName;
  88. {* End changes}
  89. end;
  90. if (idtoken=_RESIDENT) then
  91. begin
  92. consume(_RESIDENT);
  93. hp^.options:=hp^.options or eo_resident;
  94. {* Changes made by Ozerski 23.10.1998}
  95. DefString:=ProcName+'='+InternalProcName;{Resident ignored!}
  96. {* End changes}
  97. end;
  98. {* Changes made by Ozerski 23.10.1998}
  99. if DefString<>''then
  100. DefFile.AddExport(DefString);
  101. {* End changes}
  102. if srsym^.typ=procsym then
  103. exportlib^.exportprocedure(hp)
  104. else
  105. exportlib^.exportvar(hp);
  106. end;
  107. end
  108. else
  109. consume(ID);
  110. if token=COMMA then
  111. consume(COMMA)
  112. else
  113. break;
  114. end;
  115. consume(SEMICOLON);
  116. {* Changes made by Ozerski 23.10.1998}
  117. if not DefFile.exportlist.empty then
  118. begin
  119. deffile.fname:='DEF.$$$';
  120. deffile.writefile;
  121. end;
  122. {* End changes}
  123. end;
  124. end.
  125. {
  126. $Log$
  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. }