pdecl.pas 104 KB

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