pdecl.pas 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Does declaration (but not type) parsing for Free Pascal
  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 pdecl;
  19. {$define UseUnionSymtable}
  20. interface
  21. uses
  22. globtype,tokens,globals,symtable;
  23. procedure parameter_dec(aktprocdef:pabstractprocdef);
  24. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  25. { reads the declaration blocks }
  26. procedure read_declarations(islibrary : boolean);
  27. { reads declarations in the interface part of a unit }
  28. procedure read_interface_declarations;
  29. implementation
  30. uses
  31. cobjects,scanner,
  32. cutils,symconst,aasm,tree,pass_1,strings,
  33. fmodule,types,verbose,systems,import,
  34. cpubase
  35. {$ifndef newcg}
  36. ,tccnv
  37. {$endif newcg}
  38. {$ifdef GDB}
  39. ,gdb
  40. {$endif GDB}
  41. { parser specific stuff }
  42. ,pbase,ptconst,pexpr,ptype,psub,pexports
  43. { processor specific stuff }
  44. { codegen }
  45. {$ifdef newcg}
  46. ,cgbase
  47. {$else}
  48. ,hcodegen
  49. {$endif}
  50. ,hcgdata
  51. ;
  52. function readconstant(const name:string;const filepos:tfileposinfo):pconstsym;
  53. var
  54. hp : pconstsym;
  55. p : ptree;
  56. ps : pconstset;
  57. pd : pbestreal;
  58. sp : pchar;
  59. storetokenpos : tfileposinfo;
  60. begin
  61. readconstant:=nil;
  62. if name='' then
  63. internalerror(9584582);
  64. hp:=nil;
  65. p:=comp_expr(true);
  66. do_firstpass(p);
  67. storetokenpos:=tokenpos;
  68. tokenpos:=filepos;
  69. case p^.treetype of
  70. ordconstn:
  71. begin
  72. if is_constintnode(p) then
  73. hp:=new(pconstsym,init_def(name,constint,p^.value,nil))
  74. else if is_constcharnode(p) then
  75. hp:=new(pconstsym,init_def(name,constchar,p^.value,nil))
  76. else if is_constboolnode(p) then
  77. hp:=new(pconstsym,init_def(name,constbool,p^.value,nil))
  78. else if p^.resulttype^.deftype=enumdef then
  79. hp:=new(pconstsym,init_def(name,constord,p^.value,p^.resulttype))
  80. else if p^.resulttype^.deftype=pointerdef then
  81. hp:=new(pconstsym,init_def(name,constord,p^.value,p^.resulttype))
  82. else internalerror(111);
  83. end;
  84. stringconstn:
  85. begin
  86. getmem(sp,p^.length+1);
  87. move(p^.value_str^,sp^,p^.length+1);
  88. hp:=new(pconstsym,init_string(name,conststring,sp,p^.length));
  89. end;
  90. realconstn :
  91. begin
  92. new(pd);
  93. pd^:=p^.value_real;
  94. hp:=new(pconstsym,init(name,constreal,longint(pd)));
  95. end;
  96. setconstn :
  97. begin
  98. new(ps);
  99. ps^:=p^.value_set^;
  100. hp:=new(pconstsym,init_def(name,constset,longint(ps),p^.resulttype));
  101. end;
  102. pointerconstn :
  103. begin
  104. hp:=new(pconstsym,init_def(name,constpointer,p^.value,p^.resulttype));
  105. end;
  106. niln :
  107. begin
  108. hp:=new(pconstsym,init_def(name,constnil,0,p^.resulttype));
  109. end;
  110. else
  111. Message(cg_e_illegal_expression);
  112. end;
  113. tokenpos:=storetokenpos;
  114. disposetree(p);
  115. readconstant:=hp;
  116. end;
  117. procedure parameter_dec(aktprocdef:pabstractprocdef);
  118. {
  119. handle_procvar needs the same changes
  120. }
  121. var
  122. is_procvar : boolean;
  123. sc : Pstringcontainer;
  124. s : string;
  125. hpos,
  126. storetokenpos : tfileposinfo;
  127. tt : ttype;
  128. hvs,
  129. vs : Pvarsym;
  130. hs1,hs2 : string;
  131. varspez : Tvarspez;
  132. inserthigh : boolean;
  133. pdefaultvalue : pconstsym;
  134. defaultrequired : boolean;
  135. begin
  136. { reset }
  137. defaultrequired:=false;
  138. { parsing a proc or procvar ? }
  139. is_procvar:=(aktprocdef^.deftype=procvardef);
  140. consume(_LKLAMMER);
  141. inc(testcurobject);
  142. repeat
  143. if try_to_consume(_VAR) then
  144. varspez:=vs_var
  145. else
  146. if try_to_consume(_CONST) then
  147. varspez:=vs_const
  148. else
  149. if try_to_consume(_OUT) then
  150. varspez:=vs_out
  151. else
  152. varspez:=vs_value;
  153. inserthigh:=false;
  154. pdefaultvalue:=nil;
  155. tt.reset;
  156. { self is only allowed in procvars and class methods }
  157. if (idtoken=_SELF) and
  158. (is_procvar or
  159. (assigned(procinfo^._class) and procinfo^._class^.is_class)) then
  160. begin
  161. if not is_procvar then
  162. begin
  163. {$ifndef UseNiceNames}
  164. hs2:=hs2+'$'+'self';
  165. {$else UseNiceNames}
  166. hs2:=hs2+tostr(length('self'))+'self';
  167. {$endif UseNiceNames}
  168. vs:=new(Pvarsym,initdef('@',procinfo^._class));
  169. vs^.varspez:=vs_var;
  170. { insert the sym in the parasymtable }
  171. pprocdef(aktprocdef)^.parast^.insert(vs);
  172. include(aktprocdef^.procoptions,po_containsself);
  173. inc(procinfo^.selfpointer_offset,vs^.address);
  174. end;
  175. consume(idtoken);
  176. consume(_COLON);
  177. single_type(tt,hs1,false);
  178. aktprocdef^.concatpara(tt,vs_value,nil);
  179. { check the types for procedures only }
  180. if not is_procvar then
  181. CheckTypes(tt.def,procinfo^._class);
  182. end
  183. else
  184. begin
  185. { read identifiers }
  186. sc:=idlist;
  187. {$ifdef fixLeaksOnError}
  188. strContStack.push(sc);
  189. {$endif fixLeaksOnError}
  190. { read type declaration, force reading for value and const paras }
  191. if (token=_COLON) or (varspez=vs_value) then
  192. begin
  193. consume(_COLON);
  194. { check for an open array }
  195. if token=_ARRAY then
  196. begin
  197. consume(_ARRAY);
  198. consume(_OF);
  199. { define range and type of range }
  200. tt.setdef(new(Parraydef,init(0,-1,s32bitdef)));
  201. { array of const ? }
  202. if (token=_CONST) and (m_objpas in aktmodeswitches) then
  203. begin
  204. consume(_CONST);
  205. srsym:=nil;
  206. getsymonlyin(systemunit,'TVARREC');
  207. if not assigned(srsym) then
  208. InternalError(1234124);
  209. Parraydef(tt.def)^.elementtype:=ptypesym(srsym)^.restype;
  210. Parraydef(tt.def)^.IsArrayOfConst:=true;
  211. hs1:='array_of_const';
  212. end
  213. else
  214. begin
  215. { define field type }
  216. single_type(parraydef(tt.def)^.elementtype,hs1,false);
  217. hs1:='array_of_'+hs1;
  218. end;
  219. inserthigh:=true;
  220. end
  221. else
  222. begin
  223. { open string ? }
  224. if (varspez=vs_var) and
  225. (
  226. (
  227. ((token=_STRING) or (idtoken=_SHORTSTRING)) and
  228. (cs_openstring in aktmoduleswitches) and
  229. not(cs_ansistrings in aktlocalswitches)
  230. ) or
  231. (idtoken=_OPENSTRING)) then
  232. begin
  233. consume(token);
  234. tt.setdef(openshortstringdef);
  235. hs1:='openstring';
  236. inserthigh:=true;
  237. end
  238. else
  239. begin
  240. { everything else }
  241. single_type(tt,hs1,false);
  242. end;
  243. { default parameter }
  244. if (m_default_para in aktmodeswitches) then
  245. begin
  246. if try_to_consume(_EQUAL) then
  247. begin
  248. s:=sc^.get_with_tokeninfo(hpos);
  249. if not sc^.empty then
  250. Comment(V_Error,'default value only allowed for one parameter');
  251. sc^.insert_with_tokeninfo(s,hpos);
  252. { prefix 'def' to the parameter name }
  253. pdefaultvalue:=ReadConstant('$def'+Upper(s),hpos);
  254. if assigned(pdefaultvalue) then
  255. pprocdef(aktprocdef)^.parast^.insert(pdefaultvalue);
  256. defaultrequired:=true;
  257. end
  258. else
  259. begin
  260. if defaultrequired then
  261. Comment(V_Error,'default parameter required');
  262. end;
  263. end;
  264. end;
  265. end
  266. else
  267. begin
  268. {$ifndef UseNiceNames}
  269. hs1:='$$$';
  270. {$else UseNiceNames}
  271. hs1:='var';
  272. {$endif UseNiceNames}
  273. tt.setdef(cformaldef);
  274. end;
  275. if not is_procvar then
  276. hs2:=pprocdef(aktprocdef)^.mangledname;
  277. storetokenpos:=tokenpos;
  278. while not sc^.empty do
  279. begin
  280. s:=sc^.get_with_tokeninfo(tokenpos);
  281. aktprocdef^.concatpara(tt,varspez,pdefaultvalue);
  282. { For proc vars we only need the definitions }
  283. if not is_procvar then
  284. begin
  285. {$ifndef UseNiceNames}
  286. hs2:=hs2+'$'+hs1;
  287. {$else UseNiceNames}
  288. hs2:=hs2+tostr(length(hs1))+hs1;
  289. {$endif UseNiceNames}
  290. vs:=new(pvarsym,init(s,tt));
  291. vs^.varspez:=varspez;
  292. { we have to add this to avoid var param to be in registers !!!}
  293. { I don't understand the comment above, }
  294. { but I suppose the comment is wrong and }
  295. { it means that the address of var parameters can be placed }
  296. { in a register (FK) }
  297. if (varspez in [vs_var,vs_const,vs_out]) and push_addr_param(tt.def) then
  298. include(vs^.varoptions,vo_regable);
  299. { insert the sym in the parasymtable }
  300. pprocdef(aktprocdef)^.parast^.insert(vs);
  301. { do we need a local copy? Then rename the varsym, do this after the
  302. insert so the dup id checking is done correctly }
  303. if (varspez=vs_value) and
  304. push_addr_param(tt.def) and
  305. not(is_open_array(tt.def) or is_array_of_const(tt.def)) then
  306. pprocdef(aktprocdef)^.parast^.rename(vs^.name,'val'+vs^.name);
  307. { also need to push a high value? }
  308. if inserthigh then
  309. begin
  310. hvs:=new(Pvarsym,initdef('$high'+Upper(s),s32bitdef));
  311. hvs^.varspez:=vs_const;
  312. pprocdef(aktprocdef)^.parast^.insert(hvs);
  313. end;
  314. end;
  315. end;
  316. {$ifdef fixLeaksOnError}
  317. if PStringContainer(strContStack.pop) <> sc then
  318. writeln('problem with strContStack in pdecl (1)');
  319. {$endif fixLeaksOnError}
  320. dispose(sc,done);
  321. tokenpos:=storetokenpos;
  322. end;
  323. { set the new mangled name }
  324. if not is_procvar then
  325. pprocdef(aktprocdef)^.setmangledname(hs2);
  326. until not try_to_consume(_SEMICOLON);
  327. dec(testcurobject);
  328. consume(_RKLAMMER);
  329. end;
  330. const
  331. variantrecordlevel : longint = 0;
  332. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  333. { reads the filed of a record into a }
  334. { symtablestack, if record=false }
  335. { variants are forbidden, so this procedure }
  336. { can be used to read object fields }
  337. { if absolute is true, ABSOLUTE and file }
  338. { types are allowed }
  339. { => the procedure is also used to read }
  340. { a sequence of variable declaration }
  341. procedure insert_syms(st : psymtable;sc : pstringcontainer;tt : ttype;is_threadvar : boolean);
  342. { inserts the symbols of sc in st with def as definition or sym as ptypesym, sc is disposed }
  343. var
  344. s : string;
  345. filepos : tfileposinfo;
  346. ss : pvarsym;
  347. begin
  348. filepos:=tokenpos;
  349. while not sc^.empty do
  350. begin
  351. s:=sc^.get_with_tokeninfo(tokenpos);
  352. ss:=new(pvarsym,init(s,tt));
  353. if is_threadvar then
  354. include(ss^.varoptions,vo_is_thread_var);
  355. st^.insert(ss);
  356. { static data fields are inserted in the globalsymtable }
  357. if (st^.symtabletype=objectsymtable) and
  358. (sp_static in current_object_option) then
  359. begin
  360. s:=lower(st^.name^)+'_'+s;
  361. st^.defowner^.owner^.insert(new(pvarsym,init(s,tt)));
  362. end;
  363. end;
  364. {$ifdef fixLeaksOnError}
  365. if strContStack.pop <> sc then
  366. writeln('problem with strContStack in pdecl (2)');
  367. {$endif fixLeaksOnError}
  368. dispose(sc,done);
  369. tokenpos:=filepos;
  370. end;
  371. var
  372. sc : pstringcontainer;
  373. s : stringid;
  374. old_block_type : tblock_type;
  375. declarepos,storetokenpos : tfileposinfo;
  376. symdone : boolean;
  377. { to handle absolute }
  378. abssym : pabsolutesym;
  379. l : longint;
  380. code : integer;
  381. { c var }
  382. newtype : ptypesym;
  383. is_dll,
  384. is_gpc_name,is_cdecl,extern_aktvarsym,export_aktvarsym : boolean;
  385. old_current_object_option : tsymoptions;
  386. dll_name,
  387. C_name : string;
  388. tt,casetype : ttype;
  389. { Delphi initialized vars }
  390. pconstsym : ptypedconstsym;
  391. { maxsize contains the max. size of a variant }
  392. { startvarrec contains the start of the variant part of a record }
  393. maxsize,maxalignment,startvarrecalign,startvarrecsize : longint;
  394. pt : ptree;
  395. {$ifdef UseUnionSymtable}
  396. unionsymtable : psymtable;
  397. offset : longint;
  398. uniondef : precorddef;
  399. unionsym : pvarsym;
  400. uniontype : ttype;
  401. {$endif UseUnionSymtable}
  402. begin
  403. old_current_object_option:=current_object_option;
  404. { all variables are public if not in a object declaration }
  405. if not is_object then
  406. current_object_option:=[sp_public];
  407. old_block_type:=block_type;
  408. block_type:=bt_type;
  409. is_gpc_name:=false;
  410. { Force an expected ID error message }
  411. if not (token in [_ID,_CASE,_END]) then
  412. consume(_ID);
  413. { read vars }
  414. while (token=_ID) and
  415. not(is_object and (idtoken in [_PUBLIC,_PRIVATE,_PUBLISHED,_PROTECTED])) do
  416. begin
  417. C_name:=orgpattern;
  418. sc:=idlist;
  419. {$ifdef fixLeaksOnError}
  420. strContStack.push(sc);
  421. {$endif fixLeaksOnError}
  422. consume(_COLON);
  423. if (m_gpc in aktmodeswitches) and
  424. not(is_record or is_object or is_threadvar) and
  425. (token=_ID) and (orgpattern='__asmname__') then
  426. begin
  427. consume(_ID);
  428. C_name:=pattern;
  429. if token=_CCHAR then
  430. consume(_CCHAR)
  431. else
  432. consume(_CSTRING);
  433. Is_gpc_name:=true;
  434. end;
  435. { this is needed for Delphi mode at least
  436. but should be OK for all modes !! (PM) }
  437. ignore_equal:=true;
  438. read_type(tt,'');
  439. if (variantrecordlevel>0) and tt.def^.needs_inittable then
  440. Message(parser_e_cant_use_inittable_here);
  441. ignore_equal:=false;
  442. symdone:=false;
  443. if is_gpc_name then
  444. begin
  445. storetokenpos:=tokenpos;
  446. s:=sc^.get_with_tokeninfo(tokenpos);
  447. if not sc^.empty then
  448. Message(parser_e_absolute_only_one_var);
  449. {$ifdef fixLeaksOnError}
  450. if strContStack.pop <> sc then
  451. writeln('problem with strContStack in pdecl (3)');
  452. {$endif fixLeaksOnError}
  453. dispose(sc,done);
  454. aktvarsym:=new(pvarsym,init_C(s,target_os.Cprefix+C_name,tt));
  455. include(aktvarsym^.varoptions,vo_is_external);
  456. symtablestack^.insert(aktvarsym);
  457. tokenpos:=storetokenpos;
  458. symdone:=true;
  459. end;
  460. { check for absolute }
  461. if not symdone and
  462. (idtoken=_ABSOLUTE) and not(is_record or is_object or is_threadvar) then
  463. begin
  464. consume(_ABSOLUTE);
  465. { only allowed for one var }
  466. s:=sc^.get_with_tokeninfo(declarepos);
  467. if not sc^.empty then
  468. Message(parser_e_absolute_only_one_var);
  469. {$ifdef fixLeaksOnError}
  470. if strContStack.pop <> sc then
  471. writeln('problem with strContStack in pdecl (4)');
  472. {$endif fixLeaksOnError}
  473. dispose(sc,done);
  474. { parse the rest }
  475. if token=_ID then
  476. begin
  477. getsym(pattern,true);
  478. consume(_ID);
  479. { support unit.variable }
  480. if srsym^.typ=unitsym then
  481. begin
  482. consume(_POINT);
  483. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  484. consume(_ID);
  485. end;
  486. { we should check the result type of srsym }
  487. if not (srsym^.typ in [varsym,typedconstsym,funcretsym]) then
  488. Message(parser_e_absolute_only_to_var_or_const);
  489. storetokenpos:=tokenpos;
  490. tokenpos:=declarepos;
  491. abssym:=new(pabsolutesym,init(s,tt));
  492. abssym^.abstyp:=tovar;
  493. abssym^.ref:=srsym;
  494. symtablestack^.insert(abssym);
  495. tokenpos:=storetokenpos;
  496. end
  497. else
  498. if (token=_CSTRING) or (token=_CCHAR) then
  499. begin
  500. storetokenpos:=tokenpos;
  501. tokenpos:=declarepos;
  502. abssym:=new(pabsolutesym,init(s,tt));
  503. s:=pattern;
  504. consume(token);
  505. abssym^.abstyp:=toasm;
  506. abssym^.asmname:=stringdup(s);
  507. symtablestack^.insert(abssym);
  508. tokenpos:=storetokenpos;
  509. end
  510. else
  511. { absolute address ?!? }
  512. if token=_INTCONST then
  513. begin
  514. if (target_info.target=target_i386_go32v2) then
  515. begin
  516. storetokenpos:=tokenpos;
  517. tokenpos:=declarepos;
  518. abssym:=new(pabsolutesym,init(s,tt));
  519. abssym^.abstyp:=toaddr;
  520. abssym^.absseg:=false;
  521. s:=pattern;
  522. consume(_INTCONST);
  523. val(s,abssym^.address,code);
  524. if token=_COLON then
  525. begin
  526. consume(token);
  527. s:=pattern;
  528. consume(_INTCONST);
  529. val(s,l,code);
  530. abssym^.address:=abssym^.address shl 4+l;
  531. abssym^.absseg:=true;
  532. end;
  533. symtablestack^.insert(abssym);
  534. tokenpos:=storetokenpos;
  535. end
  536. else
  537. Message(parser_e_absolute_only_to_var_or_const);
  538. end
  539. else
  540. Message(parser_e_absolute_only_to_var_or_const);
  541. symdone:=true;
  542. end;
  543. { Handling of Delphi typed const = initialized vars ! }
  544. { When should this be rejected ?
  545. - in parasymtable
  546. - in record or object
  547. - ... (PM) }
  548. if (m_delphi in aktmodeswitches) and (token=_EQUAL) and
  549. not (symtablestack^.symtabletype in [parasymtable]) and
  550. not is_record and not is_object then
  551. begin
  552. storetokenpos:=tokenpos;
  553. s:=sc^.get_with_tokeninfo(tokenpos);
  554. if not sc^.empty then
  555. Message(parser_e_initialized_only_one_var);
  556. pconstsym:=new(ptypedconstsym,inittype(s,tt,false));
  557. symtablestack^.insert(pconstsym);
  558. tokenpos:=storetokenpos;
  559. consume(_EQUAL);
  560. readtypedconst(tt.def,pconstsym,false);
  561. symdone:=true;
  562. end;
  563. { for a record there doesn't need to be a ; before the END or ) }
  564. if not((is_record or is_object) and (token in [_END,_RKLAMMER])) then
  565. consume(_SEMICOLON);
  566. { procvar handling }
  567. if (tt.def^.deftype=procvardef) and (tt.def^.typesym=nil) then
  568. begin
  569. newtype:=new(ptypesym,init('unnamed',tt));
  570. parse_var_proc_directives(psym(newtype));
  571. newtype^.restype.def:=nil;
  572. tt.def^.typesym:=nil;
  573. dispose(newtype,done);
  574. end;
  575. { Check for variable directives }
  576. if not symdone and (token=_ID) then
  577. begin
  578. { Check for C Variable declarations }
  579. if (m_cvar_support in aktmodeswitches) and
  580. not(is_record or is_object or is_threadvar) and
  581. (idtoken in [_EXPORT,_EXTERNAL,_PUBLIC,_CVAR]) then
  582. begin
  583. { only allowed for one var }
  584. s:=sc^.get_with_tokeninfo(declarepos);
  585. if not sc^.empty then
  586. Message(parser_e_absolute_only_one_var);
  587. {$ifdef fixLeaksOnError}
  588. if strContStack.pop <> sc then
  589. writeln('problem with strContStack in pdecl (5)');
  590. {$endif fixLeaksOnError}
  591. dispose(sc,done);
  592. { defaults }
  593. is_dll:=false;
  594. is_cdecl:=false;
  595. extern_aktvarsym:=false;
  596. export_aktvarsym:=false;
  597. { cdecl }
  598. if idtoken=_CVAR then
  599. begin
  600. consume(_CVAR);
  601. consume(_SEMICOLON);
  602. is_cdecl:=true;
  603. C_name:=target_os.Cprefix+C_name;
  604. end;
  605. { external }
  606. if idtoken=_EXTERNAL then
  607. begin
  608. consume(_EXTERNAL);
  609. extern_aktvarsym:=true;
  610. end;
  611. { export }
  612. if idtoken in [_EXPORT,_PUBLIC] then
  613. begin
  614. consume(_ID);
  615. if extern_aktvarsym or
  616. (symtablestack^.symtabletype in [parasymtable,localsymtable]) then
  617. Message(parser_e_not_external_and_export)
  618. else
  619. export_aktvarsym:=true;
  620. end;
  621. { external and export need a name after when no cdecl is used }
  622. if not is_cdecl then
  623. begin
  624. { dll name ? }
  625. if (extern_aktvarsym) and (idtoken<>_NAME) then
  626. begin
  627. is_dll:=true;
  628. dll_name:=get_stringconst;
  629. end;
  630. consume(_NAME);
  631. C_name:=get_stringconst;
  632. end;
  633. { consume the ; when export or external is used }
  634. if extern_aktvarsym or export_aktvarsym then
  635. consume(_SEMICOLON);
  636. { insert in the symtable }
  637. storetokenpos:=tokenpos;
  638. tokenpos:=declarepos;
  639. if is_dll then
  640. aktvarsym:=new(pvarsym,init_dll(s,tt))
  641. else
  642. aktvarsym:=new(pvarsym,init_C(s,C_name,tt));
  643. { set some vars options }
  644. if export_aktvarsym then
  645. begin
  646. inc(aktvarsym^.refs);
  647. include(aktvarsym^.varoptions,vo_is_exported);
  648. end;
  649. if extern_aktvarsym then
  650. include(aktvarsym^.varoptions,vo_is_external);
  651. { insert in the stack/datasegment }
  652. symtablestack^.insert(aktvarsym);
  653. tokenpos:=storetokenpos;
  654. { now we can insert it in the import lib if its a dll, or
  655. add it to the externals }
  656. if extern_aktvarsym then
  657. begin
  658. if is_dll then
  659. begin
  660. if not(current_module^.uses_imports) then
  661. begin
  662. current_module^.uses_imports:=true;
  663. importlib^.preparelib(current_module^.modulename^);
  664. end;
  665. importlib^.importvariable(aktvarsym^.mangledname,dll_name,C_name)
  666. end
  667. end;
  668. symdone:=true;
  669. end
  670. else
  671. if (is_object) and (cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
  672. begin
  673. include(current_object_option,sp_static);
  674. insert_syms(symtablestack,sc,tt,false);
  675. exclude(current_object_option,sp_static);
  676. consume(_STATIC);
  677. consume(_SEMICOLON);
  678. symdone:=true;
  679. end;
  680. end;
  681. { insert it in the symtable, if not done yet }
  682. if not symdone then
  683. begin
  684. { save object option, because we can turn of the sp_published }
  685. if (sp_published in current_object_option) and
  686. (not((tt.def^.deftype=objectdef) and (pobjectdef(tt.def)^.is_class))) then
  687. begin
  688. Message(parser_e_cant_publish_that);
  689. exclude(current_object_option,sp_published);
  690. end
  691. else
  692. if (sp_published in current_object_option) and
  693. not(oo_can_have_published in pobjectdef(tt.def)^.objectoptions) then
  694. begin
  695. Message(parser_e_only_publishable_classes_can__be_published);
  696. exclude(current_object_option,sp_published);
  697. end;
  698. insert_syms(symtablestack,sc,tt,is_threadvar);
  699. current_object_option:=old_current_object_option;
  700. end;
  701. end;
  702. { Check for Case }
  703. if is_record and (token=_CASE) then
  704. begin
  705. maxsize:=0;
  706. maxalignment:=0;
  707. consume(_CASE);
  708. s:=pattern;
  709. getsym(s,false);
  710. { may be only a type: }
  711. if assigned(srsym) and (srsym^.typ in [typesym,unitsym]) then
  712. read_type(casetype,'')
  713. else
  714. begin
  715. consume(_ID);
  716. consume(_COLON);
  717. read_type(casetype,'');
  718. symtablestack^.insert(new(pvarsym,init(s,casetype)));
  719. end;
  720. if not(is_ordinal(casetype.def)) or is_64bitint(casetype.def) then
  721. Message(type_e_ordinal_expr_expected);
  722. consume(_OF);
  723. {$ifdef UseUnionSymtable}
  724. UnionSymtable:=new(psymtable,init(recordsymtable));
  725. UnionSymtable^.next:=symtablestack;
  726. registerdef:=false;
  727. UnionDef:=new(precorddef,init(unionsymtable));
  728. registerdef:=true;
  729. symtablestack:=UnionSymtable;
  730. {$endif UseUnionSymtable}
  731. startvarrecsize:=symtablestack^.datasize;
  732. startvarrecalign:=symtablestack^.dataalignment;
  733. repeat
  734. repeat
  735. pt:=comp_expr(true);
  736. do_firstpass(pt);
  737. if not(pt^.treetype=ordconstn) then
  738. Message(cg_e_illegal_expression);
  739. disposetree(pt);
  740. if token=_COMMA then
  741. consume(_COMMA)
  742. else
  743. break;
  744. until false;
  745. consume(_COLON);
  746. { read the vars }
  747. consume(_LKLAMMER);
  748. inc(variantrecordlevel);
  749. if token<>_RKLAMMER then
  750. read_var_decs(true,false,false);
  751. dec(variantrecordlevel);
  752. consume(_RKLAMMER);
  753. { calculates maximal variant size }
  754. maxsize:=max(maxsize,symtablestack^.datasize);
  755. maxalignment:=max(maxalignment,symtablestack^.dataalignment);
  756. { the items of the next variant are overlayed }
  757. symtablestack^.datasize:=startvarrecsize;
  758. symtablestack^.dataalignment:=startvarrecalign;
  759. if (token<>_END) and (token<>_RKLAMMER) then
  760. consume(_SEMICOLON)
  761. else
  762. break;
  763. until (token=_END) or (token=_RKLAMMER);
  764. { at last set the record size to that of the biggest variant }
  765. symtablestack^.datasize:=maxsize;
  766. symtablestack^.dataalignment:=maxalignment;
  767. {$ifdef UseUnionSymtable}
  768. uniontype.def:=uniondef;
  769. uniontype.sym:=nil;
  770. UnionSym:=new(pvarsym,init('case',uniontype));
  771. symtablestack:=symtablestack^.next;
  772. { we do NOT call symtablestack^.insert
  773. on purpose PM }
  774. offset:=align_from_size(symtablestack^.datasize,maxalignment);
  775. symtablestack^.datasize:=offset+unionsymtable^.datasize;
  776. if maxalignment>symtablestack^.dataalignment then
  777. symtablestack^.dataalignment:=maxalignment;
  778. UnionSymtable^.Insert_in(symtablestack,offset);
  779. UnionSym^.owner:=nil;
  780. dispose(unionsym,done);
  781. dispose(uniondef,done);
  782. {$endif UseUnionSymtable}
  783. end;
  784. block_type:=old_block_type;
  785. current_object_option:=old_current_object_option;
  786. end;
  787. procedure const_dec;
  788. var
  789. name : stringid;
  790. tt : ttype;
  791. sym : psym;
  792. storetokenpos,filepos : tfileposinfo;
  793. old_block_type : tblock_type;
  794. skipequal : boolean;
  795. begin
  796. consume(_CONST);
  797. old_block_type:=block_type;
  798. block_type:=bt_const;
  799. repeat
  800. name:=pattern;
  801. filepos:=tokenpos;
  802. consume(_ID);
  803. case token of
  804. _EQUAL:
  805. begin
  806. consume(_EQUAL);
  807. sym:=readconstant(name,filepos);
  808. if assigned(sym) then
  809. symtablestack^.insert(sym);
  810. consume(_SEMICOLON);
  811. end;
  812. _COLON:
  813. begin
  814. { set the blocktype first so a consume also supports a
  815. caret, to support const s : ^string = nil }
  816. block_type:=bt_type;
  817. consume(_COLON);
  818. ignore_equal:=true;
  819. read_type(tt,'');
  820. ignore_equal:=false;
  821. block_type:=bt_const;
  822. skipequal:=false;
  823. { create symbol }
  824. storetokenpos:=tokenpos;
  825. tokenpos:=filepos;
  826. {$ifdef DELPHI_CONST_IN_RODATA}
  827. if m_delphi in aktmodeswitches then
  828. begin
  829. if assigned(readtypesym) then
  830. sym:=new(ptypedconstsym,initsym(name,readtypesym,true))
  831. else
  832. sym:=new(ptypedconstsym,init(name,def,true))
  833. end
  834. else
  835. {$endif DELPHI_CONST_IN_RODATA}
  836. begin
  837. sym:=new(ptypedconstsym,inittype(name,tt,false))
  838. end;
  839. tokenpos:=storetokenpos;
  840. symtablestack^.insert(sym);
  841. { procvar can have proc directives }
  842. if (tt.def^.deftype=procvardef) then
  843. begin
  844. { support p : procedure;stdcall=nil; }
  845. if (token=_SEMICOLON) then
  846. begin
  847. consume(_SEMICOLON);
  848. if is_proc_directive(token) then
  849. parse_var_proc_directives(sym)
  850. else
  851. begin
  852. Message(parser_e_proc_directive_expected);
  853. skipequal:=true;
  854. end;
  855. end
  856. else
  857. { support p : procedure stdcall=nil; }
  858. begin
  859. if is_proc_directive(token) then
  860. parse_var_proc_directives(sym);
  861. end;
  862. end;
  863. if not skipequal then
  864. begin
  865. { get init value }
  866. consume(_EQUAL);
  867. {$ifdef DELPHI_CONST_IN_RODATA}
  868. if m_delphi in aktmodeswitches then
  869. readtypedconst(tt.def,ptypedconstsym(sym),true)
  870. else
  871. {$endif DELPHI_CONST_IN_RODATA}
  872. readtypedconst(tt.def,ptypedconstsym(sym),false);
  873. consume(_SEMICOLON);
  874. end;
  875. end;
  876. else
  877. { generate an error }
  878. consume(_EQUAL);
  879. end;
  880. until token<>_ID;
  881. block_type:=old_block_type;
  882. end;
  883. procedure label_dec;
  884. var
  885. hl : pasmlabel;
  886. begin
  887. consume(_LABEL);
  888. if not(cs_support_goto in aktmoduleswitches) then
  889. Message(sym_e_goto_and_label_not_supported);
  890. repeat
  891. if not(token in [_ID,_INTCONST]) then
  892. consume(_ID)
  893. else
  894. begin
  895. if (cs_create_smart in aktmoduleswitches) then
  896. begin
  897. getdatalabel(hl);
  898. { we still want a warning if unused }
  899. hl^.refs:=0;
  900. end
  901. else
  902. getlabel(hl);
  903. symtablestack^.insert(new(plabelsym,init(pattern,hl)));
  904. consume(token);
  905. end;
  906. if token<>_SEMICOLON then consume(_COMMA);
  907. until not(token in [_ID,_INTCONST]);
  908. consume(_SEMICOLON);
  909. end;
  910. { search in symtablestack used, but not defined type }
  911. procedure resolve_type_forward(p : pnamedindexobject);{$ifndef FPC}far;{$endif}
  912. var
  913. hpd,pd : pdef;
  914. stpos : tfileposinfo;
  915. again : boolean;
  916. begin
  917. { Check only typesyms or record/object fields }
  918. case psym(p)^.typ of
  919. typesym :
  920. pd:=ptypesym(p)^.restype.def;
  921. varsym :
  922. if (psym(p)^.owner^.symtabletype in [objectsymtable,recordsymtable]) then
  923. pd:=pvarsym(p)^.vartype.def
  924. else
  925. exit;
  926. else
  927. exit;
  928. end;
  929. repeat
  930. again:=false;
  931. case pd^.deftype of
  932. arraydef :
  933. begin
  934. { elementtype could also be defined using a forwarddef }
  935. pd:=parraydef(pd)^.elementtype.def;
  936. again:=true;
  937. end;
  938. pointerdef,
  939. classrefdef :
  940. begin
  941. { classrefdef inherits from pointerdef }
  942. hpd:=ppointerdef(pd)^.pointertype.def;
  943. { still a forward def ? }
  944. if hpd^.deftype=forwarddef then
  945. begin
  946. { try to resolve the forward }
  947. { get the correct position for it }
  948. stpos:=tokenpos;
  949. tokenpos:=pforwarddef(hpd)^.forwardpos;
  950. resolving_forward:=true;
  951. make_ref:=false;
  952. getsym(pforwarddef(hpd)^.tosymname,false);
  953. make_ref:=true;
  954. resolving_forward:=false;
  955. tokenpos:=stpos;
  956. { we don't need the forwarddef anymore, dispose it }
  957. dispose(hpd,done);
  958. { was a type sym found ? }
  959. if assigned(srsym) and
  960. (srsym^.typ=typesym) then
  961. begin
  962. ppointerdef(pd)^.pointertype.setsym(srsym);
  963. { avoid wrong unused warnings web bug 801 PM }
  964. inc(srsym^.refs);
  965. {$ifdef GDB}
  966. if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist) and
  967. (psym(p)^.owner^.symtabletype in [globalsymtable,staticsymtable]) then
  968. begin
  969. ptypesym(p)^.isusedinstab := true;
  970. psym(p)^.concatstabto(debuglist);
  971. end;
  972. {$endif GDB}
  973. { we need a class type for classrefdef }
  974. if (pd^.deftype=classrefdef) and
  975. not((ptypesym(srsym)^.restype.def^.deftype=objectdef) and
  976. pobjectdef(ptypesym(srsym)^.restype.def)^.is_class) then
  977. Message1(type_e_class_type_expected,ptypesym(srsym)^.restype.def^.typename);
  978. end
  979. else
  980. begin
  981. MessagePos1(psym(p)^.fileinfo,sym_e_forward_type_not_resolved,p^.name);
  982. { try to recover }
  983. ppointerdef(pd)^.pointertype.def:=generrordef;
  984. end;
  985. end;
  986. end;
  987. recorddef :
  988. precorddef(pd)^.symtable^.foreach({$ifndef TP}@{$endif}resolve_type_forward);
  989. objectdef :
  990. begin
  991. if not(m_fpc in aktmodeswitches) and
  992. (oo_is_forward in pobjectdef(pd)^.objectoptions) then
  993. begin
  994. { only give an error as the implementation may follow in an
  995. other type block which is allowed by FPC modes }
  996. MessagePos1(psym(p)^.fileinfo,sym_e_forward_type_not_resolved,p^.name);
  997. end
  998. else
  999. begin
  1000. { Check all fields of the object declaration, but don't
  1001. check objectdefs in objects/records, because these
  1002. can't exist (anonymous objects aren't allowed) }
  1003. if not(psym(p)^.owner^.symtabletype in [objectsymtable,recordsymtable]) then
  1004. pobjectdef(pd)^.symtable^.foreach({$ifndef TP}@{$endif}resolve_type_forward);
  1005. end;
  1006. end;
  1007. end;
  1008. until not again;
  1009. end;
  1010. { reads a type declaration to the symbol table }
  1011. procedure type_dec;
  1012. var
  1013. typename,orgtypename : stringid;
  1014. newtype : ptypesym;
  1015. sym : psym;
  1016. tt : ttype;
  1017. defpos,storetokenpos : tfileposinfo;
  1018. old_block_type : tblock_type;
  1019. begin
  1020. old_block_type:=block_type;
  1021. block_type:=bt_type;
  1022. consume(_TYPE);
  1023. typecanbeforward:=true;
  1024. repeat
  1025. typename:=pattern;
  1026. orgtypename:=orgpattern;
  1027. defpos:=tokenpos;
  1028. consume(_ID);
  1029. consume(_EQUAL);
  1030. { support 'ttype=type word' syntax }
  1031. if token=_TYPE then
  1032. Consume(_TYPE);
  1033. { is the type already defined? }
  1034. getsym(typename,false);
  1035. sym:=srsym;
  1036. newtype:=nil;
  1037. { found a symbol with this name? }
  1038. if assigned(sym) then
  1039. begin
  1040. if (sym^.typ=typesym) then
  1041. begin
  1042. if (token=_CLASS) and
  1043. (assigned(ptypesym(sym)^.restype.def)) and
  1044. (ptypesym(sym)^.restype.def^.deftype=objectdef) and
  1045. pobjectdef(ptypesym(sym)^.restype.def)^.is_class and
  1046. (oo_is_forward in pobjectdef(ptypesym(sym)^.restype.def)^.objectoptions) then
  1047. begin
  1048. { we can ignore the result }
  1049. { the definition is modified }
  1050. object_dec(orgtypename,pobjectdef(ptypesym(sym)^.restype.def));
  1051. newtype:=ptypesym(sym);
  1052. end;
  1053. end;
  1054. end;
  1055. { no old type reused ? Then insert this new type }
  1056. if not assigned(newtype) then
  1057. begin
  1058. { insert the new type first with an errordef, so that
  1059. referencing the type before it's really set it
  1060. will give an error (PFV) }
  1061. tt.setdef(generrordef);
  1062. storetokenpos:=tokenpos;
  1063. newtype:=new(ptypesym,init(orgtypename,tt));
  1064. symtablestack^.insert(newtype);
  1065. tokenpos:=defpos;
  1066. tokenpos:=storetokenpos;
  1067. { read the type definition }
  1068. read_type(tt,orgtypename);
  1069. { update the definition of the type }
  1070. newtype^.restype:=tt;
  1071. if not assigned(tt.sym) then
  1072. tt.sym:=newtype;
  1073. if assigned(tt.def) and not assigned(tt.def^.typesym) then
  1074. tt.def^.typesym:=newtype;
  1075. end;
  1076. if assigned(newtype^.restype.def) and
  1077. (newtype^.restype.def^.deftype=procvardef) then
  1078. begin
  1079. if not is_proc_directive(token) then
  1080. consume(_SEMICOLON);
  1081. parse_var_proc_directives(psym(newtype));
  1082. end
  1083. else
  1084. consume(_SEMICOLON);
  1085. until token<>_ID;
  1086. typecanbeforward:=false;
  1087. symtablestack^.foreach({$ifndef TP}@{$endif}resolve_type_forward);
  1088. block_type:=old_block_type;
  1089. end;
  1090. procedure var_dec;
  1091. { parses variable declarations and inserts them in }
  1092. { the top symbol table of symtablestack }
  1093. begin
  1094. consume(_VAR);
  1095. read_var_decs(false,false,false);
  1096. end;
  1097. procedure threadvar_dec;
  1098. { parses thread variable declarations and inserts them in }
  1099. { the top symbol table of symtablestack }
  1100. begin
  1101. consume(_THREADVAR);
  1102. if not(symtablestack^.symtabletype in [staticsymtable,globalsymtable]) then
  1103. message(parser_e_threadvars_only_sg);
  1104. read_var_decs(false,false,true);
  1105. end;
  1106. procedure resourcestring_dec;
  1107. var
  1108. name : stringid;
  1109. p : ptree;
  1110. storetokenpos,filepos : tfileposinfo;
  1111. old_block_type : tblock_type;
  1112. sp : pchar;
  1113. begin
  1114. consume(_RESOURCESTRING);
  1115. if not(symtablestack^.symtabletype in [staticsymtable,globalsymtable]) then
  1116. message(parser_e_resourcestring_only_sg);
  1117. old_block_type:=block_type;
  1118. block_type:=bt_const;
  1119. repeat
  1120. name:=pattern;
  1121. filepos:=tokenpos;
  1122. consume(_ID);
  1123. case token of
  1124. _EQUAL:
  1125. begin
  1126. consume(_EQUAL);
  1127. p:=comp_expr(true);
  1128. do_firstpass(p);
  1129. storetokenpos:=tokenpos;
  1130. tokenpos:=filepos;
  1131. case p^.treetype of
  1132. ordconstn:
  1133. begin
  1134. if is_constcharnode(p) then
  1135. begin
  1136. getmem(sp,2);
  1137. sp[0]:=chr(p^.value);
  1138. sp[1]:=#0;
  1139. symtablestack^.insert(new(pconstsym,init_string(name,constresourcestring,sp,1)));
  1140. end
  1141. else
  1142. Message(cg_e_illegal_expression);
  1143. end;
  1144. stringconstn:
  1145. begin
  1146. getmem(sp,p^.length+1);
  1147. move(p^.value_str^,sp^,p^.length+1);
  1148. symtablestack^.insert(new(pconstsym,init_string(name,constresourcestring,sp,p^.length)));
  1149. end;
  1150. else
  1151. Message(cg_e_illegal_expression);
  1152. end;
  1153. tokenpos:=storetokenpos;
  1154. consume(_SEMICOLON);
  1155. disposetree(p);
  1156. end;
  1157. else consume(_EQUAL);
  1158. end;
  1159. until token<>_ID;
  1160. block_type:=old_block_type;
  1161. end;
  1162. procedure Not_supported_for_inline(t : ttoken);
  1163. begin
  1164. if assigned(aktprocsym) and
  1165. (pocall_inline in aktprocsym^.definition^.proccalloptions) then
  1166. Begin
  1167. Message1(parser_w_not_supported_for_inline,tokenstring(t));
  1168. Message(parser_w_inlining_disabled);
  1169. exclude(aktprocsym^.definition^.proccalloptions,pocall_inline);
  1170. End;
  1171. end;
  1172. procedure read_declarations(islibrary : boolean);
  1173. begin
  1174. repeat
  1175. case token of
  1176. _LABEL:
  1177. begin
  1178. Not_supported_for_inline(token);
  1179. label_dec;
  1180. end;
  1181. _CONST:
  1182. begin
  1183. Not_supported_for_inline(token);
  1184. const_dec;
  1185. end;
  1186. _TYPE:
  1187. begin
  1188. Not_supported_for_inline(token);
  1189. type_dec;
  1190. end;
  1191. _VAR:
  1192. var_dec;
  1193. _THREADVAR:
  1194. threadvar_dec;
  1195. _CONSTRUCTOR,_DESTRUCTOR,
  1196. _FUNCTION,_PROCEDURE,_OPERATOR,_CLASS:
  1197. begin
  1198. Not_supported_for_inline(token);
  1199. read_proc;
  1200. end;
  1201. _RESOURCESTRING:
  1202. resourcestring_dec;
  1203. _EXPORTS:
  1204. begin
  1205. Not_supported_for_inline(token);
  1206. { here we should be at lexlevel 1, no ? PM }
  1207. if (lexlevel<>main_program_level) or
  1208. (current_module^.is_unit) then
  1209. begin
  1210. Message(parser_e_syntax_error);
  1211. consume_all_until(_SEMICOLON);
  1212. end
  1213. else if islibrary or (target_info.target=target_i386_WIN32) then
  1214. read_exports;
  1215. end
  1216. else break;
  1217. end;
  1218. until false;
  1219. end;
  1220. procedure read_interface_declarations;
  1221. begin
  1222. {Since the body is now parsed at lexlevel 1, and the declarations
  1223. must be parsed at the same lexlevel we increase the lexlevel.}
  1224. inc(lexlevel);
  1225. repeat
  1226. case token of
  1227. _CONST : const_dec;
  1228. _TYPE : type_dec;
  1229. _VAR : var_dec;
  1230. _THREADVAR : threadvar_dec;
  1231. _RESOURCESTRING:
  1232. resourcestring_dec;
  1233. _FUNCTION,
  1234. _PROCEDURE,
  1235. _OPERATOR : read_proc;
  1236. else
  1237. break;
  1238. end;
  1239. until false;
  1240. dec(lexlevel);
  1241. end;
  1242. end.
  1243. {
  1244. $Log$
  1245. Revision 1.13 2000-08-27 20:19:39 peter
  1246. * store strings with case in ppu, when an internal symbol is created
  1247. a '$' is prefixed so it's not automatic uppercased
  1248. Revision 1.12 2000/08/27 16:11:51 peter
  1249. * moved some util functions from globals,cobjects to cutils
  1250. * splitted files into finput,fmodule
  1251. Revision 1.11 2000/08/20 15:01:17 peter
  1252. * don't allow forward class in separate type blocks for delphi (merged)
  1253. Revision 1.10 2000/08/17 09:17:19 pierre
  1254. * fix go32v2 cycle problem
  1255. Revision 1.9 2000/08/16 18:33:53 peter
  1256. * splitted namedobjectitem.next into indexnext and listnext so it
  1257. can be used in both lists
  1258. * don't allow "word = word" type definitions (merged)
  1259. Revision 1.8 2000/08/13 13:11:28 peter
  1260. * put defaultpara values in parast and changed the name to
  1261. 'def<Parameter name>'
  1262. Revision 1.7 2000/08/13 08:42:59 peter
  1263. * support absolute refering to funcret (merged)
  1264. Revision 1.6 2000/08/02 19:49:59 peter
  1265. * first things for default parameters
  1266. Revision 1.5 2000/07/30 17:04:43 peter
  1267. * merged fixes
  1268. Revision 1.4 2000/07/14 05:11:49 michael
  1269. + Patch to 1.1
  1270. Revision 1.3 2000/07/13 12:08:26 michael
  1271. + patched to 1.1.0 with former 1.09patch from peter
  1272. Revision 1.2 2000/07/13 11:32:44 michael
  1273. + removed logs
  1274. }