pdecl.pas 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Does declaration 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. interface
  20. uses
  21. globtype,tokens,globals,symtable;
  22. var
  23. { pointer to the last read type symbol, (for "forward" }
  24. { types) }
  25. lasttypesym : ptypesym;
  26. { hack, which allows to use the current parsed }
  27. { object type as function argument type }
  28. testcurobject : byte;
  29. curobjectname : stringid;
  30. { reads a string type with optional length }
  31. { and returns a pointer to the string }
  32. { definition }
  33. function stringtype : pdef;
  34. { reads a string, file type or a type id and returns a name and }
  35. { pdef }
  36. function single_type(var s : string) : pdef;
  37. { reads the declaration blocks }
  38. procedure read_declarations(islibrary : boolean);
  39. { reads declarations in the interface part of a unit }
  40. procedure read_interface_declarations;
  41. implementation
  42. uses
  43. cobjects,scanner,aasm,tree,pass_1,strings,
  44. files,types,verbose,systems,import,tccnv
  45. {$ifdef GDB}
  46. ,gdb
  47. {$endif GDB}
  48. { parser specific stuff }
  49. ,pbase,ptconst,pexpr,psub,pexports
  50. { processor specific stuff }
  51. {$ifdef i386}
  52. ,i386base
  53. {$endif}
  54. {$ifdef m68k}
  55. ,m68k
  56. {$endif}
  57. { codegen }
  58. ,hcodegen,hcgdata
  59. ;
  60. function read_type(const name : stringid) : pdef;forward;
  61. { search in symtablestack used, but not defined type }
  62. procedure testforward_type(p : pnamedindexobject);{$ifndef FPC}far;{$endif}
  63. var
  64. reaktvarsymtable : psymtable;
  65. oldaktfilepos : tfileposinfo;
  66. begin
  67. if not(psym(p)^.typ=typesym) then
  68. exit;
  69. if ((psym(p)^.properties and sp_forwarddef)<>0) then
  70. begin
  71. oldaktfilepos:=aktfilepos;
  72. aktfilepos:=psym(p)^.fileinfo;
  73. Message1(sym_e_forward_type_not_resolved,p^.name);
  74. aktfilepos:=oldaktfilepos;
  75. { try to recover }
  76. ptypesym(p)^.definition:=generrordef;
  77. psym(p)^.properties:=psym(p)^.properties and (not sp_forwarddef);
  78. end
  79. else
  80. if (ptypesym(p)^.definition^.deftype in [recorddef,objectdef]) then
  81. begin
  82. if (ptypesym(p)^.definition^.deftype=recorddef) then
  83. reaktvarsymtable:=precdef(ptypesym(p)^.definition)^.symtable
  84. else
  85. reaktvarsymtable:=pobjectdef(ptypesym(p)^.definition)^.publicsyms;
  86. reaktvarsymtable^.foreach({$ifndef TP}@{$endif}testforward_type);
  87. end;
  88. end;
  89. procedure const_dec;
  90. var
  91. name : stringid;
  92. p : ptree;
  93. def : pdef;
  94. sym : psym;
  95. storetokenpos,filepos : tfileposinfo;
  96. old_block_type : tblock_type;
  97. ps : pconstset;
  98. pd : pbestreal;
  99. sp : pchar;
  100. begin
  101. consume(_CONST);
  102. old_block_type:=block_type;
  103. block_type:=bt_const;
  104. repeat
  105. name:=pattern;
  106. filepos:=tokenpos;
  107. consume(ID);
  108. case token of
  109. EQUAL:
  110. begin
  111. consume(EQUAL);
  112. p:=comp_expr(true);
  113. do_firstpass(p);
  114. storetokenpos:=tokenpos;
  115. tokenpos:=filepos;
  116. case p^.treetype of
  117. ordconstn:
  118. begin
  119. if is_constintnode(p) then
  120. symtablestack^.insert(new(pconstsym,init_def(name,constint,p^.value,nil)))
  121. else if is_constcharnode(p) then
  122. symtablestack^.insert(new(pconstsym,init_def(name,constchar,p^.value,nil)))
  123. else if is_constboolnode(p) then
  124. symtablestack^.insert(new(pconstsym,init_def(name,constbool,p^.value,nil)))
  125. else if p^.resulttype^.deftype=enumdef then
  126. symtablestack^.insert(new(pconstsym,init_def(name,constord,p^.value,p^.resulttype)))
  127. else if p^.resulttype^.deftype=pointerdef then
  128. symtablestack^.insert(new(pconstsym,init_def(name,constord,p^.value,p^.resulttype)))
  129. else internalerror(111);
  130. end;
  131. stringconstn:
  132. begin
  133. getmem(sp,p^.length+1);
  134. move(p^.value_str^,sp^,p^.length+1);
  135. symtablestack^.insert(new(pconstsym,init_string(name,conststring,sp,p^.length)));
  136. end;
  137. realconstn :
  138. begin
  139. new(pd);
  140. pd^:=p^.value_real;
  141. symtablestack^.insert(new(pconstsym,init(name,constreal,longint(pd))));
  142. end;
  143. setconstn :
  144. begin
  145. new(ps);
  146. ps^:=p^.value_set^;
  147. symtablestack^.insert(new(pconstsym,init_def(name,constset,longint(ps),p^.resulttype)));
  148. end;
  149. niln :
  150. begin
  151. symtablestack^.insert(new(pconstsym,init_def(name,constnil,0,p^.resulttype)));
  152. end;
  153. else
  154. Message(cg_e_illegal_expression);
  155. end;
  156. tokenpos:=storetokenpos;
  157. consume(SEMICOLON);
  158. disposetree(p);
  159. end;
  160. COLON:
  161. begin
  162. { set the blocktype first so a consume also supports a
  163. caret, to support const s : ^string = nil }
  164. block_type:=bt_type;
  165. consume(COLON);
  166. ignore_equal:=true;
  167. def:=read_type('');
  168. ignore_equal:=false;
  169. block_type:=bt_const;
  170. storetokenpos:=tokenpos;
  171. tokenpos:=filepos;
  172. {$ifdef DELPHI_CONST_IN_RODATA}
  173. if m_delphi in aktmodeswitches then
  174. sym:=new(ptypedconstsym,init(name,def,true))
  175. else
  176. {$endif DELPHI_CONST_IN_RODATA}
  177. sym:=new(ptypedconstsym,init(name,def,false));
  178. tokenpos:=storetokenpos;
  179. symtablestack^.insert(sym);
  180. consume(EQUAL);
  181. {$ifdef DELPHI_CONST_IN_RODATA}
  182. if m_delphi in aktmodeswitches then
  183. readtypedconst(def,ptypedconstsym(sym),true)
  184. else
  185. {$endif DELPHI_CONST_IN_RODATA}
  186. readtypedconst(def,ptypedconstsym(sym),false);
  187. consume(SEMICOLON);
  188. end;
  189. else consume(EQUAL);
  190. end;
  191. until token<>ID;
  192. block_type:=old_block_type;
  193. end;
  194. procedure label_dec;
  195. var
  196. hl : pasmlabel;
  197. begin
  198. consume(_LABEL);
  199. if not(cs_support_goto in aktmoduleswitches) then
  200. Message(sym_e_goto_and_label_not_supported);
  201. repeat
  202. if not(token in [ID,INTCONST]) then
  203. consume(ID)
  204. else
  205. begin
  206. getlabel(hl);
  207. symtablestack^.insert(new(plabelsym,init(pattern,hl)));
  208. consume(token);
  209. end;
  210. if token<>SEMICOLON then consume(COMMA);
  211. until not(token in [ID,INTCONST]);
  212. consume(SEMICOLON);
  213. end;
  214. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  215. { reads the filed of a record into a }
  216. { symtablestack, if record=false }
  217. { variants are forbidden, so this procedure }
  218. { can be used to read object fields }
  219. { if absolute is true, ABSOLUTE and file }
  220. { types are allowed }
  221. { => the procedure is also used to read }
  222. { a sequence of variable declaration }
  223. var
  224. sc : pstringcontainer;
  225. s : stringid;
  226. old_block_type : tblock_type;
  227. declarepos,storetokenpos : tfileposinfo;
  228. symdone : boolean;
  229. { to handle absolute }
  230. abssym : pabsolutesym;
  231. l : longint;
  232. code : integer;
  233. { c var }
  234. newtype : ptypesym;
  235. is_dll,
  236. is_gpc_name,is_cdecl,extern_aktvarsym,export_aktvarsym : boolean;
  237. dll_name,
  238. C_name : string;
  239. { case }
  240. p,casedef : pdef;
  241. { Delphi initialized vars }
  242. pconstsym : ptypedconstsym;
  243. { maxsize contains the max. size of a variant }
  244. { startvarrec contains the start of the variant part of a record }
  245. maxsize,startvarrec : longint;
  246. pt : ptree;
  247. begin
  248. old_block_type:=block_type;
  249. block_type:=bt_type;
  250. is_gpc_name:=false;
  251. { Force an expected ID error message }
  252. if not (token in [ID,_CASE,_END]) then
  253. consume(ID);
  254. { read vars }
  255. while (token=ID) and
  256. not(is_object and (idtoken in [_PUBLIC,_PRIVATE,_PUBLISHED,_PROTECTED])) do
  257. begin
  258. C_name:=orgpattern;
  259. sc:=idlist;
  260. consume(COLON);
  261. if (m_gpc in aktmodeswitches) and
  262. not(is_record or is_object or is_threadvar) and
  263. (token=ID) and (orgpattern='__asmname__') then
  264. begin
  265. consume(ID);
  266. C_name:=pattern;
  267. if token=CCHAR then
  268. consume(CCHAR)
  269. else
  270. consume(CSTRING);
  271. Is_gpc_name:=true;
  272. end;
  273. { this is needed for Delphi mode at least
  274. but should be OK for all modes !! (PM) }
  275. ignore_equal:=true;
  276. p:=read_type('');
  277. ignore_equal:=false;
  278. symdone:=false;
  279. if is_gpc_name then
  280. begin
  281. storetokenpos:=tokenpos;
  282. s:=sc^.get_with_tokeninfo(tokenpos);
  283. if not sc^.empty then
  284. Message(parser_e_absolute_only_one_var);
  285. dispose(sc,done);
  286. aktvarsym:=new(pvarsym,init_C(s,target_os.Cprefix+C_name,p));
  287. aktvarsym^.var_options:=aktvarsym^.var_options or vo_is_external;
  288. symtablestack^.insert(aktvarsym);
  289. tokenpos:=storetokenpos;
  290. symdone:=true;
  291. end;
  292. { check for absolute }
  293. if not symdone and
  294. (idtoken=_ABSOLUTE) and not(is_record or is_object or is_threadvar) then
  295. begin
  296. consume(_ABSOLUTE);
  297. { only allowed for one var }
  298. s:=sc^.get_with_tokeninfo(declarepos);
  299. if not sc^.empty then
  300. Message(parser_e_absolute_only_one_var);
  301. dispose(sc,done);
  302. { parse the rest }
  303. if token=ID then
  304. begin
  305. getsym(pattern,true);
  306. consume(ID);
  307. { we should check the result type of srsym }
  308. if not (srsym^.typ in [varsym,typedconstsym]) then
  309. Message(parser_e_absolute_only_to_var_or_const);
  310. storetokenpos:=tokenpos;
  311. tokenpos:=declarepos;
  312. abssym:=new(pabsolutesym,init(s,p));
  313. abssym^.abstyp:=tovar;
  314. abssym^.ref:=srsym;
  315. symtablestack^.insert(abssym);
  316. tokenpos:=storetokenpos;
  317. end
  318. else
  319. if (token=CSTRING) or (token=CCHAR) then
  320. begin
  321. storetokenpos:=tokenpos;
  322. tokenpos:=declarepos;
  323. abssym:=new(pabsolutesym,init(s,p));
  324. s:=pattern;
  325. consume(token);
  326. abssym^.abstyp:=toasm;
  327. abssym^.asmname:=stringdup(s);
  328. symtablestack^.insert(abssym);
  329. tokenpos:=storetokenpos;
  330. end
  331. else
  332. { absolute address ?!? }
  333. if token=INTCONST then
  334. begin
  335. if (target_info.target=target_i386_go32v2) then
  336. begin
  337. storetokenpos:=tokenpos;
  338. tokenpos:=declarepos;
  339. abssym:=new(pabsolutesym,init(s,p));
  340. abssym^.abstyp:=toaddr;
  341. abssym^.absseg:=false;
  342. s:=pattern;
  343. consume(INTCONST);
  344. val(s,abssym^.address,code);
  345. if token=COLON then
  346. begin
  347. consume(token);
  348. s:=pattern;
  349. consume(INTCONST);
  350. val(s,l,code);
  351. abssym^.address:=abssym^.address shl 4+l;
  352. abssym^.absseg:=true;
  353. end;
  354. symtablestack^.insert(abssym);
  355. tokenpos:=storetokenpos;
  356. end
  357. else
  358. Message(parser_e_absolute_only_to_var_or_const);
  359. end
  360. else
  361. Message(parser_e_absolute_only_to_var_or_const);
  362. symdone:=true;
  363. end;
  364. { Handling of Delphi typed const = initialized vars ! }
  365. { When should this be rejected ?
  366. - in parasymtable
  367. - in record or object
  368. - ... (PM) }
  369. if (m_delphi in aktmodeswitches) and (token=EQUAL) and
  370. not (symtablestack^.symtabletype in [parasymtable]) and
  371. not is_record and not is_object then
  372. begin
  373. storetokenpos:=tokenpos;
  374. s:=sc^.get_with_tokeninfo(tokenpos);
  375. if not sc^.empty then
  376. Message(parser_e_initialized_only_one_var);
  377. pconstsym:=new(ptypedconstsym,init(s,p,false));
  378. symtablestack^.insert(pconstsym);
  379. tokenpos:=storetokenpos;
  380. consume(EQUAL);
  381. readtypedconst(p,pconstsym,false);
  382. symdone:=true;
  383. end;
  384. { for a record there doesn't need to be a ; before the END or ) }
  385. if not((is_record or is_object) and (token in [_END,RKLAMMER])) then
  386. consume(SEMICOLON);
  387. { procvar handling }
  388. if (p^.deftype=procvardef) and (p^.sym=nil) then
  389. begin
  390. newtype:=new(ptypesym,init('unnamed',p));
  391. parse_var_proc_directives(newtype);
  392. newtype^.definition:=nil;
  393. p^.sym:=nil;
  394. dispose(newtype,done);
  395. end;
  396. { Check for variable directives }
  397. if not symdone and (token=ID) then
  398. begin
  399. { Check for C Variable declarations }
  400. if (m_cvar_support in aktmodeswitches) and
  401. not(is_record or is_object or is_threadvar) and
  402. (idtoken in [_EXPORT,_EXTERNAL,_PUBLIC,_CVAR]) then
  403. begin
  404. { only allowed for one var }
  405. s:=sc^.get_with_tokeninfo(declarepos);
  406. if not sc^.empty then
  407. Message(parser_e_absolute_only_one_var);
  408. dispose(sc,done);
  409. { defaults }
  410. is_dll:=false;
  411. is_cdecl:=false;
  412. extern_aktvarsym:=false;
  413. export_aktvarsym:=false;
  414. { cdecl }
  415. if idtoken=_CVAR then
  416. begin
  417. consume(_CVAR);
  418. consume(SEMICOLON);
  419. is_cdecl:=true;
  420. C_name:=target_os.Cprefix+C_name;
  421. end;
  422. { external }
  423. if idtoken=_EXTERNAL then
  424. begin
  425. consume(_EXTERNAL);
  426. extern_aktvarsym:=true;
  427. end;
  428. { export }
  429. if idtoken in [_EXPORT,_PUBLIC] then
  430. begin
  431. consume(ID);
  432. if extern_aktvarsym then
  433. Message(parser_e_not_external_and_export)
  434. else
  435. export_aktvarsym:=true;
  436. end;
  437. { external and export need a name after when no cdecl is used }
  438. if not is_cdecl then
  439. begin
  440. { dll name ? }
  441. if (extern_aktvarsym) and (idtoken<>_NAME) then
  442. begin
  443. is_dll:=true;
  444. dll_name:=get_stringconst;
  445. end;
  446. consume(_NAME);
  447. C_name:=get_stringconst;
  448. end;
  449. { consume the ; when export or external is used }
  450. if extern_aktvarsym or export_aktvarsym then
  451. consume(SEMICOLON);
  452. { insert in the symtable }
  453. storetokenpos:=tokenpos;
  454. tokenpos:=declarepos;
  455. if is_dll then
  456. aktvarsym:=new(pvarsym,init_dll(s,p))
  457. else
  458. aktvarsym:=new(pvarsym,init_C(s,C_name,p));
  459. { set some vars options }
  460. if export_aktvarsym then
  461. inc(aktvarsym^.refs);
  462. if extern_aktvarsym then
  463. aktvarsym^.var_options:=aktvarsym^.var_options or vo_is_external;
  464. { insert in the stack/datasegment }
  465. symtablestack^.insert(aktvarsym);
  466. tokenpos:=storetokenpos;
  467. { now we can insert it in the import lib if its a dll, or
  468. add it to the externals }
  469. if extern_aktvarsym then
  470. begin
  471. if is_dll then
  472. begin
  473. if not(current_module^.uses_imports) then
  474. begin
  475. current_module^.uses_imports:=true;
  476. importlib^.preparelib(current_module^.modulename^);
  477. end;
  478. importlib^.importvariable(aktvarsym^.mangledname,dll_name,C_name)
  479. end
  480. end;
  481. symdone:=true;
  482. end
  483. else
  484. if (is_object) and (cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
  485. begin
  486. current_object_option:=current_object_option or sp_static;
  487. insert_syms(symtablestack,sc,p,false);
  488. current_object_option:=current_object_option - sp_static;
  489. consume(_STATIC);
  490. consume(SEMICOLON);
  491. symdone:=true;
  492. end;
  493. end;
  494. { insert it in the symtable, if not done yet }
  495. if not symdone then
  496. begin
  497. if (current_object_option=sp_published) and
  498. (not((p^.deftype=objectdef) and (pobjectdef(p)^.isclass))) then
  499. Message(parser_e_cant_publish_that);
  500. insert_syms(symtablestack,sc,p,is_threadvar);
  501. end;
  502. end;
  503. { Check for Case }
  504. if is_record and (token=_CASE) then
  505. begin
  506. maxsize:=0;
  507. consume(_CASE);
  508. s:=pattern;
  509. getsym(s,false);
  510. { may be only a type: }
  511. if assigned(srsym) and (srsym^.typ in [typesym,unitsym]) then
  512. casedef:=read_type('')
  513. else
  514. begin
  515. consume(ID);
  516. consume(COLON);
  517. casedef:=read_type('');
  518. symtablestack^.insert(new(pvarsym,init(s,casedef)));
  519. end;
  520. if not(is_ordinal(casedef)) or is_64bitint(casedef) then
  521. Message(type_e_ordinal_expr_expected);
  522. consume(_OF);
  523. startvarrec:=symtablestack^.datasize;
  524. repeat
  525. repeat
  526. pt:=comp_expr(true);
  527. do_firstpass(pt);
  528. if not(pt^.treetype=ordconstn) then
  529. Message(cg_e_illegal_expression);
  530. disposetree(pt);
  531. if token=COMMA then
  532. consume(COMMA)
  533. else
  534. break;
  535. until false;
  536. consume(COLON);
  537. { read the vars }
  538. consume(LKLAMMER);
  539. if token<>RKLAMMER then
  540. read_var_decs(true,false,false);
  541. consume(RKLAMMER);
  542. { calculates maximal variant size }
  543. maxsize:=max(maxsize,symtablestack^.datasize);
  544. { the items of the next variant are overlayed }
  545. symtablestack^.datasize:=startvarrec;
  546. if (token<>_END) and (token<>RKLAMMER) then
  547. consume(SEMICOLON)
  548. else
  549. break;
  550. until (token=_END) or (token=RKLAMMER);
  551. { at last set the record size to that of the biggest variant }
  552. symtablestack^.datasize:=maxsize;
  553. end;
  554. block_type:=old_block_type;
  555. end;
  556. function stringtype : pdef;
  557. { reads a string type with optional length }
  558. { and returns a pointer to the string }
  559. { definition }
  560. var
  561. p : ptree;
  562. d : pdef;
  563. begin
  564. consume(_STRING);
  565. if token=LECKKLAMMER then
  566. begin
  567. consume(LECKKLAMMER);
  568. p:=comp_expr(true);
  569. do_firstpass(p);
  570. if not is_constintnode(p) then
  571. Message(cg_e_illegal_expression);
  572. if (p^.value<=0) then
  573. begin
  574. Message(parser_e_invalid_string_size);
  575. p^.value:=255;
  576. end;
  577. consume(RECKKLAMMER);
  578. if p^.value>255 then
  579. d:=new(pstringdef,longinit(p^.value))
  580. else
  581. if p^.value<>255 then
  582. d:=new(pstringdef,shortinit(p^.value))
  583. else
  584. d:=cshortstringdef;
  585. disposetree(p);
  586. end
  587. else
  588. begin
  589. if cs_ansistrings in aktlocalswitches then
  590. d:=cansistringdef
  591. else
  592. d:=cshortstringdef;
  593. end;
  594. stringtype:=d;
  595. end;
  596. function id_type(var s : string) : pdef;
  597. { reads a type definition and returns a pointer }
  598. { to a appropriating pdef, s gets the name of }
  599. { the type to allow name mangling }
  600. begin
  601. s:=pattern;
  602. consume(ID);
  603. { classes can be used also in classes }
  604. if (curobjectname=pattern) and aktobjectdef^.isclass then
  605. begin
  606. id_type:=aktobjectdef;
  607. exit;
  608. end;
  609. { objects can be parameters }
  610. if (testcurobject=2) and (curobjectname=pattern) then
  611. begin
  612. id_type:=aktobjectdef;
  613. exit;
  614. end;
  615. getsym(s,true);
  616. if assigned(srsym) then
  617. begin
  618. if srsym^.typ=unitsym then
  619. begin
  620. consume(POINT);
  621. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  622. s:=pattern;
  623. consume(ID);
  624. end;
  625. if not assigned(srsym) or
  626. (srsym^.typ<>typesym) then
  627. begin
  628. Message(type_e_type_id_expected);
  629. lasttypesym:=ptypesym(srsym);
  630. id_type:=generrordef;
  631. exit;
  632. end;
  633. if not forwardsallowed then
  634. testforward_type(srsym);
  635. end;
  636. lasttypesym:=ptypesym(srsym);
  637. id_type:=ptypesym(srsym)^.definition;
  638. end;
  639. function single_type(var s : string) : pdef;
  640. { reads a string, file type or a type id and returns a name and }
  641. { pdef }
  642. var
  643. hs : string;
  644. begin
  645. case token of
  646. _STRING:
  647. begin
  648. single_type:=stringtype;
  649. s:='STRING';
  650. lasttypesym:=nil;
  651. end;
  652. _FILE:
  653. begin
  654. consume(_FILE);
  655. if token=_OF then
  656. begin
  657. consume(_OF);
  658. single_type:=new(pfiledef,init(ft_typed,single_type(hs)));
  659. s:='FILE$OF$'+hs;
  660. end
  661. else
  662. begin
  663. { single_type:=new(pfiledef,init(ft_untyped,nil));}
  664. single_type:=cfiledef;
  665. s:='FILE';
  666. end;
  667. lasttypesym:=nil;
  668. end;
  669. else single_type:=id_type(s);
  670. end;
  671. end;
  672. function object_dec(const n : stringid;fd : pobjectdef) : pdef;
  673. { this function parses an object or class declaration }
  674. var
  675. actmembertype : symprop;
  676. there_is_a_destructor : boolean;
  677. is_a_class : boolean;
  678. childof : pobjectdef;
  679. aktclass : pobjectdef;
  680. procedure constructor_head;
  681. begin
  682. consume(_CONSTRUCTOR);
  683. { must be at same level as in implementation }
  684. inc(lexlevel);
  685. parse_proc_head(poconstructor);
  686. dec(lexlevel);
  687. if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'INIT') then
  688. Message(parser_e_constructorname_must_be_init);
  689. aktclass^.options:=aktclass^.options or oo_hasconstructor;
  690. consume(SEMICOLON);
  691. begin
  692. if (aktclass^.options and oo_is_class)<>0 then
  693. begin
  694. { CLASS constructors return the created instance }
  695. aktprocsym^.definition^.retdef:=aktclass;
  696. end
  697. else
  698. begin
  699. { OBJECT constructors return a boolean }
  700. {$IfDef GDB}
  701. {GDB doesn't like unnamed types !}
  702. aktprocsym^.definition^.retdef:=
  703. globaldef('boolean');
  704. {$Else GDB}
  705. aktprocsym^.definition^.retdef:=
  706. new(porddef,init(bool8bit,0,1));
  707. {$Endif GDB}
  708. end;
  709. end;
  710. end;
  711. procedure property_dec;
  712. var
  713. sym : psym;
  714. propertyparas : pdefcoll;
  715. { returns the matching procedure to access a property }
  716. function get_procdef : pprocdef;
  717. var
  718. p : pprocdef;
  719. begin
  720. p:=pprocsym(sym)^.definition;
  721. get_procdef:=nil;
  722. while assigned(p) do
  723. begin
  724. if equal_paras(p^.para1,propertyparas,true) then
  725. break;
  726. p:=p^.nextoverloaded;
  727. end;
  728. get_procdef:=p;
  729. end;
  730. var
  731. hp2,datacoll : pdefcoll;
  732. p,p2 : ppropertysym;
  733. overriden : psym;
  734. hs : string;
  735. code : integer;
  736. varspez : tvarspez;
  737. sc : pstringcontainer;
  738. hp : pdef;
  739. s : string;
  740. declarepos : tfileposinfo;
  741. pp : pprocdef;
  742. pt : ptree;
  743. propname : stringid;
  744. begin
  745. { check for a class }
  746. if (aktclass^.options and oo_is_class=0) then
  747. Message(parser_e_syntax_error);
  748. consume(_PROPERTY);
  749. propertyparas:=nil;
  750. datacoll:=nil;
  751. if token=ID then
  752. begin
  753. p:=new(ppropertysym,init(pattern));
  754. propname:=pattern;
  755. consume(ID);
  756. { property parameters ? }
  757. if token=LECKKLAMMER then
  758. begin
  759. if current_object_option=sp_published then
  760. Message(parser_e_cant_publish_that_property);
  761. { create a list of the parameters in propertyparas }
  762. consume(LECKKLAMMER);
  763. inc(testcurobject);
  764. repeat
  765. if token=_VAR then
  766. begin
  767. consume(_VAR);
  768. varspez:=vs_var;
  769. end
  770. else if token=_CONST then
  771. begin
  772. consume(_CONST);
  773. varspez:=vs_const;
  774. end
  775. else varspez:=vs_value;
  776. sc:=idlist;
  777. if token=COLON then
  778. begin
  779. consume(COLON);
  780. if token=_ARRAY then
  781. begin
  782. {
  783. if (varspez<>vs_const) and
  784. (varspez<>vs_var) then
  785. begin
  786. varspez:=vs_const;
  787. Message(parser_e_illegal_open_parameter);
  788. end;
  789. }
  790. consume(_ARRAY);
  791. consume(_OF);
  792. { define range and type of range }
  793. hp:=new(parraydef,init(0,-1,s32bitdef));
  794. { define field type }
  795. parraydef(hp)^.definition:=single_type(s);
  796. end
  797. else
  798. hp:=single_type(s);
  799. end
  800. else
  801. hp:=cformaldef;
  802. s:=sc^.get_with_tokeninfo(declarepos);
  803. while s<>'' do
  804. begin
  805. new(hp2);
  806. hp2^.paratyp:=varspez;
  807. hp2^.data:=hp;
  808. hp2^.next:=propertyparas;
  809. propertyparas:=hp2;
  810. s:=sc^.get_with_tokeninfo(declarepos);
  811. end;
  812. dispose(sc,done);
  813. if token=SEMICOLON then consume(SEMICOLON)
  814. else break;
  815. until false;
  816. dec(testcurobject);
  817. consume(RECKKLAMMER);
  818. end;
  819. { overriden property ? }
  820. { force property interface, if there is a property parameter }
  821. if (token=COLON) or assigned(propertyparas) then
  822. begin
  823. consume(COLON);
  824. p^.proptype:=single_type(hs);
  825. if (idtoken=_INDEX) then
  826. begin
  827. consume(_INDEX);
  828. p^.options:=p^.options or ppo_indexed;
  829. if token=INTCONST then
  830. val(pattern,p^.index,code);
  831. consume(INTCONST);
  832. { concat a longint to the para template }
  833. new(hp2);
  834. hp2^.paratyp:=vs_value;
  835. hp2^.data:=s32bitdef;
  836. hp2^.next:=propertyparas;
  837. propertyparas:=hp2;
  838. end;
  839. end
  840. else
  841. begin
  842. { do an property override }
  843. overriden:=search_class_member(aktclass,propname);
  844. if assigned(overriden) and (overriden^.typ=propertysym) then
  845. begin
  846. { take the whole info: }
  847. p^.options:=ppropertysym(overriden)^.options;
  848. p^.index:=ppropertysym(overriden)^.index;
  849. p^.proptype:=ppropertysym(overriden)^.proptype;
  850. p^.writeaccesssym:=ppropertysym(overriden)^.writeaccesssym;
  851. p^.readaccesssym:=ppropertysym(overriden)^.readaccesssym;
  852. p^.writeaccessdef:=ppropertysym(overriden)^.writeaccessdef;
  853. p^.readaccessdef:=ppropertysym(overriden)^.readaccessdef;
  854. p^.storedsym:=ppropertysym(overriden)^.storedsym;
  855. p^.storeddef:=ppropertysym(overriden)^.storeddef;
  856. p^.default:=ppropertysym(overriden)^.default;
  857. end
  858. else
  859. begin
  860. p^.proptype:=generrordef;
  861. message(parser_e_no_property_found_to_override);
  862. end;
  863. end;
  864. if (current_object_option=sp_published) and
  865. not(p^.proptype^.is_publishable) then
  866. Message(parser_e_cant_publish_that_property);
  867. { create data defcoll to allow correct parameter checks }
  868. new(datacoll);
  869. datacoll^.paratyp:=vs_value;
  870. datacoll^.data:=p^.proptype;
  871. datacoll^.next:=nil;
  872. if (idtoken=_READ) then
  873. begin
  874. consume(_READ);
  875. sym:=search_class_member(aktclass,pattern);
  876. if not(assigned(sym)) then
  877. begin
  878. Message1(sym_e_unknown_id,pattern);
  879. consume(ID);
  880. end
  881. else
  882. begin
  883. consume(ID);
  884. if (token=POINT) and
  885. ((sym^.typ=varsym) and (pvarsym(sym)^.definition^.deftype=recorddef)) then
  886. begin
  887. consume(POINT);
  888. getsymonlyin(precdef(pvarsym(sym)^.definition)^.symtable,pattern);
  889. if not assigned(srsym) then
  890. Message1(sym_e_illegal_field,pattern);
  891. sym:=srsym;
  892. consume(ID);
  893. end;
  894. end;
  895. if assigned(sym) then
  896. begin
  897. { varsym aren't allowed for an indexed property
  898. or an property with parameters }
  899. if ((sym^.typ=varsym) and
  900. { not necessary, an index forces propertyparas
  901. to be assigned
  902. }
  903. { (((p^.options and ppo_indexed)<>0) or }
  904. assigned(propertyparas)) or
  905. not(sym^.typ in [varsym,procsym]) then
  906. Message(parser_e_ill_property_access_sym);
  907. { search the matching definition }
  908. if sym^.typ=procsym then
  909. begin
  910. pp:=get_procdef;
  911. if not(assigned(pp)) or
  912. not(is_equal(pp^.retdef,p^.proptype)) then
  913. Message(parser_e_ill_property_access_sym);
  914. p^.readaccessdef:=pp;
  915. end
  916. else if sym^.typ=varsym then
  917. begin
  918. if not(is_equal(pvarsym(sym)^.definition,
  919. p^.proptype)) then
  920. Message(parser_e_ill_property_access_sym);
  921. end;
  922. p^.readaccesssym:=sym;
  923. end;
  924. end;
  925. if (idtoken=_WRITE) then
  926. begin
  927. consume(_WRITE);
  928. sym:=search_class_member(aktclass,pattern);
  929. if not(assigned(sym)) then
  930. begin
  931. Message1(sym_e_unknown_id,pattern);
  932. consume(ID);
  933. end
  934. else
  935. begin
  936. consume(ID);
  937. if (token=POINT) and
  938. ((sym^.typ=varsym) and (pvarsym(sym)^.definition^.deftype=recorddef)) then
  939. begin
  940. consume(POINT);
  941. getsymonlyin(precdef(pvarsym(sym)^.definition)^.symtable,pattern);
  942. if not assigned(srsym) then
  943. Message1(sym_e_illegal_field,pattern);
  944. sym:=srsym;
  945. consume(ID);
  946. end;
  947. end;
  948. if assigned(sym) then
  949. begin
  950. if ((sym^.typ=varsym) and
  951. assigned(propertyparas)) or
  952. not(sym^.typ in [varsym,procsym]) then
  953. Message(parser_e_ill_property_access_sym);
  954. { search the matching definition }
  955. if sym^.typ=procsym then
  956. begin
  957. { insert data entry to check access method }
  958. datacoll^.next:=propertyparas;
  959. propertyparas:=datacoll;
  960. pp:=get_procdef;
  961. { ... and remove it }
  962. propertyparas:=propertyparas^.next;
  963. datacoll^.next:=nil;
  964. if not(assigned(pp)) then
  965. Message(parser_e_ill_property_access_sym);
  966. p^.writeaccessdef:=pp;
  967. end
  968. else if sym^.typ=varsym then
  969. begin
  970. if not(is_equal(pvarsym(sym)^.definition,
  971. p^.proptype)) then
  972. Message(parser_e_ill_property_access_sym);
  973. end;
  974. p^.writeaccesssym:=sym;
  975. end;
  976. end;
  977. if (idtoken=_STORED) then
  978. begin
  979. consume(_STORED);
  980. Message(parser_w_stored_not_implemented);
  981. { !!!!!!!! }
  982. end;
  983. if (idtoken=_DEFAULT) then
  984. begin
  985. consume(_DEFAULT);
  986. if not(is_ordinal(p^.proptype) or
  987. is_64bitint(p^.proptype) or
  988. ((p^.proptype^.deftype=setdef) and
  989. (psetdef(p^.proptype)^.settype=smallset)
  990. ) or
  991. assigned(propertyparas)
  992. ) then
  993. Message(parser_e_property_cant_have_a_default_value);
  994. { Get the result of the default, the firstpass is
  995. needed to support values like -1 }
  996. pt:=comp_expr(true);
  997. do_firstpass(pt);
  998. if p^.proptype^.deftype=setdef then
  999. begin
  1000. arrayconstructor_to_set(pt);
  1001. do_firstpass(pt);
  1002. end;
  1003. pt:=gentypeconvnode(pt,p^.proptype);
  1004. do_firstpass(pt);
  1005. if not(is_constnode(pt)) then
  1006. Message(parser_e_property_default_value_must_const);
  1007. if pt^.treetype=setconstn then
  1008. p^.default:=plongint(pt^.value_set)^
  1009. else
  1010. p^.default:=pt^.value;
  1011. disposetree(pt);
  1012. end
  1013. else if (idtoken=_NODEFAULT) then
  1014. begin
  1015. consume(_NODEFAULT);
  1016. p^.default:=0;
  1017. end;
  1018. symtablestack^.insert(p);
  1019. { default property ? }
  1020. consume(SEMICOLON);
  1021. if (idtoken=_DEFAULT) then
  1022. begin
  1023. consume(_DEFAULT);
  1024. p2:=search_default_property(aktclass);
  1025. if assigned(p2) then
  1026. message1(parser_e_only_one_default_property,
  1027. pobjectdef(p2^.owner^.defowner)^.objname^)
  1028. else
  1029. begin
  1030. p^.options:=p^.options or ppo_defaultproperty;
  1031. if not(assigned(propertyparas)) then
  1032. message(parser_e_property_need_paras);
  1033. end;
  1034. consume(SEMICOLON);
  1035. end;
  1036. { clean up }
  1037. if assigned(datacoll) then
  1038. disposepdefcoll(datacoll);
  1039. end
  1040. else
  1041. begin
  1042. consume(ID);
  1043. consume(SEMICOLON);
  1044. end;
  1045. if assigned(propertyparas) then
  1046. disposepdefcoll(propertyparas);
  1047. end;
  1048. procedure destructor_head;
  1049. begin
  1050. consume(_DESTRUCTOR);
  1051. inc(lexlevel);
  1052. parse_proc_head(podestructor);
  1053. dec(lexlevel);
  1054. if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'DONE') then
  1055. Message(parser_e_destructorname_must_be_done);
  1056. aktclass^.options:=aktclass^.options or oo_hasdestructor;
  1057. consume(SEMICOLON);
  1058. if assigned(aktprocsym^.definition^.para1) then
  1059. Message(parser_e_no_paras_for_destructor);
  1060. { no return value }
  1061. aktprocsym^.definition^.retdef:=voiddef;
  1062. end;
  1063. var
  1064. hs : string;
  1065. pcrd : pclassrefdef;
  1066. hp1 : pdef;
  1067. oldprocsym : pprocsym;
  1068. oldparse_only : boolean;
  1069. intmessagetable,strmessagetable,classnamelabel : pasmlabel;
  1070. storetypeforwardsallowed : boolean;
  1071. begin
  1072. {Nowadays aktprocsym may already have a value, so we need to save
  1073. it.}
  1074. oldprocsym:=aktprocsym;
  1075. { forward is resolved }
  1076. if assigned(fd) then
  1077. fd^.options:=fd^.options and not(oo_isforward);
  1078. there_is_a_destructor:=false;
  1079. actmembertype:=sp_public;
  1080. { objects and class types can't be declared local }
  1081. if (symtablestack^.symtabletype<>globalsymtable) and
  1082. (symtablestack^.symtabletype<>staticsymtable) then
  1083. Message(parser_e_no_local_objects);
  1084. storetypeforwardsallowed:=typecanbeforward;
  1085. if m_tp in aktmodeswitches then
  1086. typecanbeforward:=false;
  1087. { distinguish classes and objects }
  1088. if token=_OBJECT then
  1089. begin
  1090. is_a_class:=false;
  1091. consume(_OBJECT)
  1092. end
  1093. else
  1094. begin
  1095. is_a_class:=true;
  1096. consume(_CLASS);
  1097. if not(assigned(fd)) and (token=_OF) then
  1098. begin
  1099. { a hack, but it's easy to handle }
  1100. { class reference type }
  1101. consume(_OF);
  1102. if typecanbeforward then
  1103. forwardsallowed:=true;
  1104. hp1:=single_type(hs);
  1105. { accept hp1, if is a forward def ...}
  1106. if ((lasttypesym<>nil)
  1107. and ((lasttypesym^.properties and sp_forwarddef)<>0)) or
  1108. { or a class
  1109. (if the foward defined type is a class is checked, when
  1110. the forward is resolved)
  1111. }
  1112. ((hp1^.deftype=objectdef) and (
  1113. (pobjectdef(hp1)^.options and oo_is_class)<>0)) then
  1114. begin
  1115. pcrd:=new(pclassrefdef,init(hp1));
  1116. object_dec:=pcrd;
  1117. if assigned(lasttypesym) and ((lasttypesym^.properties and sp_forwarddef)<>0) then
  1118. lasttypesym^.addforwardpointer(ppointerdef(pcrd));
  1119. forwardsallowed:=false;
  1120. end
  1121. else
  1122. begin
  1123. Message(type_e_class_type_expected);
  1124. object_dec:=new(perrordef,init);
  1125. end;
  1126. typecanbeforward:=storetypeforwardsallowed;
  1127. exit;
  1128. end
  1129. { forward class }
  1130. else if not(assigned(fd)) and (token=SEMICOLON) then
  1131. begin
  1132. { also anonym objects aren't allow (o : object a : longint; end;) }
  1133. if n='' then
  1134. begin
  1135. Message(parser_f_no_anonym_objects)
  1136. end;
  1137. if n='TOBJECT' then
  1138. begin
  1139. aktclass:=new(pobjectdef,init(n,nil));
  1140. class_tobject:=aktclass;
  1141. end
  1142. else
  1143. aktclass:=new(pobjectdef,init(n,nil));
  1144. aktclass^.options:=aktclass^.options or oo_is_class or oo_isforward;
  1145. { all classes must have a vmt !! at offset zero }
  1146. if (aktclass^.options and oo_hasvmt)=0 then
  1147. aktclass^.insertvmt;
  1148. object_dec:=aktclass;
  1149. typecanbeforward:=storetypeforwardsallowed;
  1150. exit;
  1151. end;
  1152. end;
  1153. { also anonym objects aren't allow (o : object a : longint; end;) }
  1154. if n='' then
  1155. Message(parser_f_no_anonym_objects);
  1156. { read the parent class }
  1157. if token=LKLAMMER then
  1158. begin
  1159. consume(LKLAMMER);
  1160. { does not allow objects.tobject !! }
  1161. {if token<>ID then
  1162. consume(ID);
  1163. getsym(pattern,true);}
  1164. childof:=pobjectdef(id_type(pattern));
  1165. if (childof^.deftype<>objectdef) then
  1166. begin
  1167. Message(type_e_class_type_expected);
  1168. childof:=nil;
  1169. end
  1170. else
  1171. begin
  1172. { a mix of class and object isn't allowed }
  1173. if (((childof^.options and oo_is_class)<>0) and not is_a_class) or
  1174. (((childof^.options and oo_is_class)=0) and is_a_class) then
  1175. Message(parser_e_mix_of_classes_and_objects);
  1176. end;
  1177. if assigned(fd) then
  1178. begin
  1179. { the forward of the child must be resolved to get
  1180. correct field addresses
  1181. }
  1182. if (childof^.options and oo_isforward)<>0 then
  1183. Message1(parser_e_forward_declaration_must_be_resolved,childof^.objname^);
  1184. aktclass:=fd;
  1185. { we must inherit several options !!
  1186. this was missing !!
  1187. all is now done in set_parent
  1188. including symtable datasize setting PM }
  1189. fd^.set_parent(childof);
  1190. end
  1191. else
  1192. aktclass:=new(pobjectdef,init(n,childof));
  1193. consume(RKLAMMER);
  1194. end
  1195. { if no parent class, then a class get tobject as parent }
  1196. else if is_a_class then
  1197. begin
  1198. { is the current class tobject? }
  1199. { so you could define your own tobject }
  1200. if n='TOBJECT' then
  1201. begin
  1202. if assigned(fd) then
  1203. aktclass:=fd
  1204. else
  1205. aktclass:=new(pobjectdef,init(n,nil));
  1206. class_tobject:=aktclass;
  1207. end
  1208. else
  1209. begin
  1210. childof:=class_tobject;
  1211. if assigned(fd) then
  1212. begin
  1213. { the forward of the child must be resolved to get
  1214. correct field addresses
  1215. }
  1216. if (childof^.options and oo_isforward)<>0 then
  1217. Message1(parser_e_forward_declaration_must_be_resolved,childof^.objname^);
  1218. aktclass:=fd;
  1219. aktclass^.set_parent(childof);
  1220. end
  1221. else
  1222. begin
  1223. aktclass:=new(pobjectdef,init(n,childof));
  1224. aktclass^.set_parent(childof);
  1225. end;
  1226. end;
  1227. end
  1228. else
  1229. aktclass:=new(pobjectdef,init(n,nil));
  1230. { set the class attribute }
  1231. if is_a_class then
  1232. begin
  1233. aktclass^.options:=aktclass^.options or oo_is_class;
  1234. if (cs_generate_rtti in aktlocalswitches) or
  1235. (assigned(aktclass^.childof) and
  1236. ((aktclass^.childof^.options and oo_can_have_published)<>0)
  1237. ) then
  1238. aktclass^.options:=aktclass^.options or oo_can_have_published;
  1239. end;
  1240. aktobjectdef:=aktclass;
  1241. { default access is public }
  1242. actmembertype:=sp_public;
  1243. aktclass^.publicsyms^.next:=symtablestack;
  1244. symtablestack:=aktclass^.publicsyms;
  1245. procinfo._class:=aktclass;
  1246. testcurobject:=1;
  1247. curobjectname:=n;
  1248. { short class declaration ? }
  1249. if (not is_a_class) or (token<>SEMICOLON) then
  1250. begin
  1251. { Parse componenten }
  1252. repeat
  1253. if actmembertype=sp_private then
  1254. aktclass^.options:=aktclass^.options or oo_hasprivate;
  1255. if actmembertype=sp_protected then
  1256. aktclass^.options:=aktclass^.options or oo_hasprotected;
  1257. case token of
  1258. ID : begin
  1259. case idtoken of
  1260. _PRIVATE : begin
  1261. consume(_PRIVATE);
  1262. actmembertype:=sp_private;
  1263. current_object_option:=sp_private;
  1264. end;
  1265. _PROTECTED : begin
  1266. consume(_PROTECTED);
  1267. current_object_option:=sp_protected;
  1268. actmembertype:=sp_protected;
  1269. end;
  1270. _PUBLIC : begin
  1271. consume(_PUBLIC);
  1272. current_object_option:=sp_public;
  1273. actmembertype:=sp_public;
  1274. end;
  1275. _PUBLISHED : begin
  1276. if (aktclass^.options and oo_can_have_published)=0 then
  1277. Message(parser_e_cant_have_published);
  1278. consume(_PUBLISHED);
  1279. current_object_option:=sp_published;
  1280. actmembertype:=sp_published;
  1281. end;
  1282. else
  1283. read_var_decs(false,true,false);
  1284. end;
  1285. end;
  1286. _PROPERTY : property_dec;
  1287. _PROCEDURE,
  1288. _FUNCTION,
  1289. _CLASS : begin
  1290. oldparse_only:=parse_only;
  1291. parse_only:=true;
  1292. parse_proc_dec;
  1293. parse_object_proc_directives(aktprocsym);
  1294. if (aktprocsym^.definition^.options and pomsgint)<>0 then
  1295. aktclass^.options:=aktclass^.options or oo_hasmsgint;
  1296. if (aktprocsym^.definition^.options and pomsgstr)<>0 then
  1297. aktclass^.options:=aktclass^.options or oo_hasmsgstr;
  1298. if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
  1299. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1300. parse_only:=oldparse_only;
  1301. end;
  1302. _CONSTRUCTOR : begin
  1303. if actmembertype<>sp_public then
  1304. Message(parser_w_constructor_should_be_public);
  1305. oldparse_only:=parse_only;
  1306. parse_only:=true;
  1307. constructor_head;
  1308. parse_object_proc_directives(aktprocsym);
  1309. if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
  1310. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1311. parse_only:=oldparse_only;
  1312. end;
  1313. _DESTRUCTOR : begin
  1314. if there_is_a_destructor then
  1315. Message(parser_n_only_one_destructor);
  1316. there_is_a_destructor:=true;
  1317. if actmembertype<>sp_public then
  1318. Message(parser_w_destructor_should_be_public);
  1319. oldparse_only:=parse_only;
  1320. parse_only:=true;
  1321. destructor_head;
  1322. parse_object_proc_directives(aktprocsym);
  1323. if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
  1324. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1325. parse_only:=oldparse_only;
  1326. end;
  1327. _END : begin
  1328. consume(_END);
  1329. break;
  1330. end;
  1331. else
  1332. consume(ID); { Give a ident expected message, like tp7 }
  1333. end;
  1334. until false;
  1335. current_object_option:=sp_public;
  1336. end;
  1337. testcurobject:=0;
  1338. curobjectname:='';
  1339. typecanbeforward:=storetypeforwardsallowed;
  1340. { generate vmt space if needed }
  1341. if ((aktclass^.options and
  1342. (oo_hasvirtual or oo_hasconstructor or
  1343. oo_hasdestructor or oo_is_class))<>0) and
  1344. ((aktclass^.options and
  1345. oo_hasvmt)=0) then
  1346. aktclass^.insertvmt;
  1347. if (cs_smartlink in aktmoduleswitches) then
  1348. datasegment^.concat(new(pai_cut,init));
  1349. { write extended info for classes }
  1350. if is_a_class then
  1351. begin
  1352. if (aktclass^.options and oo_can_have_published)<>0 then
  1353. aktclass^.generate_rtti;
  1354. { write class name }
  1355. getdatalabel(classnamelabel);
  1356. datasegment^.concat(new(pai_label,init(classnamelabel)));
  1357. datasegment^.concat(new(pai_const,init_8bit(length(aktclass^.objname^))));
  1358. datasegment^.concat(new(pai_string,init(aktclass^.objname^)));
  1359. { generate message and dynamic tables }
  1360. { why generate those if empty ??? }
  1361. if (aktclass^.options and oo_hasmsgstr)<>0 then
  1362. strmessagetable:=genstrmsgtab(aktclass);
  1363. if (aktclass^.options and oo_hasmsgint)<>0 then
  1364. intmessagetable:=genintmsgtab(aktclass);
  1365. { table for string messages }
  1366. if (aktclass^.options and oo_hasmsgstr)<>0 then
  1367. datasegment^.concat(new(pai_const_symbol,init(strmessagetable)))
  1368. else
  1369. datasegment^.concat(new(pai_const,init_32bit(0)));
  1370. { interface table }
  1371. datasegment^.concat(new(pai_const,init_32bit(0)));
  1372. { auto table }
  1373. datasegment^.concat(new(pai_const,init_32bit(0)));
  1374. { inittable for con-/destruction }
  1375. if aktclass^.needs_inittable then
  1376. datasegment^.concat(new(pai_const_symbol,init(aktclass^.get_inittable_label)))
  1377. else
  1378. datasegment^.concat(new(pai_const,init_32bit(0)));
  1379. { pointer to type info of published section }
  1380. if (aktclass^.options and oo_can_have_published)<>0 then
  1381. datasegment^.concat(new(pai_const_symbol,initname(aktclass^.rtti_name)))
  1382. else
  1383. datasegment^.concat(new(pai_const,init_32bit(0)));
  1384. { pointer to field table }
  1385. datasegment^.concat(new(pai_const,init_32bit(0)));
  1386. { pointer to method table }
  1387. datasegment^.concat(new(pai_const,init_32bit(0)));
  1388. { pointer to dynamic table }
  1389. if (aktclass^.options and oo_hasmsgint)<>0 then
  1390. datasegment^.concat(new(pai_const_symbol,init(intmessagetable)))
  1391. else
  1392. datasegment^.concat(new(pai_const,init_32bit(0)));
  1393. { pointer to class name string }
  1394. datasegment^.concat(new(pai_const_symbol,init(classnamelabel)));
  1395. end;
  1396. {$ifdef GDB}
  1397. { generate the VMT }
  1398. if (cs_debuginfo in aktmoduleswitches) and
  1399. ((aktclass^.options and oo_hasvmt)<>0) then
  1400. begin
  1401. do_count_dbx:=true;
  1402. if assigned(aktclass^.owner) and assigned(aktclass^.owner^.name) then
  1403. datasegment^.concat(new(pai_stabs,init(strpnew('"vmt_'+aktclass^.owner^.name^+n+':S'+
  1404. typeglobalnumber('__vtbl_ptr_type')+'",'+tostr(N_STSYM)+',0,0,'+aktclass^.vmt_mangledname))));
  1405. end;
  1406. {$endif GDB}
  1407. if ((aktclass^.options and oo_hasvmt)<>0) then
  1408. begin
  1409. datasegment^.concat(new(pai_symbol,initname_global(aktclass^.vmt_mangledname)));
  1410. { determine the size with publicsyms^.datasize, because }
  1411. { size gives back 4 for classes }
  1412. datasegment^.concat(new(pai_const,init_32bit(aktclass^.publicsyms^.datasize)));
  1413. datasegment^.concat(new(pai_const,init_32bit(-aktclass^.publicsyms^.datasize)));
  1414. { write pointer to parent VMT, this isn't implemented in TP }
  1415. { but this is not used in FPC ? (PM) }
  1416. { it's not used yet, but the delphi-operators as and is need it (FK) }
  1417. { it is not written for parents that don't have any vmt !! }
  1418. if assigned(aktclass^.childof) and
  1419. ((aktclass^.childof^.options and oo_hasvmt)<>0) then
  1420. begin
  1421. datasegment^.concat(new(pai_const_symbol,initname(aktclass^.childof^.vmt_mangledname)));
  1422. end
  1423. else
  1424. datasegment^.concat(new(pai_const,init_32bit(0)));
  1425. { this generates the entries }
  1426. genvmt(aktclass);
  1427. end;
  1428. { restore old state }
  1429. symtablestack:=symtablestack^.next;
  1430. procinfo._class:=nil;
  1431. aktobjectdef:=nil;
  1432. {Restore the aktprocsym.}
  1433. aktprocsym:=oldprocsym;
  1434. object_dec:=aktclass;
  1435. end;
  1436. { reads a record declaration }
  1437. function record_dec : pdef;
  1438. var
  1439. symtable : psymtable;
  1440. storetypeforwardsallowed : boolean;
  1441. begin
  1442. symtable:=new(psymtable,init(recordsymtable));
  1443. symtable^.next:=symtablestack;
  1444. symtablestack:=symtable;
  1445. consume(_RECORD);
  1446. storetypeforwardsallowed:=typecanbeforward;
  1447. if m_tp in aktmodeswitches then
  1448. typecanbeforward:=false;
  1449. read_var_decs(true,false,false);
  1450. { may be scale record size to a size of n*4 ? }
  1451. if ((symtablestack^.datasize mod aktpackrecords)<>0) then
  1452. inc(symtablestack^.datasize,aktpackrecords-(symtablestack^.datasize mod aktpackrecords));
  1453. consume(_END);
  1454. typecanbeforward:=storetypeforwardsallowed;
  1455. symtablestack:=symtable^.next;
  1456. record_dec:=new(precdef,init(symtable));
  1457. end;
  1458. { reads a type definition and returns a pointer to it }
  1459. function read_type(const name : stringid) : pdef;
  1460. function handle_procvar:Pprocvardef;
  1461. var
  1462. sc : pstringcontainer;
  1463. hs1,s : string;
  1464. p : pdef;
  1465. varspez : tvarspez;
  1466. procvardef : pprocvardef;
  1467. begin
  1468. procvardef:=new(pprocvardef,init);
  1469. if token=LKLAMMER then
  1470. begin
  1471. consume(LKLAMMER);
  1472. inc(testcurobject);
  1473. repeat
  1474. if try_to_consume(_VAR) then
  1475. varspez:=vs_var
  1476. else
  1477. if try_to_consume(_CONST) then
  1478. varspez:=vs_const
  1479. else
  1480. varspez:=vs_value;
  1481. { self method ? }
  1482. if idtoken=_SELF then
  1483. begin
  1484. procvardef^.options:=procvardef^.options or pocontainsself;
  1485. consume(idtoken);
  1486. consume(COLON);
  1487. p:=single_type(hs1);
  1488. procvardef^.concatdef(p,vs_value);
  1489. end
  1490. else
  1491. begin
  1492. sc:=idlist;
  1493. if (token=COLON) or (varspez=vs_value) then
  1494. begin
  1495. consume(COLON);
  1496. if token=_ARRAY then
  1497. begin
  1498. consume(_ARRAY);
  1499. consume(_OF);
  1500. { define range and type of range }
  1501. p:=new(Parraydef,init(0,-1,s32bitdef));
  1502. { array of const ? }
  1503. if (token=_CONST) and (m_objpas in aktmodeswitches) then
  1504. begin
  1505. consume(_CONST);
  1506. srsym:=nil;
  1507. if assigned(objpasunit) then
  1508. getsymonlyin(objpasunit,'TVARREC');
  1509. if not assigned(srsym) then
  1510. InternalError(1234124);
  1511. Parraydef(p)^.definition:=ptypesym(srsym)^.definition;
  1512. Parraydef(p)^.IsArrayOfConst:=true;
  1513. end
  1514. else
  1515. begin
  1516. { define field type }
  1517. Parraydef(p)^.definition:=single_type(s);
  1518. end;
  1519. end
  1520. else
  1521. p:=single_type(s);
  1522. end
  1523. else
  1524. p:=cformaldef;
  1525. while not sc^.empty do
  1526. begin
  1527. s:=sc^.get;
  1528. procvardef^.concatdef(p,varspez);
  1529. end;
  1530. dispose(sc,done);
  1531. end;
  1532. until not try_to_consume(SEMICOLON);
  1533. dec(testcurobject);
  1534. consume(RKLAMMER);
  1535. end;
  1536. handle_procvar:=procvardef;
  1537. end;
  1538. var
  1539. hp1,p : pdef;
  1540. aufdef : penumdef;
  1541. aufsym : penumsym;
  1542. ap : parraydef;
  1543. s : stringid;
  1544. l,v,oldaktpackrecords : longint;
  1545. hs : string;
  1546. procedure expr_type;
  1547. var
  1548. pt1,pt2 : ptree;
  1549. begin
  1550. { use of current parsed object ? }
  1551. if (token=ID) and (testcurobject=2) and (curobjectname=pattern) then
  1552. begin
  1553. consume(ID);
  1554. p:=aktobjectdef;
  1555. exit;
  1556. end;
  1557. { we can't accept a equal in type }
  1558. pt1:=comp_expr(not(ignore_equal));
  1559. do_firstpass(pt1);
  1560. if (token=POINTPOINT) then
  1561. begin
  1562. consume(POINTPOINT);
  1563. { get high value of range }
  1564. pt2:=comp_expr(not(ignore_equal));
  1565. do_firstpass(pt2);
  1566. { both must be evaluated to constants now }
  1567. if (pt1^.treetype<>ordconstn) or (pt2^.treetype<>ordconstn) then
  1568. Message(sym_e_error_in_type_def)
  1569. else
  1570. begin
  1571. { check types }
  1572. if CheckTypes(pt1^.resulttype,pt2^.resulttype) then
  1573. begin
  1574. { Check bounds }
  1575. if pt2^.value<pt1^.value then
  1576. Message(cg_e_upper_lower_than_lower)
  1577. else
  1578. begin
  1579. { All checks passed, create the new def }
  1580. case pt1^.resulttype^.deftype of
  1581. enumdef : p:=new(penumdef,init_subrange(penumdef(pt1^.resulttype),pt1^.value,pt2^.value));
  1582. orddef : begin
  1583. if is_char(pt1^.resulttype) then
  1584. p:=new(porddef,init(uchar,pt1^.value,pt2^.value))
  1585. else
  1586. if is_boolean(pt1^.resulttype) then
  1587. p:=new(porddef,init(bool8bit,pt1^.value,pt2^.value))
  1588. else
  1589. p:=new(porddef,init(uauto,pt1^.value,pt2^.value));
  1590. end;
  1591. end;
  1592. end;
  1593. end;
  1594. end;
  1595. disposetree(pt2);
  1596. end
  1597. else
  1598. begin
  1599. { a simple type renaming }
  1600. if (pt1^.treetype=typen) then
  1601. p:=pt1^.resulttype
  1602. else
  1603. Message(sym_e_error_in_type_def);
  1604. end;
  1605. disposetree(pt1);
  1606. end;
  1607. var
  1608. pt : ptree;
  1609. procedure array_dec;
  1610. var
  1611. lowval,
  1612. highval : longint;
  1613. arraytype : pdef;
  1614. begin
  1615. consume(_ARRAY);
  1616. consume(LECKKLAMMER);
  1617. { defaults }
  1618. arraytype:=generrordef;
  1619. lowval:=$80000000;
  1620. highval:=$7fffffff;
  1621. p:=nil;
  1622. repeat
  1623. { read the expression and check it }
  1624. pt:=expr;
  1625. if pt^.treetype=typen then
  1626. begin
  1627. case pt^.resulttype^.deftype of
  1628. enumdef :
  1629. begin
  1630. lowval:=penumdef(pt^.resulttype)^.min;
  1631. highval:=penumdef(pt^.resulttype)^.max;
  1632. arraytype:=pt^.resulttype;
  1633. end;
  1634. orddef :
  1635. begin
  1636. lowval:=porddef(pt^.resulttype)^.low;
  1637. highval:=porddef(pt^.resulttype)^.high;
  1638. arraytype:=pt^.resulttype;
  1639. end;
  1640. else
  1641. Message(sym_e_error_in_type_def);
  1642. end;
  1643. end
  1644. else
  1645. begin
  1646. do_firstpass(pt);
  1647. if (pt^.treetype=rangen) then
  1648. begin
  1649. if (pt^.left^.treetype=ordconstn) and
  1650. (pt^.right^.treetype=ordconstn) then
  1651. begin
  1652. lowval:=pt^.left^.value;
  1653. highval:=pt^.right^.value;
  1654. if highval<lowval then
  1655. begin
  1656. Message(parser_e_array_lower_less_than_upper_bound);
  1657. highval:=lowval;
  1658. end;
  1659. arraytype:=pt^.right^.resulttype;
  1660. end
  1661. else
  1662. Message(type_e_cant_eval_constant_expr);
  1663. end
  1664. else
  1665. Message(sym_e_error_in_type_def)
  1666. end;
  1667. disposetree(pt);
  1668. { create arraydef }
  1669. if p=nil then
  1670. begin
  1671. ap:=new(parraydef,init(lowval,highval,arraytype));
  1672. p:=ap;
  1673. end
  1674. else
  1675. begin
  1676. ap^.definition:=new(parraydef,init(lowval,highval,arraytype));
  1677. ap:=parraydef(ap^.definition);
  1678. end;
  1679. if token=COMMA then
  1680. consume(COMMA)
  1681. else
  1682. break;
  1683. until false;
  1684. consume(RECKKLAMMER);
  1685. consume(_OF);
  1686. hp1:=read_type('');
  1687. { if no error, set element type }
  1688. if assigned(ap) then
  1689. ap^.definition:=hp1;
  1690. end;
  1691. begin
  1692. p:=nil;
  1693. case token of
  1694. _STRING,_FILE:
  1695. p:=single_type(hs);
  1696. LKLAMMER:
  1697. begin
  1698. consume(LKLAMMER);
  1699. { allow negativ value_str }
  1700. l:=-1;
  1701. aufsym := Nil;
  1702. aufdef:=new(penumdef,init);
  1703. repeat
  1704. s:=pattern;
  1705. consume(ID);
  1706. if token=ASSIGNMENT then
  1707. begin
  1708. consume(ASSIGNMENT);
  1709. v:=get_intconst;
  1710. { please leave that a note, allows type save }
  1711. { declarations in the win32 units ! }
  1712. if v<=l then
  1713. Message(parser_n_duplicate_enum);
  1714. l:=v;
  1715. end
  1716. else
  1717. inc(l);
  1718. constsymtable^.insert(new(penumsym,init(s,aufdef,l)));
  1719. if token=COMMA then
  1720. consume(COMMA)
  1721. else
  1722. break;
  1723. until false;
  1724. {aufdef^.max:=l;
  1725. if we allow unordered enums
  1726. this can be wrong
  1727. min and max are now set in tenumsym.init PM }
  1728. p:=aufdef;
  1729. consume(RKLAMMER);
  1730. end;
  1731. _ARRAY:
  1732. array_dec;
  1733. _SET:
  1734. begin
  1735. consume(_SET);
  1736. consume(_OF);
  1737. hp1:=read_type('');
  1738. if assigned(hp1) then
  1739. begin
  1740. case hp1^.deftype of
  1741. { don't forget that min can be negativ PM }
  1742. enumdef : if penumdef(hp1)^.min>=0 then
  1743. p:=new(psetdef,init(hp1,penumdef(hp1)^.max))
  1744. else
  1745. Message(sym_e_ill_type_decl_set);
  1746. orddef : begin
  1747. case porddef(hp1)^.typ of
  1748. uchar : p:=new(psetdef,init(hp1,255));
  1749. u8bit,s8bit,u16bit,s16bit,s32bit :
  1750. begin
  1751. if (porddef(hp1)^.low>=0) then
  1752. p:=new(psetdef,init(hp1,porddef(hp1)^.high))
  1753. else Message(sym_e_ill_type_decl_set);
  1754. end;
  1755. else Message(sym_e_ill_type_decl_set);
  1756. end;
  1757. end;
  1758. else Message(sym_e_ill_type_decl_set);
  1759. end;
  1760. end
  1761. else
  1762. p:=generrordef;
  1763. end;
  1764. CARET:
  1765. begin
  1766. consume(CARET);
  1767. { forwards allowed only inside TYPE statements }
  1768. if typecanbeforward then
  1769. forwardsallowed:=true;
  1770. hp1:=single_type(hs);
  1771. p:=new(ppointerdef,init(hp1));
  1772. if (lasttypesym<>nil) and ((lasttypesym^.properties and sp_forwarddef)<>0) then
  1773. lasttypesym^.addforwardpointer(ppointerdef(p));
  1774. forwardsallowed:=false;
  1775. end;
  1776. _RECORD:
  1777. p:=record_dec;
  1778. _PACKED:
  1779. begin
  1780. consume(_PACKED);
  1781. if token=_ARRAY then
  1782. array_dec
  1783. else
  1784. begin
  1785. oldaktpackrecords:=aktpackrecords;
  1786. aktpackrecords:=1;
  1787. if token in [_CLASS,_OBJECT] then
  1788. p:=object_dec(name,nil)
  1789. else
  1790. p:=record_dec;
  1791. aktpackrecords:=oldaktpackrecords;
  1792. end;
  1793. end;
  1794. _CLASS,
  1795. _OBJECT:
  1796. p:=object_dec(name,nil);
  1797. _PROCEDURE:
  1798. begin
  1799. consume(_PROCEDURE);
  1800. p:=handle_procvar;
  1801. if token=_OF then
  1802. begin
  1803. consume(_OF);
  1804. consume(_OBJECT);
  1805. pprocvardef(p)^.options:=pprocvardef(p)^.options or pomethodpointer;
  1806. end;
  1807. end;
  1808. _FUNCTION:
  1809. begin
  1810. consume(_FUNCTION);
  1811. p:=handle_procvar;
  1812. consume(COLON);
  1813. pprocvardef(p)^.retdef:=single_type(hs);
  1814. if token=_OF then
  1815. begin
  1816. consume(_OF);
  1817. consume(_OBJECT);
  1818. pprocvardef(p)^.options:=pprocvardef(p)^.options or pomethodpointer;
  1819. end;
  1820. end;
  1821. else
  1822. expr_type;
  1823. end;
  1824. if p=nil then
  1825. p:=generrordef;
  1826. read_type:=p;
  1827. end;
  1828. { reads a type declaration to the symbol table }
  1829. procedure type_dec;
  1830. var
  1831. typename : stringid;
  1832. newtype : ptypesym;
  1833. sym : psym;
  1834. begin
  1835. block_type:=bt_type;
  1836. consume(_TYPE);
  1837. typecanbeforward:=true;
  1838. repeat
  1839. typename:=pattern;
  1840. consume(ID);
  1841. consume(EQUAL);
  1842. { here you loose the strictness of pascal
  1843. for which a redefinition like
  1844. childtype = parenttype;
  1845. child2type = parenttype;
  1846. does not make the two child types equal !!
  1847. here all vars from childtype and child2type
  1848. get the definition of parenttype !! }
  1849. {$ifdef testequaltype}
  1850. if (token = ID) or (token=_FILE) or (token=_STRING) then
  1851. begin
  1852. olddef := single_type(s);
  1853. { make a clone of olddef }
  1854. { is that ok ??? }
  1855. getmem(newdef,SizeOf(olddef));
  1856. move(olddef^,newdef^,SizeOf(olddef));
  1857. newtype:=new(ptypesym,init(typename,newdef));
  1858. symtablestack^.insert(newtype);
  1859. end
  1860. else
  1861. {$endif testequaltype}
  1862. begin
  1863. getsym(typename,false);
  1864. sym:=srsym;
  1865. newtype:=nil;
  1866. { found a symbol with this name? }
  1867. if assigned(sym) then
  1868. begin
  1869. if (sym^.typ=typesym) then
  1870. begin
  1871. if (token=_CLASS) and
  1872. (assigned(ptypesym(sym)^.definition)) and
  1873. (ptypesym(sym)^.definition^.deftype=objectdef) and
  1874. ((pobjectdef(ptypesym(sym)^.definition)^.options and oo_isforward)<>0) and
  1875. ((pobjectdef(ptypesym(sym)^.definition)^.options and oo_is_class)<>0) then
  1876. begin
  1877. { we can ignore the result }
  1878. { the definition is modified }
  1879. object_dec(typename,pobjectdef(ptypesym(sym)^.definition));
  1880. newtype:=ptypesym(sym);
  1881. end
  1882. else
  1883. if sym^.properties=sp_forwarddef then
  1884. begin
  1885. ptypesym(sym)^.updateforwarddef(read_type(typename));
  1886. newtype:=ptypesym(sym);
  1887. end;
  1888. end;
  1889. end;
  1890. { no old type reused ? Then insert this new type }
  1891. if not assigned(newtype) then
  1892. begin
  1893. newtype:=new(ptypesym,init(typename,read_type(typename)));
  1894. newtype:=ptypesym(symtablestack^.insert(newtype));
  1895. end;
  1896. end;
  1897. consume(SEMICOLON);
  1898. if assigned(newtype^.definition) and (newtype^.definition^.deftype=procvardef) then
  1899. parse_var_proc_directives(newtype);
  1900. until token<>ID;
  1901. typecanbeforward:=false;
  1902. symtablestack^.foreach({$ifndef TP}@{$endif}testforward_type);
  1903. resolve_forwards;
  1904. block_type:=bt_general;
  1905. end;
  1906. procedure var_dec;
  1907. { parses varaible declarations and inserts them in }
  1908. { the top symbol table of symtablestack }
  1909. begin
  1910. consume(_VAR);
  1911. read_var_decs(false,false,false);
  1912. end;
  1913. procedure threadvar_dec;
  1914. { parses thread variable declarations and inserts them in }
  1915. { the top symbol table of symtablestack }
  1916. begin
  1917. consume(_THREADVAR);
  1918. if not(symtablestack^.symtabletype in [staticsymtable,globalsymtable]) then
  1919. message(parser_e_threadvars_only_sg);
  1920. read_var_decs(false,false,true);
  1921. end;
  1922. procedure Not_supported_for_inline(t : ttoken);
  1923. begin
  1924. if assigned(aktprocsym) and
  1925. ((aktprocsym^.definition^.options and poinline)<>0) then
  1926. Begin
  1927. Message1(parser_w_not_supported_for_inline,tokenstring(t));
  1928. Message(parser_w_inlining_disabled);
  1929. aktprocsym^.definition^.options:= aktprocsym^.definition^.options and not poinline;
  1930. End;
  1931. end;
  1932. procedure read_declarations(islibrary : boolean);
  1933. begin
  1934. repeat
  1935. case token of
  1936. _LABEL:
  1937. begin
  1938. Not_supported_for_inline(token);
  1939. label_dec;
  1940. end;
  1941. _CONST:
  1942. begin
  1943. Not_supported_for_inline(token);
  1944. const_dec;
  1945. end;
  1946. _TYPE:
  1947. begin
  1948. Not_supported_for_inline(token);
  1949. type_dec;
  1950. end;
  1951. _VAR:
  1952. var_dec;
  1953. _THREADVAR:
  1954. threadvar_dec;
  1955. _CONSTRUCTOR,_DESTRUCTOR,
  1956. _FUNCTION,_PROCEDURE,_OPERATOR,_CLASS:
  1957. begin
  1958. Not_supported_for_inline(token);
  1959. read_proc;
  1960. end;
  1961. _EXPORTS:
  1962. begin
  1963. Not_supported_for_inline(token);
  1964. { here we should be at lexlevel 1, no ? PM }
  1965. if (lexlevel<>main_program_level) or
  1966. (not islibrary and not DLLsource) then
  1967. begin
  1968. Message(parser_e_syntax_error);
  1969. consume_all_until(SEMICOLON);
  1970. end
  1971. else if islibrary then
  1972. read_exports;
  1973. end
  1974. else break;
  1975. end;
  1976. until false;
  1977. end;
  1978. procedure read_interface_declarations;
  1979. begin
  1980. {Since the body is now parsed at lexlevel 1, and the declarations
  1981. must be parsed at the same lexlevel we increase the lexlevel.}
  1982. inc(lexlevel);
  1983. repeat
  1984. case token of
  1985. _CONST : const_dec;
  1986. _TYPE : type_dec;
  1987. _VAR : var_dec;
  1988. _THREADVAR : threadvar_dec;
  1989. _FUNCTION,
  1990. _PROCEDURE,
  1991. _OPERATOR : read_proc;
  1992. else
  1993. break;
  1994. end;
  1995. until false;
  1996. dec(lexlevel);
  1997. end;
  1998. end.
  1999. {
  2000. $Log$
  2001. Revision 1.130 1999-07-05 20:25:39 peter
  2002. * merged
  2003. Revision 1.129 1999/07/02 13:02:26 peter
  2004. * merged
  2005. Revision 1.128 1999/06/30 22:16:19 florian
  2006. * use of is_ordinal checked: often a qword/int64 isn't allowed (case/for ...)
  2007. * small qword problems fixed
  2008. Revision 1.127.2.2 1999/07/05 20:03:27 peter
  2009. * removed warning/notes
  2010. Revision 1.127.2.1 1999/07/02 12:59:49 peter
  2011. * fixed parsing of message directive
  2012. Revision 1.127 1999/06/02 22:44:10 pierre
  2013. * previous wrong log corrected
  2014. Revision 1.126 1999/06/02 22:25:42 pierre
  2015. * changed $ifdef FPC @ into $ifndef TP
  2016. Revision 1.125 1999/06/01 19:27:53 peter
  2017. * better checks for procvar and methodpointer
  2018. Revision 1.124 1999/06/01 14:45:51 peter
  2019. * @procvar is now always needed for FPC
  2020. Revision 1.123 1999/05/27 19:44:45 peter
  2021. * removed oldasm
  2022. * plabel -> pasmlabel
  2023. * -a switches to source writing automaticly
  2024. * assembler readers OOPed
  2025. * asmsymbol automaticly external
  2026. * jumptables and other label fixes for asm readers
  2027. Revision 1.122 1999/05/21 20:08:22 florian
  2028. * hopefully the default property bug fixed
  2029. Revision 1.121 1999/05/21 13:55:04 peter
  2030. * NEWLAB for label as symbol
  2031. Revision 1.120 1999/05/20 22:19:52 pierre
  2032. * better stabs line info for vars
  2033. Revision 1.119 1999/05/19 12:41:56 florian
  2034. * made source compilable with TP (too long line)
  2035. * default values for set properties fixed
  2036. Revision 1.118 1999/05/18 14:15:51 peter
  2037. * containsself fixes
  2038. * checktypes()
  2039. Revision 1.117 1999/05/17 21:57:12 florian
  2040. * new temporary ansistring handling
  2041. Revision 1.116 1999/05/13 21:59:34 peter
  2042. * removed oldppu code
  2043. * warning if objpas is loaded from uses
  2044. * first things for new deref writing
  2045. Revision 1.115 1999/05/07 10:36:09 peter
  2046. * fixed crash
  2047. Revision 1.114 1999/05/04 21:44:54 florian
  2048. * changes to compile it with Delphi 4.0
  2049. Revision 1.113 1999/05/01 13:24:30 peter
  2050. * merged nasm compiler
  2051. * old asm moved to oldasm/
  2052. Revision 1.112 1999/04/28 06:02:07 florian
  2053. * changes of Bruessel:
  2054. + message handler can now take an explicit self
  2055. * typinfo fixed: sometimes the type names weren't written
  2056. * the type checking for pointer comparisations and subtraction
  2057. and are now more strict (was also buggy)
  2058. * small bug fix to link.pas to support compiling on another
  2059. drive
  2060. * probable bug in popt386 fixed: call/jmp => push/jmp
  2061. transformation didn't count correctly the jmp references
  2062. + threadvar support
  2063. * warning if ln/sqrt gets an invalid constant argument
  2064. Revision 1.111 1999/04/26 13:31:37 peter
  2065. * release storenumber,double_checksum
  2066. Revision 1.110 1999/04/25 22:42:16 pierre
  2067. + code for initialized vars in Delphi mode
  2068. Revision 1.109 1999/04/21 09:43:45 peter
  2069. * storenumber works
  2070. * fixed some typos in double_checksum
  2071. + incompatible types type1 and type2 message (with storenumber)
  2072. Revision 1.108 1999/04/17 13:16:19 peter
  2073. * fixes for storenumber
  2074. Revision 1.107 1999/04/14 09:14:50 peter
  2075. * first things to store the symbol/def number in the ppu
  2076. Revision 1.106 1999/04/07 15:31:15 pierre
  2077. * all formaldefs are now a sinlge definition
  2078. cformaldef (this was necessary for double_checksum)
  2079. + small part of double_checksum code
  2080. Revision 1.105 1999/03/26 00:05:34 peter
  2081. * released valintern
  2082. + deffile is now removed when compiling is finished
  2083. * ^( compiles now correct
  2084. + static directive
  2085. * shrd fixed
  2086. Revision 1.104 1999/03/24 23:17:13 peter
  2087. * fixed bugs 212,222,225,227,229,231,233
  2088. Revision 1.103 1999/03/22 22:10:25 florian
  2089. * typecanbeforward wasn't always restored in object_dec which
  2090. sometimes caused strange effects
  2091. Revision 1.102 1999/03/05 01:14:26 pierre
  2092. * bug0198 : call conventions for methods
  2093. not yet implemented is the control of same calling convention
  2094. for virtual and child's virtual
  2095. * msgstr and msgint only created if message was found
  2096. who implemented this by the way ?
  2097. it leaks lots of plabels !!!! (check with heaptrc !)
  2098. Revision 1.101 1999/02/25 21:02:41 peter
  2099. * ag386bin updates
  2100. + coff writer
  2101. Revision 1.100 1999/02/24 00:59:14 peter
  2102. * small updates for ag386bin
  2103. Revision 1.99 1999/02/22 23:33:29 florian
  2104. + message directive for integers added
  2105. Revision 1.98 1999/02/22 20:13:36 florian
  2106. + first implementation of message keyword
  2107. Revision 1.97 1999/02/22 02:44:10 peter
  2108. * ag386bin doesn't use i386.pas anymore
  2109. Revision 1.96 1999/02/17 14:20:40 pierre
  2110. * Reference specific bug in recompiling unit solved
  2111. Revision 1.95 1999/01/25 20:13:48 peter
  2112. * fixed crash with forward declared class of ...
  2113. Revision 1.94 1999/01/19 12:17:00 peter
  2114. * fixed constant strings > 255 chars
  2115. Revision 1.93 1999/01/15 13:08:23 peter
  2116. * error if upper<lower in array decl
  2117. Revision 1.92 1999/01/14 21:49:58 peter
  2118. * fixed forwardpointer problem with multiple forwards for the same
  2119. typesym. It now uses a linkedlist instead of a single pointer
  2120. Revision 1.91 1998/12/30 22:15:46 peter
  2121. + farpointer type
  2122. * absolutesym now also stores if its far
  2123. Revision 1.90 1998/12/15 17:16:00 peter
  2124. * fixed const s : ^string
  2125. * first things for const pchar : @string[1]
  2126. Revision 1.89 1998/12/11 00:03:30 peter
  2127. + globtype,tokens,version unit splitted from globals
  2128. Revision 1.88 1998/11/30 09:43:20 pierre
  2129. * some range check bugs fixed (still not working !)
  2130. + added DLL writing support for win32 (also accepts variables)
  2131. + TempAnsi for code that could be used for Temporary ansi strings
  2132. handling
  2133. Revision 1.87 1998/11/29 12:42:24 peter
  2134. * check for constants with array decl
  2135. Revision 1.86 1998/11/28 16:20:52 peter
  2136. + support for dll variables
  2137. Revision 1.85 1998/11/27 14:34:43 peter
  2138. * give error when string[0] decl is found
  2139. Revision 1.84 1998/11/17 10:40:15 peter
  2140. * H+ fixes
  2141. Revision 1.83 1998/11/16 11:28:59 pierre
  2142. * stackcheck removed for i386_win32
  2143. * exportlist does not crash at least !!
  2144. (was need for tests dir !)z
  2145. Revision 1.82 1998/11/16 10:18:07 peter
  2146. * fixes for ansistrings
  2147. Revision 1.81 1998/11/13 15:40:22 pierre
  2148. + added -Se in Makefile cvstest target
  2149. + lexlevel cleanup
  2150. normal_function_level main_program_level and unit_init_level defined
  2151. * tins_cache grown to A_EMMS (gave range check error in asm readers)
  2152. (test added in code !)
  2153. * -Un option was wrong
  2154. * _FAIL and _SELF only keyword inside
  2155. constructors and methods respectively
  2156. Revision 1.80 1998/11/13 10:18:09 peter
  2157. + nil constants
  2158. Revision 1.79 1998/11/05 12:02:51 peter
  2159. * released useansistring
  2160. * removed -Sv, its now available in fpc modes
  2161. Revision 1.78 1998/10/27 13:45:33 pierre
  2162. * classes get a vmt allways
  2163. * better error info (tried to remove
  2164. several error strings introduced by the tpexcept handling)
  2165. Revision 1.77 1998/10/26 22:58:20 florian
  2166. * new introduded problem with classes fix, the parent class wasn't set
  2167. correct, if the class was defined forward before
  2168. Revision 1.76 1998/10/25 23:31:18 peter
  2169. * procvar parsing updated just like psub.pas routine
  2170. Revision 1.75 1998/10/21 08:39:59 florian
  2171. + ansistring operator +
  2172. + $h and string[n] for n>255 added
  2173. * small problem with TP fixed
  2174. Revision 1.74 1998/10/20 13:09:13 peter
  2175. * fixed object(unknown) crash
  2176. Revision 1.73 1998/10/19 08:54:56 pierre
  2177. * wrong stabs info corrected once again !!
  2178. + variable vmt offset with vmt field only if required
  2179. implemented now !!!
  2180. Revision 1.72 1998/10/16 13:12:51 pierre
  2181. * added vmt_offsets in destructors code also !!!
  2182. * vmt_offset code for m68k
  2183. Revision 1.71 1998/10/15 15:13:25 pierre
  2184. + added oo_hasconstructor and oo_hasdestructor
  2185. for objects options
  2186. Revision 1.70 1998/10/13 13:10:22 peter
  2187. * new style for m68k/i386 infos and enums
  2188. Revision 1.69 1998/10/09 12:07:49 pierre
  2189. * typo error for propertyparas dispose corrected
  2190. Revision 1.68 1998/10/09 11:47:54 pierre
  2191. * still more memory leaks fixes !!
  2192. Revision 1.67 1998/10/08 13:48:46 peter
  2193. * fixed memory leaks for do nothing source
  2194. * fixed unit interdependency
  2195. Revision 1.66 1998/10/06 20:43:31 peter
  2196. * fixed set of bugs. like set of false..true set of #1..#255 and
  2197. set of #1..true which was allowed
  2198. Revision 1.65 1998/10/05 22:43:35 peter
  2199. * commited the wrong file :(
  2200. Revision 1.64 1998/10/05 21:33:24 peter
  2201. * fixed 161,165,166,167,168
  2202. Revision 1.63 1998/10/05 13:57:13 peter
  2203. * crash preventions
  2204. Revision 1.62 1998/10/02 17:06:02 peter
  2205. * better error message for unresolved forward types
  2206. Revision 1.61 1998/10/02 09:23:24 peter
  2207. * fixed error msg with type l=<var>
  2208. * block_type bt_const is now set in read_const_dec
  2209. Revision 1.60 1998/09/30 07:40:33 florian
  2210. * better error recovering
  2211. Revision 1.59 1998/09/26 17:45:33 peter
  2212. + idtoken and only one token table
  2213. Revision 1.58 1998/09/25 00:04:01 florian
  2214. * problems when calling class methods fixed
  2215. Revision 1.57 1998/09/24 23:49:09 peter
  2216. + aktmodeswitches
  2217. Revision 1.56 1998/09/23 15:39:09 pierre
  2218. * browser bugfixes
  2219. was adding a reference when looking for the symbol
  2220. if -bSYM_NAME was used
  2221. Revision 1.55 1998/09/21 13:24:44 daniel
  2222. * Memory leak fixed.
  2223. Revision 1.54 1998/09/17 13:41:16 pierre
  2224. sizeof(TPOINT) problem
  2225. Revision 1.53.2.1 1998/09/17 13:12:09 pierre
  2226. * virtual destructor did not set oo_hasvirtual
  2227. (detected with the sizeof(TPoint) problem
  2228. * genloadcallnode was missing
  2229. Revision 1.53 1998/09/09 11:50:52 pierre
  2230. * forward def are not put in record or objects
  2231. + added check for forwards also in record and objects
  2232. * dummy parasymtable for unit initialization removed from
  2233. symtable stack
  2234. Revision 1.52 1998/09/07 23:10:22 florian
  2235. * a lot of stuff fixed regarding rtti and publishing of properties,
  2236. basics should now work
  2237. Revision 1.51 1998/09/07 19:33:22 florian
  2238. + some stuff for property rtti added:
  2239. - NameIndex of the TPropInfo record is now written correctly
  2240. - the DEFAULT/NODEFAULT keyword is supported now
  2241. - the default value and the storedsym/def are now written to
  2242. the PPU fiel
  2243. Revision 1.50 1998/09/07 18:46:08 peter
  2244. * update smartlinking, uses getdatalabel
  2245. * renamed ptree.value vars to value_str,value_real,value_set
  2246. Revision 1.49 1998/09/07 17:37:00 florian
  2247. * first fixes for published properties
  2248. Revision 1.48 1998/09/04 08:42:02 peter
  2249. * updated some error messages
  2250. Revision 1.47 1998/09/03 16:03:18 florian
  2251. + rtti generation
  2252. * init table generation changed
  2253. Revision 1.46 1998/09/01 17:39:48 peter
  2254. + internal constant functions
  2255. Revision 1.45 1998/08/31 12:20:28 peter
  2256. * fixed array_dec when unknown type was used
  2257. Revision 1.44 1998/08/28 10:57:01 peter
  2258. * removed warnings
  2259. Revision 1.43 1998/08/25 13:09:25 pierre
  2260. * corrected mangling sheme :
  2261. cvar add Cprefix to the mixed case name whereas
  2262. export or public use direct name
  2263. Revision 1.42 1998/08/25 12:42:41 pierre
  2264. * CDECL changed to CVAR for variables
  2265. specifications are read in structures also
  2266. + started adding GPC compatibility mode ( option -Sp)
  2267. * names changed to lowercase
  2268. Revision 1.41 1998/08/23 21:04:36 florian
  2269. + rtti generation for classes added
  2270. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  2271. Revision 1.40 1998/08/21 15:48:58 pierre
  2272. * more cdecl chagnes
  2273. - better line info
  2274. - changes the definition options of a procvar
  2275. if it is a unnamed type
  2276. Revision 1.39 1998/08/19 00:42:40 peter
  2277. + subrange types for enums
  2278. + checking for bounds type with ranges
  2279. Revision 1.38 1998/08/12 19:20:39 peter
  2280. + public is the same as export for c_vars
  2281. * a exported/public c_var incs now the refcount
  2282. Revision 1.37 1998/08/11 15:31:38 peter
  2283. * write extended to ppu file
  2284. * new version 0.99.7
  2285. Revision 1.36 1998/08/10 14:50:09 peter
  2286. + localswitches, moduleswitches, globalswitches splitting
  2287. Revision 1.35 1998/07/26 21:59:00 florian
  2288. + better support for switch $H
  2289. + index access to ansi strings added
  2290. + assigment of data (records/arrays) containing ansi strings
  2291. Revision 1.34 1998/07/20 22:17:15 florian
  2292. * hex constants in numeric char (#$54#$43 ...) are now allowed
  2293. * there was a bug in record_var_dec which prevents the used
  2294. of nested variant records (for example drivers.tevent of tv)
  2295. Revision 1.33 1998/07/18 17:11:11 florian
  2296. + ansi string constants fixed
  2297. + switch $H partial implemented
  2298. Revision 1.32 1998/07/14 21:46:50 peter
  2299. * updated messages file
  2300. Revision 1.31 1998/07/14 14:46:53 peter
  2301. * released NEWINPUT
  2302. Revision 1.30 1998/07/10 00:00:00 peter
  2303. * fixed ttypesym bug finally
  2304. * fileinfo in the symtable and better using for unused vars
  2305. Revision 1.29 1998/06/25 14:04:21 peter
  2306. + internal inc/dec
  2307. Revision 1.28 1998/06/24 12:26:45 peter
  2308. * stricter var parsing like tp7 and some optimizes with directive
  2309. parsing
  2310. Revision 1.27 1998/06/12 16:15:34 pierre
  2311. * external name 'C_var';
  2312. export name 'intern_C_var';
  2313. cdecl;
  2314. cdecl;external;
  2315. are now supported only with -Sv switch
  2316. Revision 1.25 1998/06/09 16:01:45 pierre
  2317. + added procedure directive parsing for procvars
  2318. (accepted are popstack cdecl and pascal)
  2319. + added C vars with the following syntax
  2320. var C calias 'true_c_name';(can be followed by external)
  2321. reason is that you must add the Cprefix
  2322. which is target dependent
  2323. Revision 1.24 1998/06/05 14:37:32 pierre
  2324. * fixes for inline for operators
  2325. * inline procedure more correctly restricted
  2326. Revision 1.23 1998/06/04 23:51:50 peter
  2327. * m68k compiles
  2328. + .def file creation moved to gendef.pas so it could also be used
  2329. for win32
  2330. Revision 1.22 1998/06/03 22:48:59 peter
  2331. + wordbool,longbool
  2332. * rename bis,von -> high,low
  2333. * moved some systemunit loading/creating to psystem.pas
  2334. Revision 1.21 1998/06/03 22:14:19 florian
  2335. * problem with sizes of classes fixed (if the anchestor was declared
  2336. forward, the compiler doesn't update the child classes size)
  2337. Revision 1.20 1998/05/28 14:35:54 peter
  2338. * nicer error message when no id is used after var
  2339. Revision 1.19 1998/05/23 01:21:19 peter
  2340. + aktasmmode, aktoptprocessor, aktoutputformat
  2341. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  2342. + $LIBNAME to set the library name where the unit will be put in
  2343. * splitted cgi386 a bit (codeseg to large for bp7)
  2344. * nasm, tasm works again. nasm moved to ag386nsm.pas
  2345. Revision 1.18 1998/05/20 09:42:35 pierre
  2346. + UseTokenInfo now default
  2347. * unit in interface uses and implementation uses gives error now
  2348. * only one error for unknown symbol (uses lastsymknown boolean)
  2349. the problem came from the label code !
  2350. + first inlined procedures and function work
  2351. (warning there might be allowed cases were the result is still wrong !!)
  2352. * UseBrower updated gives a global list of all position of all used symbols
  2353. with switch -gb
  2354. Revision 1.17 1998/05/11 13:07:55 peter
  2355. + $ifdef NEWPPU for the new ppuformat
  2356. + $define GDB not longer required
  2357. * removed all warnings and stripped some log comments
  2358. * no findfirst/findnext anymore to remove smartlink *.o files
  2359. Revision 1.16 1998/05/05 12:05:42 florian
  2360. * problems with properties fixed
  2361. * crash fixed: i:=l when i and l are undefined, was a problem with
  2362. implementation of private/protected
  2363. Revision 1.15 1998/05/01 09:01:23 florian
  2364. + correct semantics of private and protected
  2365. * small fix in variable scope:
  2366. a id can be used in a parameter list of a method, even it is used in
  2367. an anchestor class as field id
  2368. Revision 1.14 1998/05/01 07:43:56 florian
  2369. + basics for rtti implemented
  2370. + switch $m (generate rtti for published sections)
  2371. Revision 1.13 1998/04/30 15:59:41 pierre
  2372. * GDB works again better :
  2373. correct type info in one pass
  2374. + UseTokenInfo for better source position
  2375. * fixed one remaining bug in scanner for line counts
  2376. * several little fixes
  2377. Revision 1.12 1998/04/29 10:33:57 pierre
  2378. + added some code for ansistring (not complete nor working yet)
  2379. * corrected operator overloading
  2380. * corrected nasm output
  2381. + started inline procedures
  2382. + added starstarn : use ** for exponentiation (^ gave problems)
  2383. + started UseTokenInfo cond to get accurate positions
  2384. Revision 1.11 1998/04/28 11:45:52 florian
  2385. * make it compilable with TP
  2386. + small COM problems solved to compile classes.pp
  2387. Revision 1.10 1998/04/27 23:10:28 peter
  2388. + new scanner
  2389. * $makelib -> if smartlink
  2390. * small filename fixes pmodule.setfilename
  2391. * moved import from files.pas -> import.pas
  2392. Revision 1.9 1998/04/10 21:36:56 florian
  2393. + some stuff to support method pointers (procedure of object) added
  2394. (declaration, parameter handling)
  2395. Revision 1.8 1998/04/10 15:39:48 florian
  2396. * more fixes to get classes.pas compiled
  2397. Revision 1.7 1998/04/09 23:02:15 florian
  2398. * small problems solved to get remake3 work
  2399. Revision 1.6 1998/04/09 22:16:35 florian
  2400. * problem with previous REGALLOC solved
  2401. * improved property support
  2402. Revision 1.5 1998/04/08 14:59:20 florian
  2403. * problem with new expr_type solved
  2404. Revision 1.4 1998/04/08 10:26:09 florian
  2405. * correct error handling of virtual constructors
  2406. * problem with new type declaration handling fixed
  2407. Revision 1.3 1998/04/07 22:45:05 florian
  2408. * bug0092, bug0115 and bug0121 fixed
  2409. + packed object/class/array
  2410. Revision 1.2 1998/04/05 13:58:35 peter
  2411. * fixed the -Ss bug
  2412. + warning for Virtual constructors
  2413. * helppages updated with -TGO32V1
  2414. }