pdecvar.pas 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Parses variable declarations. Used for var statement and record
  5. definitions
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit pdecvar;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. symsym,symdef;
  24. function read_property_dec(aclass:tobjectdef):tpropertysym;
  25. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  26. implementation
  27. uses
  28. { common }
  29. cutils,cclasses,
  30. { global }
  31. globtype,globals,tokens,verbose,
  32. systems,
  33. { symtable }
  34. symconst,symbase,symtype,symtable,defutil,defcmp,
  35. fmodule,
  36. { pass 1 }
  37. node,pass_1,
  38. nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,nmem,
  39. { codegen }
  40. ncgutil,
  41. { parser }
  42. scanner,
  43. pbase,pexpr,ptype,ptconst,pdecsub,
  44. { link }
  45. import
  46. {$ifdef Delphi}
  47. ,dmisc
  48. ,sysutils
  49. {$endif}
  50. ;
  51. function read_property_dec(aclass:tobjectdef):tpropertysym;
  52. { convert a node tree to symlist and return the last
  53. symbol }
  54. function parse_symlist(pl:tsymlist;var def:tdef):boolean;
  55. var
  56. idx : longint;
  57. sym : tsym;
  58. srsymtable : tsymtable;
  59. st : tsymtable;
  60. p : tnode;
  61. begin
  62. result:=true;
  63. def:=nil;
  64. if token=_ID then
  65. begin
  66. if assigned(aclass) then
  67. sym:=search_class_member(aclass,pattern)
  68. else
  69. searchsym(pattern,sym,srsymtable);
  70. if assigned(sym) then
  71. begin
  72. case sym.typ of
  73. varsym :
  74. begin
  75. pl.addsym(sl_load,sym);
  76. def:=tvarsym(sym).vartype.def;
  77. end;
  78. procsym :
  79. begin
  80. pl.addsym(sl_call,sym);
  81. end;
  82. end;
  83. end
  84. else
  85. begin
  86. Message1(parser_e_illegal_field_or_method,pattern);
  87. result:=false;
  88. end;
  89. consume(_ID);
  90. repeat
  91. case token of
  92. _ID,
  93. _SEMICOLON :
  94. begin
  95. break;
  96. end;
  97. _POINT :
  98. begin
  99. consume(_POINT);
  100. if assigned(def) then
  101. begin
  102. st:=def.getsymtable(gs_record);
  103. if assigned(st) then
  104. begin
  105. sym:=searchsymonlyin(st,pattern);
  106. if assigned(sym) then
  107. begin
  108. pl.addsym(sl_subscript,sym);
  109. case sym.typ of
  110. varsym :
  111. def:=tvarsym(sym).vartype.def;
  112. else
  113. begin
  114. Message1(sym_e_illegal_field,pattern);
  115. result:=false;
  116. end;
  117. end;
  118. end
  119. else
  120. begin
  121. Message1(sym_e_illegal_field,pattern);
  122. result:=false;
  123. end;
  124. end
  125. else
  126. begin
  127. Message(parser_e_invalid_qualifier);
  128. result:=false;
  129. end;
  130. end
  131. else
  132. begin
  133. Message(parser_e_invalid_qualifier);
  134. result:=false;
  135. end;
  136. consume(_ID);
  137. end;
  138. _LECKKLAMMER :
  139. begin
  140. consume(_LECKKLAMMER);
  141. repeat
  142. if def.deftype=arraydef then
  143. begin
  144. idx:=0;
  145. p:=comp_expr(true);
  146. if (not codegenerror) then
  147. begin
  148. if (p.nodetype=ordconstn) then
  149. begin
  150. if compare_defs(p.resulttype.def,tarraydef(def).rangetype.def,nothingn)>=te_equal then
  151. idx:=tordconstnode(p).value
  152. else
  153. IncompatibleTypes(p.resulttype.def,tarraydef(def).rangetype.def);
  154. end
  155. else
  156. Message(parser_e_illegal_expression)
  157. end;
  158. p.free;
  159. pl.addconst(sl_vec,idx);
  160. def:=tarraydef(def).elementtype.def;
  161. end
  162. else
  163. begin
  164. Message(parser_e_invalid_qualifier);
  165. result:=false;
  166. end;
  167. until not try_to_consume(_COMMA);
  168. consume(_RECKKLAMMER);
  169. end;
  170. else
  171. begin
  172. Message(parser_e_ill_property_access_sym);
  173. result:=false;
  174. break;
  175. end;
  176. end;
  177. until false;
  178. end
  179. else
  180. begin
  181. Message(parser_e_ill_property_access_sym);
  182. result:=false;
  183. end;
  184. end;
  185. var
  186. sym : tsym;
  187. p : tpropertysym;
  188. overriden : tsym;
  189. hs : string;
  190. varspez : tvarspez;
  191. s : string;
  192. tt : ttype;
  193. arraytype : ttype;
  194. def : tdef;
  195. pt : tnode;
  196. propname : stringid;
  197. sc : tsinglelist;
  198. oldregisterdef : boolean;
  199. readvs,
  200. hvs : tvarsym;
  201. readprocdef,
  202. writeprocdef : tprocvardef;
  203. oldsymtablestack : tsymtable;
  204. begin
  205. { Generate temp procvardefs to search for matching read/write
  206. procedures. the readprocdef will store all definitions }
  207. oldregisterdef:=registerdef;
  208. registerdef:=false;
  209. readprocdef:=tprocvardef.create(normal_function_level);
  210. writeprocdef:=tprocvardef.create(normal_function_level);
  211. registerdef:=oldregisterdef;
  212. { make it method pointers }
  213. if assigned(aclass) then
  214. begin
  215. include(readprocdef.procoptions,po_methodpointer);
  216. include(writeprocdef.procoptions,po_methodpointer);
  217. end;
  218. if token<>_ID then
  219. begin
  220. consume(_ID);
  221. consume(_SEMICOLON);
  222. exit;
  223. end;
  224. { Generate propertysym and insert in symtablestack }
  225. p:=tpropertysym.create(orgpattern);
  226. symtablestack.insert(p);
  227. propname:=pattern;
  228. consume(_ID);
  229. { Set the symtablestack to the parast of readprop so
  230. temp defs will be destroyed after declaration }
  231. readprocdef.parast.next:=symtablestack;
  232. symtablestack:=readprocdef.parast;
  233. { property parameters ? }
  234. if token=_LECKKLAMMER then
  235. begin
  236. if (sp_published in current_object_option) then
  237. Message(parser_e_cant_publish_that_property);
  238. { create a list of the parameters }
  239. sc:=tsinglelist.create;
  240. consume(_LECKKLAMMER);
  241. inc(testcurobject);
  242. repeat
  243. if token=_VAR then
  244. begin
  245. consume(_VAR);
  246. varspez:=vs_var;
  247. end
  248. else if token=_CONST then
  249. begin
  250. consume(_CONST);
  251. varspez:=vs_const;
  252. end
  253. else if (idtoken=_OUT) and (m_out in aktmodeswitches) then
  254. begin
  255. consume(_OUT);
  256. varspez:=vs_out;
  257. end
  258. else
  259. varspez:=vs_value;
  260. sc.reset;
  261. repeat
  262. readvs:=tvarsym.create(orgpattern,varspez,generrortype);
  263. readprocdef.parast.insert(readvs);
  264. sc.insert(readvs);
  265. consume(_ID);
  266. until not try_to_consume(_COMMA);
  267. if try_to_consume(_COLON) then
  268. begin
  269. { for records, don't search the recordsymtable for
  270. the symbols of the types }
  271. oldsymtablestack:=symtablestack;
  272. symtablestack:=symtablestack.next;
  273. if try_to_consume(_ARRAY) then
  274. begin
  275. consume(_OF);
  276. { define range and type of range }
  277. tt.setdef(tarraydef.create(0,-1,s32inttype));
  278. { define field type }
  279. single_type(arraytype,s,false);
  280. tarraydef(tt.def).setelementtype(arraytype);
  281. end
  282. else
  283. single_type(tt,s,false);
  284. symtablestack:=oldsymtablestack;
  285. end
  286. else
  287. tt:=cformaltype;
  288. readvs:=tvarsym(sc.first);
  289. while assigned(readvs) do
  290. begin
  291. readprocdef.concatpara(nil,tt,readvs,nil,false);
  292. { also update the writeprocdef }
  293. hvs:=tvarsym.create(readvs.realname,vs_value,generrortype);
  294. writeprocdef.parast.insert(hvs);
  295. writeprocdef.concatpara(nil,tt,hvs,nil,false);
  296. readvs:=tvarsym(readvs.listnext);
  297. end;
  298. until not try_to_consume(_SEMICOLON);
  299. sc.free;
  300. dec(testcurobject);
  301. consume(_RECKKLAMMER);
  302. { the parser need to know if a property has parameters, the
  303. index parameter doesn't count (PFV) }
  304. if readprocdef.minparacount>0 then
  305. include(p.propoptions,ppo_hasparameters);
  306. end;
  307. { overriden property ? }
  308. { force property interface
  309. there is a property parameter
  310. a global property }
  311. if (token=_COLON) or (readprocdef.minparacount>0) or (aclass=nil) then
  312. begin
  313. consume(_COLON);
  314. { insert types in global symtable }
  315. oldsymtablestack:=symtablestack;
  316. while not(symtablestack.symtabletype in [globalsymtable,staticsymtable]) do
  317. symtablestack:=symtablestack.next;
  318. single_type(p.proptype,hs,false);
  319. symtablestack:=oldsymtablestack;
  320. if (idtoken=_INDEX) then
  321. begin
  322. consume(_INDEX);
  323. pt:=comp_expr(true);
  324. if is_constnode(pt) and
  325. is_ordinal(pt.resulttype.def)
  326. {$ifndef cpu64bit}
  327. and (not is_64bitint(pt.resulttype.def))
  328. {$endif}
  329. then
  330. p.index:=tordconstnode(pt).value
  331. else
  332. begin
  333. Message(parser_e_invalid_property_index_value);
  334. p.index:=0;
  335. end;
  336. inserttypeconv(pt,sinttype);
  337. p.indextype.setdef(pt.resulttype.def);
  338. include(p.propoptions,ppo_indexed);
  339. { concat a longint to the para templates }
  340. hvs:=tvarsym.create('$index',vs_value,p.indextype);
  341. readprocdef.parast.insert(hvs);
  342. readprocdef.concatpara(nil,p.indextype,hvs,nil,false);
  343. hvs:=tvarsym.create('$index',vs_value,p.indextype);
  344. writeprocdef.parast.insert(hvs);
  345. writeprocdef.concatpara(nil,p.indextype,hvs,nil,false);
  346. pt.free;
  347. end;
  348. end
  349. else
  350. begin
  351. { do an property override }
  352. overriden:=search_class_member(aclass.childof,propname);
  353. if assigned(overriden) and (overriden.typ=propertysym) then
  354. begin
  355. p.dooverride(tpropertysym(overriden));
  356. end
  357. else
  358. begin
  359. p.proptype:=generrortype;
  360. message(parser_e_no_property_found_to_override);
  361. end;
  362. end;
  363. if (sp_published in current_object_option) and
  364. not(p.proptype.def.is_publishable) then
  365. Message(parser_e_cant_publish_that_property);
  366. if try_to_consume(_READ) then
  367. begin
  368. p.readaccess.clear;
  369. if parse_symlist(p.readaccess,def) then
  370. begin
  371. sym:=p.readaccess.firstsym^.sym;
  372. case sym.typ of
  373. procsym :
  374. begin
  375. { read is function returning the type of the property }
  376. readprocdef.rettype:=p.proptype;
  377. { Insert hidden parameters }
  378. handle_calling_convention(readprocdef);
  379. calc_parast(readprocdef);
  380. { search procdefs matching readprocdef }
  381. { we ignore hidden stuff here because the property access symbol might have
  382. non default calling conventions which might change the hidden stuff;
  383. see tw3216.pp (FK) }
  384. p.readaccess.procdef:=Tprocsym(sym).search_procdef_bypara(readprocdef.para,p.proptype.def,[cpo_allowdefaults,cpo_ignorehidden,cpo_allowconvert]);
  385. if not assigned(p.readaccess.procdef) then
  386. Message(parser_e_ill_property_access_sym);
  387. end;
  388. varsym :
  389. begin
  390. if not assigned(def) then
  391. internalerror(200310071);
  392. if compare_defs(def,p.proptype.def,nothingn)>=te_equal then
  393. begin
  394. { property parameters are allowed if this is
  395. an indexed property, because the index is then
  396. the parameter.
  397. Note: In the help of Kylix it is written
  398. that it isn't allowed, but the compiler accepts it (PFV) }
  399. if (ppo_hasparameters in p.propoptions) then
  400. Message(parser_e_ill_property_access_sym);
  401. end
  402. else
  403. IncompatibleTypes(def,p.proptype.def);
  404. end;
  405. else
  406. Message(parser_e_ill_property_access_sym);
  407. end;
  408. end;
  409. end;
  410. if try_to_consume(_WRITE) then
  411. begin
  412. p.writeaccess.clear;
  413. if parse_symlist(p.writeaccess,def) then
  414. begin
  415. sym:=p.writeaccess.firstsym^.sym;
  416. case sym.typ of
  417. procsym :
  418. begin
  419. { write is a procedure with an extra value parameter
  420. of the of the property }
  421. writeprocdef.rettype:=voidtype;
  422. hvs:=tvarsym.create('$value',vs_value,p.proptype);
  423. writeprocdef.parast.insert(hvs);
  424. writeprocdef.concatpara(nil,p.proptype,hvs,nil,false);
  425. { Insert hidden parameters }
  426. handle_calling_convention(writeprocdef);
  427. calc_parast(writeprocdef);
  428. { search procdefs matching writeprocdef }
  429. p.writeaccess.procdef:=Tprocsym(sym).search_procdef_bypara(writeprocdef.para,writeprocdef.rettype.def,[cpo_allowdefaults,cpo_allowconvert]);
  430. if not assigned(p.writeaccess.procdef) then
  431. Message(parser_e_ill_property_access_sym);
  432. end;
  433. varsym :
  434. begin
  435. if not assigned(def) then
  436. internalerror(200310072);
  437. if compare_defs(def,p.proptype.def,nothingn)>=te_equal then
  438. begin
  439. { property parameters are allowed if this is
  440. an indexed property, because the index is then
  441. the parameter.
  442. Note: In the help of Kylix it is written
  443. that it isn't allowed, but the compiler accepts it (PFV) }
  444. if (ppo_hasparameters in p.propoptions) then
  445. Message(parser_e_ill_property_access_sym);
  446. end
  447. else
  448. IncompatibleTypes(def,p.proptype.def);
  449. end;
  450. else
  451. Message(parser_e_ill_property_access_sym);
  452. end;
  453. end;
  454. end;
  455. if assigned(aclass) then
  456. begin
  457. include(p.propoptions,ppo_stored);
  458. if try_to_consume(_STORED) then
  459. begin
  460. p.storedaccess.clear;
  461. case token of
  462. _ID:
  463. begin
  464. { in the case that idtoken=_DEFAULT }
  465. { we have to do nothing except }
  466. { setting ppo_stored, it's the same }
  467. { as stored true }
  468. if idtoken<>_DEFAULT then
  469. begin
  470. if parse_symlist(p.storedaccess,def) then
  471. begin
  472. sym:=p.storedaccess.firstsym^.sym;
  473. case sym.typ of
  474. procsym :
  475. begin
  476. p.storedaccess.procdef:=Tprocsym(sym).search_procdef_nopara_boolret;
  477. if not assigned(p.storedaccess.procdef) then
  478. message(parser_e_ill_property_storage_sym);
  479. end;
  480. varsym :
  481. begin
  482. if not assigned(def) then
  483. internalerror(200310073);
  484. if (ppo_hasparameters in p.propoptions) or
  485. not(is_boolean(def)) then
  486. Message(parser_e_stored_property_must_be_boolean);
  487. end;
  488. else
  489. Message(parser_e_ill_property_access_sym);
  490. end;
  491. end;
  492. end;
  493. end;
  494. _FALSE:
  495. begin
  496. consume(_FALSE);
  497. exclude(p.propoptions,ppo_stored);
  498. end;
  499. _TRUE:
  500. consume(_TRUE);
  501. end;
  502. end;
  503. end;
  504. if try_to_consume(_DEFAULT) then
  505. begin
  506. if not(is_ordinal(p.proptype.def) or
  507. {$ifndef cpu64bit}
  508. is_64bitint(p.proptype.def) or
  509. {$endif cpu64bit}
  510. is_class(p.proptype.def) or
  511. is_single(p.proptype.def) or
  512. (p.proptype.def.deftype in [classrefdef,pointerdef]) or
  513. ((p.proptype.def.deftype=setdef) and
  514. (tsetdef(p.proptype.def).settype=smallset))) or
  515. ((p.proptype.def.deftype=arraydef) and
  516. (ppo_indexed in p.propoptions)) or
  517. (ppo_hasparameters in p.propoptions) then
  518. begin
  519. Message(parser_e_property_cant_have_a_default_value);
  520. { Error recovery }
  521. pt:=comp_expr(true);
  522. pt.free;
  523. end
  524. else
  525. begin
  526. { Get the result of the default, the firstpass is
  527. needed to support values like -1 }
  528. pt:=comp_expr(true);
  529. if (p.proptype.def.deftype=setdef) and
  530. (pt.nodetype=arrayconstructorn) then
  531. begin
  532. arrayconstructor_to_set(pt);
  533. do_resulttypepass(pt);
  534. end;
  535. inserttypeconv(pt,p.proptype);
  536. if not(is_constnode(pt)) then
  537. Message(parser_e_property_default_value_must_const);
  538. { Set default value }
  539. case pt.nodetype of
  540. setconstn :
  541. p.default:=plongint(tsetconstnode(pt).value_set)^;
  542. ordconstn :
  543. p.default:=tordconstnode(pt).value;
  544. niln :
  545. p.default:=0;
  546. realconstn:
  547. p.default:=longint(single(trealconstnode(pt).value_real));
  548. end;
  549. pt.free;
  550. end;
  551. end
  552. else if try_to_consume(_NODEFAULT) then
  553. begin
  554. p.default:=0;
  555. end;
  556. { remove temporary procvardefs }
  557. symtablestack:=symtablestack.next;
  558. readprocdef.free;
  559. writeprocdef.free;
  560. result:=p;
  561. end;
  562. const
  563. variantrecordlevel : longint = 0;
  564. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  565. { reads the filed of a record into a }
  566. { symtablestack, if record=false }
  567. { variants are forbidden, so this procedure }
  568. { can be used to read object fields }
  569. { if absolute is true, ABSOLUTE and file }
  570. { types are allowed }
  571. { => the procedure is also used to read }
  572. { a sequence of variable declaration }
  573. procedure insert_syms(sc : tsinglelist;tt : ttype;is_threadvar : boolean; addsymopts : tsymoptions);
  574. { inserts the symbols of sc in st with def as definition or sym as ttypesym, sc is disposed }
  575. var
  576. vs,vs2 : tvarsym;
  577. begin
  578. vs:=tvarsym(sc.first);
  579. while assigned(vs) do
  580. begin
  581. vs.vartype:=tt;
  582. { insert any additional hint directives }
  583. vs.symoptions := vs.symoptions + addsymopts;
  584. if (sp_static in current_object_option) then
  585. include(vs.symoptions,sp_static);
  586. if is_threadvar then
  587. include(vs.varoptions,vo_is_thread_var);
  588. { static data fields are inserted in the globalsymtable }
  589. if (symtablestack.symtabletype=objectsymtable) and
  590. (sp_static in current_object_option) then
  591. begin
  592. vs2:=tvarsym.create('$'+lower(symtablestack.name^)+'_'+vs.name,vs_value,tt);
  593. symtablestack.defowner.owner.insert(vs2);
  594. insertbssdata(vs2);
  595. end
  596. else
  597. begin
  598. { external data is not possible here }
  599. case symtablestack.symtabletype of
  600. globalsymtable,
  601. staticsymtable :
  602. insertbssdata(vs);
  603. recordsymtable,
  604. objectsymtable :
  605. tabstractrecordsymtable(symtablestack).insertfield(vs,false);
  606. end;
  607. end;
  608. vs:=tvarsym(vs.listnext);
  609. end;
  610. end;
  611. procedure read_default_value(sc : tsinglelist;tt : ttype;is_threadvar : boolean);
  612. var
  613. vs : tvarsym;
  614. tcsym : ttypedconstsym;
  615. begin
  616. vs:=tvarsym(sc.first);
  617. if assigned(vs.listnext) then
  618. Message(parser_e_initialized_only_one_var);
  619. if is_threadvar then
  620. Message(parser_e_initialized_not_for_threadvar);
  621. if symtablestack.symtabletype=localsymtable then
  622. begin
  623. consume(_EQUAL);
  624. tcsym:=ttypedconstsym.createtype('default'+vs.realname,tt,false);
  625. vs.defaultconstsym:=tcsym;
  626. symtablestack.insert(tcsym);
  627. insertconstdata(tcsym);
  628. readtypedconst(tt,tcsym,false);
  629. end
  630. else
  631. begin
  632. tcsym:=ttypedconstsym.createtype(vs.realname,tt,true);
  633. tcsym.fileinfo:=vs.fileinfo;
  634. symtablestack.replace(vs,tcsym);
  635. vs.free;
  636. insertconstdata(tcsym);
  637. consume(_EQUAL);
  638. readtypedconst(tt,tcsym,true);
  639. end;
  640. end;
  641. var
  642. sc : tsinglelist;
  643. old_block_type : tblock_type;
  644. symdone : boolean;
  645. { to handle absolute }
  646. abssym : tabsolutesym;
  647. { c var }
  648. newtype : ttypesym;
  649. is_dll,
  650. hasdefaultvalue,
  651. is_gpc_name,is_cdecl,
  652. extern_var,export_var : boolean;
  653. old_current_object_option : tsymoptions;
  654. hs,sorg,C_name,dll_name : string;
  655. tt,casetype : ttype;
  656. { maxsize contains the max. size of a variant }
  657. { startvarrec contains the start of the variant part of a record }
  658. maxsize, startvarrecsize : longint;
  659. usedalign,
  660. maxalignment,startvarrecalign,
  661. maxpadalign, startpadalign: shortint;
  662. hp,pt : tnode;
  663. vs,vs2 : tvarsym;
  664. srsym : tsym;
  665. oldsymtablestack,
  666. srsymtable : tsymtable;
  667. unionsymtable : trecordsymtable;
  668. offset : longint;
  669. uniondef : trecorddef;
  670. unionsym : tvarsym;
  671. uniontype : ttype;
  672. dummysymoptions : tsymoptions;
  673. semicolonatend: boolean;
  674. {$ifdef powerpc}
  675. tempdef: tdef;
  676. is_first_field: boolean;
  677. {$endif powerpc}
  678. begin
  679. {$ifdef powerpc}
  680. is_first_field := true;
  681. {$endif powerpc}
  682. old_current_object_option:=current_object_option;
  683. { all variables are public if not in a object declaration }
  684. if not is_object then
  685. current_object_option:=[sp_public];
  686. old_block_type:=block_type;
  687. block_type:=bt_type;
  688. is_gpc_name:=false;
  689. { Force an expected ID error message }
  690. if not (token in [_ID,_CASE,_END]) then
  691. consume(_ID);
  692. { read vars }
  693. sc:=tsinglelist.create;
  694. while (token=_ID) and
  695. not(is_object and (idtoken in [_PUBLIC,_PRIVATE,_PUBLISHED,_PROTECTED])) do
  696. begin
  697. sorg:=orgpattern;
  698. sc.reset;
  699. repeat
  700. vs:=tvarsym.create(orgpattern,vs_value,generrortype);
  701. symtablestack.insert(vs);
  702. if assigned(vs.owner) then
  703. sc.insert(vs)
  704. else
  705. vs.free;
  706. consume(_ID);
  707. until not try_to_consume(_COMMA);
  708. consume(_COLON);
  709. if (m_gpc in aktmodeswitches) and
  710. not(is_record or is_object or is_threadvar) and
  711. (token=_ID) and (orgpattern='__asmname__') then
  712. begin
  713. consume(_ID);
  714. C_name:=get_stringconst;
  715. Is_gpc_name:=true;
  716. end;
  717. { this is needed for Delphi mode at least
  718. but should be OK for all modes !! (PM) }
  719. ignore_equal:=true;
  720. if is_record or is_object then
  721. begin
  722. { for records, don't search the recordsymtable for
  723. the symbols of the types }
  724. oldsymtablestack:=symtablestack;
  725. symtablestack:=symtablestack.next;
  726. read_type(tt,'',false);
  727. symtablestack:=oldsymtablestack;
  728. end
  729. else
  730. read_type(tt,'',false);
  731. { Process procvar directives }
  732. if (tt.def.deftype=procvardef) and
  733. (tt.def.typesym=nil) and
  734. is_proc_directive(token,true) then
  735. begin
  736. newtype:=ttypesym.create('unnamed',tt);
  737. parse_var_proc_directives(tsym(newtype));
  738. newtype.restype.def:=nil;
  739. tt.def.typesym:=nil;
  740. newtype.free;
  741. end;
  742. {$ifdef powerpc}
  743. { from gcc/gcc/config/rs6000/rs6000.h:
  744. /* APPLE LOCAL begin Macintosh alignment 2002-1-22 ff */
  745. /* Return the alignment of a struct based on the Macintosh PowerPC
  746. alignment rules. In general the alignment of a struct is
  747. determined by the greatest alignment of its elements. However, the
  748. PowerPC rules cause the alignment of a struct to peg at word
  749. alignment except when the first field has greater than word
  750. (32-bit) alignment, in which case the alignment is determined by
  751. the alignment of the first field. */
  752. }
  753. if (target_info.system in [system_powerpc_darwin, system_powerpc_macos]) and
  754. is_record and
  755. is_first_field and
  756. (trecordsymtable(symtablestack).usefieldalignment = -1) then
  757. begin
  758. tempdef := tt.def;
  759. while tempdef.deftype = arraydef do
  760. tempdef := tarraydef(tempdef).elementtype.def;
  761. if tempdef.deftype <> recorddef then
  762. maxpadalign := tempdef.alignment
  763. else
  764. maxpadalign := trecorddef(tempdef).padalignment;
  765. if (maxpadalign > 4) and
  766. (maxpadalign > trecordsymtable(symtablestack).padalignment) then
  767. trecordsymtable(symtablestack).padalignment := maxpadalign;
  768. is_first_field := false;
  769. end;
  770. {$endif powerpc}
  771. { types that use init/final are not allowed in variant parts, but
  772. classes are allowed }
  773. if (variantrecordlevel>0) and
  774. (tt.def.needs_inittable and not is_class(tt.def)) then
  775. Message(parser_e_cant_use_inittable_here);
  776. ignore_equal:=false;
  777. hasdefaultvalue:=false;
  778. symdone:=false;
  779. if is_gpc_name then
  780. begin
  781. vs:=tvarsym(sc.first);
  782. if assigned(vs.listnext) then
  783. Message(parser_e_absolute_only_one_var);
  784. vs.vartype:=tt;
  785. include(vs.varoptions,vo_is_C_var);
  786. vs.set_mangledname(target_info.Cprefix+sorg);
  787. include(vs.varoptions,vo_is_external);
  788. symdone:=true;
  789. end;
  790. { check for absolute }
  791. if not symdone and
  792. (idtoken=_ABSOLUTE) and not(is_record or is_object or is_threadvar) then
  793. begin
  794. consume(_ABSOLUTE);
  795. abssym:=nil;
  796. { only allowed for one var }
  797. vs:=tvarsym(sc.first);
  798. if assigned(vs.listnext) then
  799. Message(parser_e_absolute_only_one_var);
  800. { parse the rest }
  801. pt:=expr;
  802. { check allowed absolute types }
  803. if (pt.nodetype=stringconstn) or
  804. (is_constcharnode(pt)) then
  805. begin
  806. abssym:=tabsolutesym.create(vs.realname,tt);
  807. abssym.fileinfo:=vs.fileinfo;
  808. if pt.nodetype=stringconstn then
  809. hs:=strpas(tstringconstnode(pt).value_str)
  810. else
  811. hs:=chr(tordconstnode(pt).value);
  812. consume(token);
  813. abssym.abstyp:=toasm;
  814. abssym.asmname:=stringdup(hs);
  815. { replace the varsym }
  816. symtablestack.replace(vs,abssym);
  817. vs.free;
  818. end
  819. { address }
  820. else if is_constintnode(pt) and
  821. ((target_info.system in [system_i386_go32v2,system_i386_watcom,
  822. system_i386_wdosx,system_i386_win32]) or
  823. (m_objfpc in aktmodeswitches) or
  824. (m_delphi in aktmodeswitches)) then
  825. begin
  826. abssym:=tabsolutesym.create(vs.realname,tt);
  827. abssym.fileinfo:=vs.fileinfo;
  828. abssym.abstyp:=toaddr;
  829. abssym.fieldoffset:=tordconstnode(pt).value;
  830. {$ifdef i386}
  831. abssym.absseg:=false;
  832. if (target_info.system in [system_i386_go32v2,system_i386_watcom]) and
  833. try_to_consume(_COLON) then
  834. begin
  835. pt.free;
  836. pt:=expr;
  837. if is_constintnode(pt) then
  838. begin
  839. abssym.fieldoffset:=abssym.fieldoffset shl 4+tordconstnode(pt).value;
  840. abssym.absseg:=true;
  841. end
  842. else
  843. Message(type_e_ordinal_expr_expected);
  844. end;
  845. {$endif i386}
  846. symtablestack.replace(vs,abssym);
  847. vs.free;
  848. end
  849. { variable }
  850. else
  851. begin
  852. { remove subscriptn before checking for loadn }
  853. hp:=pt;
  854. while (hp.nodetype in [subscriptn,typeconvn,vecn]) do
  855. hp:=tunarynode(hp).left;
  856. if (hp.nodetype=loadn) then
  857. begin
  858. { we should check the result type of loadn }
  859. if not (tloadnode(hp).symtableentry.typ in [varsym,typedconstsym]) then
  860. Message(parser_e_absolute_only_to_var_or_const);
  861. abssym:=tabsolutesym.create(vs.realname,tt);
  862. abssym.fileinfo:=vs.fileinfo;
  863. abssym.abstyp:=tovar;
  864. abssym.ref:=node_to_symlist(pt);
  865. symtablestack.replace(vs,abssym);
  866. vs.free;
  867. end
  868. else
  869. Message(parser_e_absolute_only_to_var_or_const);
  870. end;
  871. if assigned(abssym) then
  872. begin
  873. { try to consume the hint directives with absolute symbols }
  874. dummysymoptions:=[];
  875. try_consume_hintdirective(dummysymoptions);
  876. abssym.symoptions := abssym.symoptions + dummysymoptions;
  877. end;
  878. pt.free;
  879. symdone:=true;
  880. end;
  881. { Process procvar directives before = and ; }
  882. if (tt.def.deftype=procvardef) and
  883. (tt.def.typesym=nil) and
  884. is_proc_directive(token,true) then
  885. begin
  886. newtype:=ttypesym.create('unnamed',tt);
  887. parse_var_proc_directives(tsym(newtype));
  888. newtype.restype.def:=nil;
  889. tt.def.typesym:=nil;
  890. newtype.free;
  891. end;
  892. { try to parse the hint directives }
  893. dummysymoptions:=[];
  894. try_consume_hintdirective(dummysymoptions);
  895. { Records and objects can't have default values }
  896. if is_record or is_object then
  897. begin
  898. { for a record there doesn't need to be a ; before the END or ) }
  899. if not(token in [_END,_RKLAMMER]) then
  900. consume(_SEMICOLON);
  901. end
  902. else
  903. begin
  904. { Handling of Delphi typed const = initialized vars }
  905. if (token=_EQUAL) and
  906. not(m_tp7 in aktmodeswitches) and
  907. (symtablestack.symtabletype<>parasymtable) then
  908. begin
  909. if (tt.def.deftype=procvardef) and
  910. (tt.def.typesym=nil) then
  911. begin
  912. { Add calling convention for procvar }
  913. handle_calling_convention(tprocvardef(tt.def));
  914. calc_parast(tprocvardef(tt.def));
  915. end;
  916. read_default_value(sc,tt,is_threadvar);
  917. { for locals we've created typedconstsym with a different name }
  918. if symtablestack.symtabletype<>localsymtable then
  919. symdone:=true;
  920. hasdefaultvalue:=true;
  921. end;
  922. consume(_SEMICOLON);
  923. end;
  924. { Support calling convention for procvars after semicolon }
  925. if not(hasdefaultvalue) and
  926. (tt.def.deftype=procvardef) and
  927. (tt.def.typesym=nil) then
  928. begin
  929. { Parse procvar directives after ; }
  930. if is_proc_directive(token,true) then
  931. begin
  932. newtype:=ttypesym.create('unnamed',tt);
  933. parse_var_proc_directives(tsym(newtype));
  934. newtype.restype.def:=nil;
  935. tt.def.typesym:=nil;
  936. newtype.free;
  937. end;
  938. { Add calling convention for procvar }
  939. handle_calling_convention(tprocvardef(tt.def));
  940. calc_parast(tprocvardef(tt.def));
  941. { Handling of Delphi typed const = initialized vars }
  942. if (token=_EQUAL) and
  943. not(is_record or is_object) and
  944. not(m_tp7 in aktmodeswitches) and
  945. (symtablestack.symtabletype<>parasymtable) then
  946. begin
  947. read_default_value(sc,tt,is_threadvar);
  948. consume(_SEMICOLON);
  949. symdone:=true;
  950. hasdefaultvalue:=true;
  951. end;
  952. end;
  953. { Check for EXTERNAL etc directives or, in macpas, if cs_external_var is set}
  954. if not symdone and not(is_record or is_object or is_threadvar) then
  955. begin
  956. if (
  957. (token=_ID) and
  958. (m_cvar_support in aktmodeswitches) and
  959. (idtoken in [_EXPORT,_EXTERNAL,_PUBLIC,_CVAR])
  960. ) or
  961. (
  962. (m_mac in aktmodeswitches) and
  963. ((cs_external_var in aktlocalswitches) or (cs_externally_visible in aktlocalswitches))
  964. ) then
  965. begin
  966. { only allowed for one var }
  967. vs:=tvarsym(sc.first);
  968. if assigned(vs.listnext) then
  969. Message(parser_e_absolute_only_one_var);
  970. { set type of the var }
  971. vs.vartype:=tt;
  972. vs.symoptions := vs.symoptions + dummysymoptions;
  973. { defaults }
  974. is_dll:=false;
  975. is_cdecl:=false;
  976. extern_var:=false;
  977. export_var:=false;
  978. C_name:=sorg;
  979. semicolonatend:= false;
  980. { cdecl }
  981. if idtoken=_CVAR then
  982. begin
  983. consume(_CVAR);
  984. consume(_SEMICOLON);
  985. is_cdecl:=true;
  986. C_name:=target_info.Cprefix+sorg;
  987. end;
  988. { external }
  989. if idtoken=_EXTERNAL then
  990. begin
  991. consume(_EXTERNAL);
  992. extern_var:=true;
  993. semicolonatend:= true;
  994. end;
  995. { macpas specific handling due to some switches}
  996. if (m_mac in aktmodeswitches) then
  997. begin
  998. if (cs_external_var in aktlocalswitches) then
  999. begin {The effect of this is the same as if cvar; external; has been given as directives.}
  1000. is_cdecl:=true;
  1001. C_name:=target_info.Cprefix+sorg;
  1002. extern_var:=true;
  1003. end
  1004. else if (cs_externally_visible in aktlocalswitches) then
  1005. begin {The effect of this is the same as if cvar has been given as directives.}
  1006. is_cdecl:=true;
  1007. C_name:=target_info.Cprefix+sorg;
  1008. end;
  1009. end;
  1010. { export }
  1011. if idtoken in [_EXPORT,_PUBLIC] then
  1012. begin
  1013. consume(_ID);
  1014. if extern_var or
  1015. (symtablestack.symtabletype in [parasymtable,localsymtable]) then
  1016. Message(parser_e_not_external_and_export)
  1017. else
  1018. begin
  1019. export_var:=true;
  1020. semicolonatend:= true;
  1021. end;
  1022. end;
  1023. { external and export need a name after when no cdecl is used }
  1024. if not is_cdecl then
  1025. begin
  1026. { dll name ? }
  1027. if (extern_var) and (idtoken<>_NAME) then
  1028. begin
  1029. is_dll:=true;
  1030. dll_name:=get_stringconst;
  1031. end;
  1032. consume(_NAME);
  1033. C_name:=get_stringconst;
  1034. end;
  1035. { consume the ; when export or external is used }
  1036. if semicolonatend then
  1037. consume(_SEMICOLON);
  1038. { set some vars options }
  1039. if is_dll then
  1040. include(vs.varoptions,vo_is_dll_var)
  1041. else
  1042. include(vs.varoptions,vo_is_C_var);
  1043. if (is_dll) and
  1044. (target_info.system = system_powerpc_darwin) then
  1045. C_Name := target_info.Cprefix+C_Name;
  1046. vs.set_mangledname(C_Name);
  1047. if export_var then
  1048. begin
  1049. inc(vs.refs);
  1050. include(vs.varoptions,vo_is_exported);
  1051. end;
  1052. if extern_var then
  1053. include(vs.varoptions,vo_is_external);
  1054. { insert in the datasegment when it is not external }
  1055. if (not extern_var) then
  1056. insertbssdata(vs);
  1057. { now we can insert it in the import lib if its a dll, or
  1058. add it to the externals }
  1059. if extern_var then
  1060. begin
  1061. if is_dll then
  1062. begin
  1063. if not(current_module.uses_imports) then
  1064. begin
  1065. current_module.uses_imports:=true;
  1066. importlib.preparelib(current_module.modulename^);
  1067. end;
  1068. importlib.importvariable(vs,C_name,dll_name);
  1069. end
  1070. else
  1071. if target_info.DllScanSupported then
  1072. current_module.Externals.insert(tExternalsItem.create(vs.mangledname));
  1073. end;
  1074. symdone:=true;
  1075. end;
  1076. end;
  1077. { Check for STATIC directive }
  1078. if not symdone and (is_object) and
  1079. (cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
  1080. begin
  1081. include(current_object_option,sp_static);
  1082. insert_syms(sc,tt,false,dummysymoptions);
  1083. exclude(current_object_option,sp_static);
  1084. consume(_STATIC);
  1085. consume(_SEMICOLON);
  1086. symdone:=true;
  1087. end;
  1088. { insert it in the symtable, if not done yet }
  1089. if not symdone then
  1090. begin
  1091. { save object option, because we can turn of the sp_published }
  1092. if (sp_published in current_object_option) and
  1093. not(is_class(tt.def)) then
  1094. begin
  1095. Message(parser_e_cant_publish_that);
  1096. exclude(current_object_option,sp_published);
  1097. { recover by changing access type to public }
  1098. vs2:=tvarsym(sc.first);
  1099. while assigned (vs2) do
  1100. begin
  1101. exclude(vs2.symoptions,sp_published);
  1102. include(vs2.symoptions,sp_public);
  1103. vs2:=tvarsym(vs2.listnext);
  1104. end;
  1105. end
  1106. else
  1107. if (sp_published in current_object_option) and
  1108. not(oo_can_have_published in tobjectdef(tt.def).objectoptions) then
  1109. begin
  1110. Message(parser_e_only_publishable_classes_can__be_published);
  1111. exclude(current_object_option,sp_published);
  1112. end;
  1113. insert_syms(sc,tt,is_threadvar,dummysymoptions);
  1114. current_object_option:=old_current_object_option;
  1115. end;
  1116. end;
  1117. { Check for Case }
  1118. if is_record and (token=_CASE) then
  1119. begin
  1120. maxsize:=0;
  1121. maxalignment:=0;
  1122. maxpadalign:=0;
  1123. consume(_CASE);
  1124. sorg:=orgpattern;
  1125. hs:=pattern;
  1126. searchsym(hs,srsym,srsymtable);
  1127. { may be only a type: }
  1128. if assigned(srsym) and (srsym.typ in [typesym,unitsym]) then
  1129. begin
  1130. { for records, don't search the recordsymtable for
  1131. the symbols of the types }
  1132. oldsymtablestack:=symtablestack;
  1133. symtablestack:=symtablestack.next;
  1134. read_type(casetype,'',true);
  1135. symtablestack:=oldsymtablestack;
  1136. end
  1137. else
  1138. begin
  1139. consume(_ID);
  1140. consume(_COLON);
  1141. { for records, don't search the recordsymtable for
  1142. the symbols of the types }
  1143. oldsymtablestack:=symtablestack;
  1144. symtablestack:=symtablestack.next;
  1145. read_type(casetype,'',true);
  1146. symtablestack:=oldsymtablestack;
  1147. vs:=tvarsym.create(sorg,vs_value,casetype);
  1148. tabstractrecordsymtable(symtablestack).insertfield(vs,true);
  1149. end;
  1150. if not(is_ordinal(casetype.def))
  1151. {$ifndef cpu64bit}
  1152. or is_64bitint(casetype.def)
  1153. {$endif cpu64bit}
  1154. then
  1155. Message(type_e_ordinal_expr_expected);
  1156. consume(_OF);
  1157. UnionSymtable:=trecordsymtable.create(aktpackrecords);
  1158. Unionsymtable.next:=symtablestack;
  1159. registerdef:=false;
  1160. UnionDef:=trecorddef.create(unionsymtable);
  1161. uniondef.isunion:=true;
  1162. if assigned(symtablestack.defowner) then
  1163. Uniondef.owner:=symtablestack.defowner.owner;
  1164. registerdef:=true;
  1165. startvarrecsize:=UnionSymtable.datasize;
  1166. startvarrecalign:=UnionSymtable.fieldalignment;
  1167. startpadalign:=Unionsymtable.padalignment;
  1168. symtablestack:=UnionSymtable;
  1169. repeat
  1170. repeat
  1171. pt:=comp_expr(true);
  1172. if not(pt.nodetype=ordconstn) then
  1173. Message(parser_e_illegal_expression);
  1174. pt.free;
  1175. if token=_COMMA then
  1176. consume(_COMMA)
  1177. else
  1178. break;
  1179. until false;
  1180. consume(_COLON);
  1181. { read the vars }
  1182. consume(_LKLAMMER);
  1183. inc(variantrecordlevel);
  1184. if token<>_RKLAMMER then
  1185. read_var_decs(true,false,false);
  1186. dec(variantrecordlevel);
  1187. consume(_RKLAMMER);
  1188. { calculates maximal variant size }
  1189. maxsize:=max(maxsize,unionsymtable.datasize);
  1190. maxalignment:=max(maxalignment,unionsymtable.fieldalignment);
  1191. maxpadalign:=max(maxpadalign,unionsymtable.padalignment);
  1192. { the items of the next variant are overlayed }
  1193. unionsymtable.datasize:=startvarrecsize;
  1194. unionsymtable.fieldalignment:=startvarrecalign;
  1195. unionsymtable.padalignment:=startpadalign;
  1196. if (token<>_END) and (token<>_RKLAMMER) then
  1197. consume(_SEMICOLON)
  1198. else
  1199. break;
  1200. until (token=_END) or (token=_RKLAMMER);
  1201. { at last set the record size to that of the biggest variant }
  1202. unionsymtable.datasize:=maxsize;
  1203. unionsymtable.fieldalignment:=maxalignment;
  1204. uniontype.def:=uniondef;
  1205. uniontype.sym:=nil;
  1206. UnionSym:=tvarsym.create('$case',vs_value,uniontype);
  1207. symtablestack:=symtablestack.next;
  1208. unionsymtable.addalignmentpadding;
  1209. {$ifdef powerpc}
  1210. { parent inherits the alignment padding if the variant is the first "field" of the parent record/variant }
  1211. if (target_info.system in [system_powerpc_darwin, system_powerpc_macos]) and
  1212. is_first_field and
  1213. (trecordsymtable(symtablestack).usefieldalignment = -1) and
  1214. (maxpadalign > trecordsymtable(symtablestack).padalignment) then
  1215. trecordsymtable(symtablestack).padalignment:=maxpadalign;
  1216. {$endif powerpc}
  1217. { Align the offset where the union symtable is added }
  1218. if (trecordsymtable(symtablestack).usefieldalignment=-1) then
  1219. usedalign:=used_align(unionsymtable.recordalignment,aktalignment.recordalignmin,aktalignment.maxCrecordalign)
  1220. else
  1221. usedalign:=used_align(unionsymtable.recordalignment,aktalignment.recordalignmin,aktalignment.recordalignmax);
  1222. offset:=align(trecordsymtable(symtablestack).datasize,usedalign);
  1223. trecordsymtable(symtablestack).datasize:=offset+unionsymtable.datasize;
  1224. if unionsymtable.recordalignment>trecordsymtable(symtablestack).fieldalignment then
  1225. trecordsymtable(symtablestack).fieldalignment:=unionsymtable.recordalignment;
  1226. trecordsymtable(symtablestack).insertunionst(Unionsymtable,offset);
  1227. Unionsym.owner:=nil;
  1228. unionsym.free;
  1229. uniondef.owner:=nil;
  1230. uniondef.free;
  1231. end;
  1232. block_type:=old_block_type;
  1233. current_object_option:=old_current_object_option;
  1234. { free the list }
  1235. sc.free;
  1236. {$ifdef powerpc}
  1237. is_first_field := false;
  1238. {$endif powerpc}
  1239. end;
  1240. end.
  1241. {
  1242. $Log$
  1243. Revision 1.79 2004-08-17 16:29:21 jonas
  1244. + padalgingment field for recordsymtables (saved by recorddefs)
  1245. + support for Macintosh PowerPC alignment (if the first field of a record
  1246. or union has an alignment > 4, then the record or union size must be
  1247. padded to a multiple of this size)
  1248. Revision 1.78 2004/08/15 13:30:18 florian
  1249. * fixed alignment of variant records
  1250. * more alignment problems fixed
  1251. Revision 1.77 2004/08/07 19:14:50 florian
  1252. * fixed problem with explicit specified calling conventions for property symbols
  1253. Revision 1.76 2004/07/14 23:19:22 olle
  1254. + added external facilities for macpas
  1255. Revision 1.75 2004/06/20 08:55:30 florian
  1256. * logs truncated
  1257. Revision 1.74 2004/06/16 20:07:09 florian
  1258. * dwarf branch merged
  1259. Revision 1.73 2004/04/11 12:38:16 peter
  1260. * fix calling convention problem when parsing default value before
  1261. the semicolon
  1262. Revision 1.72.2.5 2004/05/02 20:54:04 peter
  1263. * allow convert when choosing property function with index
  1264. Revision 1.72.2.4 2004/05/01 20:51:20 peter
  1265. * fix val code parameter
  1266. Revision 1.72.2.3 2004/04/28 19:55:52 peter
  1267. * new warning for ordinal-pointer when size is different
  1268. * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
  1269. }