pexports.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. cobjects,globals,scanner,symtable,pbase,verbose;
  25. const
  26. { export options }
  27. eo_resident = $1;
  28. type
  29. pexportsitem = ^texportsitem;
  30. texportsitem = object(tlinkedlist_item)
  31. sym : psym;
  32. index : longint;
  33. name : pstring;
  34. options : word;
  35. constructor init;
  36. end;
  37. var
  38. exportslist : tlinkedlist;
  39. constructor texportsitem.init;
  40. begin
  41. sym:=nil;
  42. index:=-1;
  43. name:=nil;
  44. options:=0;
  45. end;
  46. procedure read_exports;
  47. var
  48. hp : pexportsitem;
  49. code : word;
  50. begin
  51. hp:=new(pexportsitem,init);
  52. consume(_EXPORTS);
  53. while true do
  54. begin
  55. if token=ID then
  56. begin
  57. getsym(pattern,true);
  58. if srsym^.typ=unitsym then
  59. begin
  60. consume(ID);
  61. consume(POINT);
  62. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  63. end;
  64. consume(ID);
  65. if assigned(srsym) then
  66. begin
  67. hp^.sym:=srsym;
  68. if (srsym^.typ<>procsym) or
  69. ((pprocdef(pprocsym(srsym)^.definition)^.options and poexports)=0) then
  70. Message(parser_e_illegal_symbol_exported);
  71. if (token=ID) and (pattern='INDEX') then
  72. begin
  73. consume(ID);
  74. val(pattern,hp^.index,code);
  75. consume(INTCONST);
  76. end;
  77. if (token=ID) and (pattern='NAME') then
  78. begin
  79. consume(ID);
  80. hp^.name:=stringdup(pattern);
  81. consume(ID);
  82. end;
  83. if (token=ID) and (pattern='RESIDENT') then
  84. begin
  85. consume(ID);
  86. hp^.options:=hp^.options or eo_resident;
  87. end;
  88. end;
  89. end
  90. else
  91. consume(ID);
  92. if token=COMMA then
  93. consume(COMMA)
  94. else
  95. break;
  96. end;
  97. consume(SEMICOLON);
  98. end;
  99. begin
  100. { a library is a root of sources, e.g. it can't be used
  101. twice in one compiler run }
  102. exportslist.init;
  103. end.
  104. {
  105. $Log$
  106. Revision 1.1 1998-03-25 11:18:15 root
  107. Initial revision
  108. Revision 1.7 1998/03/10 01:17:24 peter
  109. * all files have the same header
  110. * messages are fully implemented, EXTDEBUG uses Comment()
  111. + AG... files for the Assembler generation
  112. Revision 1.6 1998/03/06 00:52:42 peter
  113. * replaced all old messages from errore.msg, only ExtDebug and some
  114. Comment() calls are left
  115. * fixed options.pas
  116. Revision 1.5 1998/03/02 01:49:01 peter
  117. * renamed target_DOS to target_GO32V1
  118. + new verbose system, merged old errors and verbose units into one new
  119. verbose.pas, so errors.pas is obsolete
  120. Revision 1.4 1998/02/13 10:35:24 daniel
  121. * Made Motorola version compilable.
  122. * Fixed optimizer
  123. Revision 1.3 1998/01/12 13:02:41 florian
  124. + items of exports are now seperated by ,
  125. Revision 1.2 1998/01/12 12:11:35 florian
  126. + unit qualifier is now allowed to specify exported symbols
  127. + exports starts now a list of symbols to export
  128. Revision 1.1 1998/01/11 10:58:07 florian
  129. + pexports in lowercase commited
  130. Revision 1.1 1998/01/11 10:54:19 florian
  131. + generic library support
  132. }