pdecl.pas 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191
  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. 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,
  44. files,types,hcodegen,verbose,systems
  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. ,i386
  53. {$endif}
  54. {$ifdef m68k}
  55. ,m68k
  56. {$endif}
  57. ;
  58. function read_type(const name : stringid) : pdef;forward;
  59. procedure const_dec;
  60. var
  61. name : stringid;
  62. p : ptree;
  63. def : pdef;
  64. sym : psym;
  65. ps : pconstset;
  66. pd : pbestreal;
  67. {$ifdef USEANSISTRING}
  68. sp : pstring;
  69. {$endif USEANSISTRING}
  70. begin
  71. consume(_CONST);
  72. repeat
  73. name:=pattern;
  74. consume(ID);
  75. case token of
  76. EQUAL:
  77. begin
  78. consume(EQUAL);
  79. p:=comp_expr(true);
  80. do_firstpass(p);
  81. case p^.treetype of
  82. ordconstn:
  83. begin
  84. if is_constintnode(p) then
  85. symtablestack^.insert(new(pconstsym,init(name,constint,p^.value,nil)))
  86. else if is_constcharnode(p) then
  87. symtablestack^.insert(new(pconstsym,init(name,constchar,p^.value,nil)))
  88. else if is_constboolnode(p) then
  89. symtablestack^.insert(new(pconstsym,init(name,constbool,p^.value,nil)))
  90. else if p^.resulttype^.deftype=enumdef then
  91. symtablestack^.insert(new(pconstsym,init(name,constord,p^.value,p^.resulttype)))
  92. else if p^.resulttype^.deftype=pointerdef then
  93. symtablestack^.insert(new(pconstsym,init(name,constord,p^.value,p^.resulttype)))
  94. else internalerror(111);
  95. end;
  96. stringconstn:
  97. {value_str is disposed with p so I need a copy !}
  98. {$ifdef USEANSISTRING} begin
  99. getmem(sp,p^.length+1);
  100. move(p^.value_str^,sp^[1],p^.length);
  101. sp^[0]:=chr(p^.length);
  102. symtablestack^.insert(new(pconstsym,init(name,conststring,longint(sp),nil)));
  103. end;
  104. {$else USEANSISTRING}
  105. symtablestack^.insert(new(pconstsym,init(name,conststring,longint(stringdup(p^.value_str^)),nil)));
  106. {$endif USEANSISTRING}
  107. realconstn : begin
  108. new(pd);
  109. pd^:=p^.value_real;
  110. symtablestack^.insert(new(pconstsym,init(name,constreal,longint(pd),nil)));
  111. end;
  112. setconstn : begin
  113. new(ps);
  114. ps^:=p^.value_set^;
  115. symtablestack^.insert(new(pconstsym,init(name,constset,longint(ps),p^.resulttype)));
  116. end;
  117. else Message(cg_e_illegal_expression);
  118. end;
  119. consume(SEMICOLON);
  120. end;
  121. COLON:
  122. begin
  123. { this was missed, so const s : ^string = nil gives an
  124. error (FK)
  125. }
  126. block_type:=bt_type;
  127. consume(COLON);
  128. ignore_equal:=true;
  129. def:=read_type('');
  130. block_type:=bt_general;
  131. ignore_equal:=false;
  132. sym:=new(ptypedconstsym,init(name,def));
  133. symtablestack^.insert(sym);
  134. consume(EQUAL);
  135. readtypedconst(def,ptypedconstsym(sym));
  136. consume(SEMICOLON);
  137. end;
  138. else consume(EQUAL);
  139. end;
  140. until token<>ID;
  141. end;
  142. procedure label_dec;
  143. var
  144. hl : plabel;
  145. begin
  146. consume(_LABEL);
  147. if not(cs_support_goto in aktmoduleswitches) then
  148. Message(sym_e_goto_and_label_not_supported);
  149. repeat
  150. if not(token in [ID,INTCONST]) then
  151. consume(ID)
  152. else
  153. begin
  154. getlabel(hl);
  155. symtablestack^.insert(new(plabelsym,init(pattern,hl)));
  156. consume(token);
  157. end;
  158. if token<>SEMICOLON then consume(COMMA);
  159. until not(token in [ID,INTCONST]);
  160. consume(SEMICOLON);
  161. end;
  162. procedure read_var_decs(is_record,is_object:boolean);
  163. { reads the filed of a record into a }
  164. { symtablestack, if record=false }
  165. { variants are forbidden, so this procedure }
  166. { can be used to read object fields }
  167. { if absolute is true, ABSOLUTE and file }
  168. { types are allowed }
  169. { => the procedure is also used to read }
  170. { a sequence of variable declaration }
  171. var
  172. sc : pstringcontainer;
  173. s : stringid;
  174. old_block_type : tblock_type;
  175. filepos : tfileposinfo;
  176. symdone : boolean;
  177. { to handle absolute }
  178. abssym : pabsolutesym;
  179. {$ifdef i386}
  180. l : longint;
  181. code : word;
  182. {$endif i386}
  183. { c var }
  184. Csym : pvarsym;
  185. newtype : ptypesym;
  186. is_gpc_name,is_cdecl,extern_Csym,export_Csym : boolean;
  187. C_name : string;
  188. { case }
  189. p,casedef : pdef;
  190. { maxsize contains the max. size of a variant }
  191. { startvarrec contains the start of the variant part of a record }
  192. maxsize,startvarrec : longint;
  193. pt : ptree;
  194. begin
  195. old_block_type:=block_type;
  196. block_type:=bt_type;
  197. is_gpc_name:=false;
  198. { Force an expected ID error message }
  199. if not (token in [ID,_CASE,_END]) then
  200. consume(ID);
  201. { read vars }
  202. while (token=ID) and
  203. not(is_object and
  204. ((pattern='PUBLIC') or (pattern='PRIVATE') or
  205. (pattern='PUBLISHED') or (pattern='PROTECTED'))) do
  206. begin
  207. C_name:=orgpattern;
  208. sc:=idlist;
  209. consume(COLON);
  210. if (cs_gpc_compatible in aktmoduleswitches) and
  211. not(is_record or is_object) and
  212. (token=ID) and (orgpattern='__asmname__') then
  213. begin
  214. consume(ID);
  215. C_name:=get_stringconst;
  216. Is_gpc_name:=true;
  217. end;
  218. p:=read_type('');
  219. symdone:=false;
  220. if is_gpc_name then
  221. begin
  222. s:=sc^.get_with_tokeninfo(filepos);
  223. if not sc^.empty then
  224. Message(parser_e_absolute_only_one_var);
  225. dispose(sc,done);
  226. Csym:=new(pvarsym,init_C(s,target_os.Cprefix+C_name,p));
  227. Csym^.fileinfo:=filepos;
  228. Csym^.var_options:=Csym^.var_options or vo_is_external;
  229. externals^.concat(new(pai_external,init(Csym^.mangledname,EXT_NEAR)));
  230. symtablestack^.insert(Csym);
  231. symdone:=true;
  232. end;
  233. { check for absolute }
  234. if not symdone and (token=ID) and
  235. (pattern='ABSOLUTE') and not(is_record or is_object) then
  236. begin
  237. consume(ID);
  238. { only allowed for one var }
  239. s:=sc^.get_with_tokeninfo(filepos);
  240. if not sc^.empty then
  241. Message(parser_e_absolute_only_one_var);
  242. dispose(sc,done);
  243. { parse the rest }
  244. if token=ID then
  245. begin
  246. getsym(pattern,true);
  247. consume(ID);
  248. { we should check the result type of srsym }
  249. if not (srsym^.typ in [varsym,typedconstsym]) then
  250. Message(parser_e_absolute_only_to_var_or_const);
  251. abssym:=new(pabsolutesym,init(s,p));
  252. abssym^.typ:=absolutesym;
  253. abssym^.abstyp:=tovar;
  254. abssym^.ref:=srsym;
  255. abssym^.fileinfo:=filepos;
  256. symtablestack^.insert(abssym);
  257. end
  258. else
  259. if token=CSTRING then
  260. begin
  261. abssym:=new(pabsolutesym,init(s,p));
  262. s:=pattern;
  263. consume(CSTRING);
  264. abssym^.typ:=absolutesym;
  265. abssym^.abstyp:=toasm;
  266. abssym^.asmname:=stringdup(s);
  267. abssym^.fileinfo:=filepos;
  268. symtablestack^.insert(abssym);
  269. end
  270. else
  271. { absolute address ?!? }
  272. if token=INTCONST then
  273. begin
  274. {$ifdef i386}
  275. if (target_info.target=target_GO32V2) then
  276. begin
  277. abssym:=new(pabsolutesym,init(s,p));
  278. abssym^.typ:=absolutesym;
  279. abssym^.abstyp:=toaddr;
  280. abssym^.absseg:=false;
  281. abssym^.fileinfo:=filepos;
  282. s:=pattern;
  283. consume(INTCONST);
  284. val(s,abssym^.address,code);
  285. if token=COLON then
  286. begin
  287. consume(token);
  288. s:=pattern;
  289. consume(INTCONST);
  290. val(s,l,code);
  291. abssym^.address:=abssym^.address shl 4+l;
  292. abssym^.absseg:=true;
  293. end;
  294. symtablestack^.insert(abssym);
  295. end
  296. else
  297. {$endif i386}
  298. Message(parser_e_absolute_only_to_var_or_const);
  299. end
  300. else
  301. Message(parser_e_absolute_only_to_var_or_const);
  302. symdone:=true;
  303. end;
  304. { for a record there doesn't need to be a ; before the END or ) }
  305. if not((is_record or is_object) and (token in [_END,RKLAMMER])) then
  306. consume(SEMICOLON);
  307. if (p^.deftype=procvardef) and (p^.sym=nil) then
  308. begin
  309. newtype:=new(ptypesym,init('unnamed',p));
  310. parse_var_proc_directives(newtype);
  311. newtype^.definition:=nil;
  312. p^.sym:=nil;
  313. dispose(newtype,done);
  314. end;
  315. { Check for variable directives }
  316. if not symdone and (token=ID) then
  317. begin
  318. { Check for C Variable declarations }
  319. if (cs_support_c_var in aktmoduleswitches) and
  320. not(is_record or is_object) and
  321. ((pattern='EXPORT') or
  322. (pattern='EXTERNAL') or
  323. (pattern='PUBLIC') or
  324. (pattern='CVAR')) then
  325. begin
  326. { only allowed for one var }
  327. s:=sc^.get_with_tokeninfo(filepos);
  328. if not sc^.empty then
  329. Message(parser_e_absolute_only_one_var);
  330. dispose(sc,done);
  331. { defaults }
  332. is_cdecl:=false;
  333. extern_csym:=false;
  334. export_Csym:=false;
  335. { cdecl }
  336. if pattern='CVAR' then
  337. begin
  338. consume(ID);
  339. consume(SEMICOLON);
  340. is_cdecl:=true;
  341. C_name:=target_os.Cprefix+C_name;
  342. end;
  343. { external }
  344. if pattern='EXTERNAL' then
  345. begin
  346. consume(ID);
  347. extern_csym:=true;
  348. end;
  349. { export }
  350. if (pattern='EXPORT') or (pattern='PUBLIC') then
  351. begin
  352. consume(ID);
  353. if extern_csym then
  354. Message(parser_e_not_external_and_export)
  355. else
  356. export_Csym:=true;
  357. end;
  358. { external and export need a name after when no cdecl is used }
  359. if not is_cdecl then
  360. begin
  361. if (token=ID) and (pattern='NAME') then
  362. consume(ID)
  363. else
  364. Message(parser_e_name_keyword_expected);
  365. C_name:=pattern;
  366. { allow also char }
  367. if token=CCHAR then
  368. consume(CCHAR)
  369. else
  370. consume(CSTRING);
  371. end;
  372. { consume the ; when export or external is used }
  373. if extern_csym or export_csym then
  374. consume(SEMICOLON);
  375. { insert in the symtable }
  376. Csym:=new(pvarsym,init_C(s,C_name,p));
  377. Csym^.fileinfo:=filepos;
  378. if export_Csym then
  379. inc(Csym^.refs);
  380. if extern_Csym then
  381. begin
  382. Csym^.var_options:=Csym^.var_options or vo_is_external;
  383. { correct type ?? }
  384. externals^.concat(new(pai_external,init(Csym^.mangledname,EXT_NEAR)));
  385. end;
  386. symtablestack^.insert(Csym);
  387. symdone:=true;
  388. end
  389. else
  390. if (is_object) and (cs_static_keyword in aktglobalswitches) and (pattern='STATIC') then
  391. begin
  392. current_object_option:=current_object_option or sp_static;
  393. insert_syms(symtablestack,sc,p);
  394. current_object_option:=current_object_option - sp_static;
  395. consume(ID);
  396. consume(SEMICOLON);
  397. symdone:=true;
  398. end;
  399. end;
  400. { insert it in the symtable, if not done yet }
  401. if not symdone then
  402. insert_syms(symtablestack,sc,p);
  403. end;
  404. { Check for Case }
  405. if is_record and (token=_CASE) then
  406. begin
  407. maxsize:=0;
  408. consume(_CASE);
  409. s:=pattern;
  410. getsym(s,false);
  411. { may be only a type: }
  412. if assigned(srsym) and (srsym^.typ in [typesym,unitsym]) then
  413. casedef:=read_type('')
  414. else
  415. begin
  416. consume(ID);
  417. consume(COLON);
  418. casedef:=read_type('');
  419. symtablestack^.insert(new(pvarsym,init(s,casedef)));
  420. end;
  421. if not is_ordinal(casedef) then
  422. Message(type_e_ordinal_expr_expected);
  423. consume(_OF);
  424. startvarrec:=symtablestack^.datasize;
  425. repeat
  426. repeat
  427. pt:=comp_expr(true);
  428. do_firstpass(pt);
  429. if not(pt^.treetype=ordconstn) then
  430. Message(cg_e_illegal_expression);
  431. disposetree(pt);
  432. if token=COMMA then
  433. consume(COMMA)
  434. else
  435. break;
  436. until false;
  437. consume(COLON);
  438. { read the vars }
  439. consume(LKLAMMER);
  440. if token<>RKLAMMER then
  441. read_var_decs(true,false);
  442. consume(RKLAMMER);
  443. { calculates maximal variant size }
  444. maxsize:=max(maxsize,symtablestack^.datasize);
  445. { the items of the next variant are overlayed }
  446. symtablestack^.datasize:=startvarrec;
  447. if (token<>_END) and (token<>RKLAMMER) then
  448. consume(SEMICOLON)
  449. else
  450. break;
  451. until (token=_END) or (token=RKLAMMER);
  452. { at last set the record size to that of the biggest variant }
  453. symtablestack^.datasize:=maxsize;
  454. end;
  455. block_type:=old_block_type;
  456. end;
  457. function stringtype : pdef;
  458. { reads a string type with optional length }
  459. { and returns a pointer to the string }
  460. { definition }
  461. var
  462. p : ptree;
  463. d : pdef;
  464. begin
  465. consume(_STRING);
  466. if token=LECKKLAMMER then
  467. begin
  468. consume(LECKKLAMMER);
  469. p:=comp_expr(true);
  470. do_firstpass(p);
  471. if not is_constintnode(p) then
  472. Message(cg_e_illegal_expression);
  473. {$ifndef UseAnsiString}
  474. if (p^.value<1) or (p^.value>255) then
  475. begin
  476. Message(parser_e_string_too_long);
  477. p^.value:=255;
  478. end;
  479. consume(RECKKLAMMER);
  480. if p^.value<>255 then
  481. d:=new(pstringdef,init(p^.value))
  482. {$ifndef GDB}
  483. else d:=new(pstringdef,init(255));
  484. {$else GDB}
  485. else d:=globaldef('STRING');
  486. {$endif GDB}
  487. {$else UseAnsiString}
  488. if p^.value>255 then
  489. d:=new(pstringdef,ansiinit(p^.value))
  490. else if p^.value<>255 then
  491. d:=new(pstringdef,init(p^.value))
  492. {$ifndef GDB}
  493. else d:=new(pstringdef,init(255));
  494. {$else GDB}
  495. else d:=globaldef('STRING');
  496. {$endif GDB}
  497. consume(RECKKLAMMER);
  498. {$endif UseAnsiString}
  499. disposetree(p);
  500. end
  501. { should string without suffix be an ansistring also
  502. in ansistring mode ?? (PM) Yes!!! (FK) }
  503. else
  504. begin
  505. if cs_ansistrings in aktlocalswitches then
  506. d:=new(pstringdef,ansiinit(0))
  507. else
  508. {$ifndef GDB}
  509. d:=new(pstringdef,init(255));
  510. {$else GDB}
  511. d:=globaldef('STRING');
  512. {$endif GDB}
  513. end;
  514. stringtype:=d;
  515. end;
  516. function id_type(var s : string) : pdef;
  517. { reads a type definition and returns a pointer }
  518. { to a appropriating pdef, s gets the name of }
  519. { the type to allow name mangling }
  520. begin
  521. s:=pattern;
  522. consume(ID);
  523. { classes can be used also in classes }
  524. if (curobjectname=pattern) and aktobjectdef^.isclass then
  525. begin
  526. id_type:=aktobjectdef;
  527. exit;
  528. end;
  529. { objects can be parameters }
  530. if (testcurobject=2) and (curobjectname=pattern) then
  531. begin
  532. id_type:=aktobjectdef;
  533. exit;
  534. end;
  535. getsym(s,true);
  536. if assigned(srsym) then
  537. begin
  538. if srsym^.typ=unitsym then
  539. begin
  540. consume(POINT);
  541. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  542. s:=pattern;
  543. consume(ID);
  544. end;
  545. if srsym^.typ<>typesym then
  546. begin
  547. Message(type_e_type_id_expected);
  548. lasttypesym:=ptypesym(srsym);
  549. id_type:=generrordef;
  550. exit;
  551. end;
  552. end;
  553. lasttypesym:=ptypesym(srsym);
  554. id_type:=ptypesym(srsym)^.definition;
  555. end;
  556. function single_type(var s : string) : pdef;
  557. { reads a string, file type or a type id and returns a name and }
  558. { pdef }
  559. var
  560. hs : string;
  561. begin
  562. case token of
  563. _STRING:
  564. begin
  565. single_type:=stringtype;
  566. s:='STRING';
  567. lasttypesym:=nil;
  568. end;
  569. _FILE:
  570. begin
  571. consume(_FILE);
  572. if token=_OF then
  573. begin
  574. consume(_OF);
  575. single_type:=new(pfiledef,init(ft_typed,single_type(hs)));
  576. s:='FILE$OF$'+hs;
  577. end
  578. else
  579. begin
  580. { single_type:=new(pfiledef,init(ft_untyped,nil));}
  581. single_type:=cfiledef;
  582. s:='FILE';
  583. end;
  584. lasttypesym:=nil;
  585. end;
  586. else single_type:=id_type(s);
  587. end;
  588. end;
  589. function object_dec(const n : stringid;fd : pobjectdef) : pdef;
  590. { this function parses an object or class declaration }
  591. var
  592. actmembertype : symprop;
  593. there_is_a_destructor : boolean;
  594. is_a_class : boolean;
  595. childof : pobjectdef;
  596. aktclass : pobjectdef;
  597. procedure constructor_head;
  598. begin
  599. consume(_CONSTRUCTOR);
  600. { must be at same level as in implementation }
  601. _proc_head(poconstructor);
  602. if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'INIT') then
  603. Message(parser_e_constructorname_must_be_init);
  604. consume(SEMICOLON);
  605. begin
  606. if (aktclass^.options and oois_class)<>0 then
  607. begin
  608. { CLASS constructors return the created instance }
  609. aktprocsym^.definition^.retdef:=aktclass;
  610. end
  611. else
  612. begin
  613. { OBJECT constructors return a boolean }
  614. {$IfDef GDB}
  615. {GDB doesn't like unnamed types !}
  616. aktprocsym^.definition^.retdef:=
  617. globaldef('boolean');
  618. {$Else GDB}
  619. aktprocsym^.definition^.retdef:=
  620. new(porddef,init(bool8bit,0,1));
  621. {$Endif GDB}
  622. end;
  623. end;
  624. end;
  625. procedure property_dec;
  626. var
  627. sym : psym;
  628. propertyparas : pdefcoll;
  629. { returns the matching procedure to access a property }
  630. function get_procdef : pprocdef;
  631. var
  632. p : pprocdef;
  633. begin
  634. p:=pprocsym(sym)^.definition;
  635. get_procdef:=nil;
  636. while assigned(p) do
  637. begin
  638. if equal_paras(p^.para1,propertyparas,true) then
  639. break;
  640. p:=p^.nextoverloaded;
  641. end;
  642. get_procdef:=p;
  643. end;
  644. var
  645. hp2,datacoll : pdefcoll;
  646. p,p2 : ppropertysym;
  647. overriden : psym;
  648. hs : string;
  649. code : word;
  650. varspez : tvarspez;
  651. sc : pstringcontainer;
  652. hp : pdef;
  653. s : string;
  654. filepos : tfileposinfo;
  655. pp : pprocdef;
  656. begin
  657. { check for a class }
  658. if (aktclass^.options and oois_class=0) then
  659. Message(parser_e_syntax_error);
  660. consume(_PROPERTY);
  661. if token=ID then
  662. begin
  663. p:=new(ppropertysym,init(pattern));
  664. consume(ID);
  665. propertyparas:=nil;
  666. datacoll:=nil;
  667. { property parameters ? }
  668. if token=LECKKLAMMER then
  669. begin
  670. { create a list of the parameters in propertyparas }
  671. consume(LECKKLAMMER);
  672. inc(testcurobject);
  673. repeat
  674. if token=_VAR then
  675. begin
  676. consume(_VAR);
  677. varspez:=vs_var;
  678. end
  679. else if token=_CONST then
  680. begin
  681. consume(_CONST);
  682. varspez:=vs_const;
  683. end
  684. else varspez:=vs_value;
  685. sc:=idlist;
  686. if token=COLON then
  687. begin
  688. consume(COLON);
  689. if token=_ARRAY then
  690. begin
  691. {
  692. if (varspez<>vs_const) and
  693. (varspez<>vs_var) then
  694. begin
  695. varspez:=vs_const;
  696. Message(parser_e_illegal_open_parameter);
  697. end;
  698. }
  699. consume(_ARRAY);
  700. consume(_OF);
  701. { define range and type of range }
  702. hp:=new(parraydef,init(0,-1,s32bitdef));
  703. { define field type }
  704. parraydef(hp)^.definition:=single_type(s);
  705. end
  706. else
  707. hp:=single_type(s);
  708. end
  709. else
  710. hp:=new(pformaldef,init);
  711. s:=sc^.get_with_tokeninfo(filepos);
  712. while s<>'' do
  713. begin
  714. new(hp2);
  715. hp2^.paratyp:=varspez;
  716. hp2^.data:=hp;
  717. hp2^.next:=propertyparas;
  718. propertyparas:=hp2;
  719. s:=sc^.get_with_tokeninfo(filepos);
  720. end;
  721. dispose(sc,done);
  722. if token=SEMICOLON then consume(SEMICOLON)
  723. else break;
  724. until false;
  725. dec(testcurobject);
  726. consume(RECKKLAMMER);
  727. end;
  728. { overriden property ? }
  729. { force property interface, if there is a property parameter }
  730. if (token=COLON) or assigned(propertyparas) then
  731. begin
  732. consume(COLON);
  733. p^.proptype:=single_type(hs);
  734. if (token=ID) and (pattern='INDEX') then
  735. begin
  736. consume(ID);
  737. p^.options:=p^.options or ppo_indexed;
  738. if token=INTCONST then
  739. val(pattern,p^.index,code);
  740. consume(INTCONST);
  741. { concat a longint to the para template }
  742. new(hp2);
  743. hp2^.paratyp:=vs_value;
  744. hp2^.data:=s32bitdef;
  745. hp2^.next:=propertyparas;
  746. propertyparas:=hp2;
  747. end;
  748. end
  749. else
  750. begin
  751. { do an property override }
  752. overriden:=search_class_member(aktclass,pattern);
  753. if assigned(overriden) and (overriden^.typ=propertysym) then
  754. begin
  755. { take the whole info: }
  756. p^.options:=ppropertysym(overriden)^.options;
  757. p^.index:=ppropertysym(overriden)^.index;
  758. p^.proptype:=ppropertysym(overriden)^.proptype;
  759. p^.writeaccesssym:=ppropertysym(overriden)^.writeaccesssym;
  760. p^.readaccesssym:=ppropertysym(overriden)^.readaccesssym;
  761. p^.writeaccessdef:=ppropertysym(overriden)^.writeaccessdef;
  762. p^.readaccessdef:=ppropertysym(overriden)^.readaccessdef;
  763. end
  764. else
  765. begin
  766. p^.proptype:=generrordef;
  767. message(parser_e_no_property_found_to_override);
  768. end;
  769. end;
  770. { create data defcoll to allow correct parameter checks }
  771. new(datacoll);
  772. datacoll^.paratyp:=vs_value;
  773. datacoll^.data:=p^.proptype;
  774. datacoll^.next:=nil;
  775. if (token=ID) and (pattern='READ') then
  776. begin
  777. consume(ID);
  778. sym:=search_class_member(aktclass,pattern);
  779. if not(assigned(sym)) then
  780. Message1(sym_e_unknown_id,pattern)
  781. else
  782. begin
  783. { varsym aren't allowed for an indexed property
  784. or an property with parameters }
  785. if ((sym^.typ=varsym) and
  786. { not necessary, an index forces propertyparas
  787. to be assigned
  788. }
  789. { (((p^.options and ppo_indexed)<>0) or }
  790. assigned(propertyparas)) or
  791. not(sym^.typ in [varsym,procsym]) then
  792. Message(parser_e_ill_property_access_sym);
  793. { search the matching definition }
  794. if sym^.typ=procsym then
  795. begin
  796. pp:=get_procdef;
  797. if not(assigned(pp)) or
  798. not(is_equal(pp^.retdef,p^.proptype)) then
  799. Message(parser_e_ill_property_access_sym);
  800. p^.readaccessdef:=pp;
  801. end
  802. else if sym^.typ=varsym then
  803. begin
  804. if not(is_equal(pvarsym(sym)^.definition,
  805. p^.proptype)) then
  806. Message(parser_e_ill_property_access_sym);
  807. end;
  808. p^.readaccesssym:=sym;
  809. end;
  810. consume(ID);
  811. end;
  812. if (token=ID) and (pattern='WRITE') then
  813. begin
  814. consume(ID);
  815. sym:=search_class_member(aktclass,pattern);
  816. if not(assigned(sym)) then
  817. Message1(sym_e_unknown_id,pattern)
  818. else
  819. begin
  820. if ((sym^.typ=varsym) and
  821. assigned(propertyparas)) or
  822. not(sym^.typ in [varsym,procsym]) then
  823. Message(parser_e_ill_property_access_sym);
  824. { search the matching definition }
  825. if sym^.typ=procsym then
  826. begin
  827. { insert data entry to check access method }
  828. datacoll^.next:=propertyparas;
  829. propertyparas:=datacoll;
  830. pp:=get_procdef;
  831. { ... and remove it }
  832. propertyparas:=propertyparas^.next;
  833. if not(assigned(pp)) then
  834. Message(parser_e_ill_property_access_sym);
  835. p^.writeaccessdef:=pp;
  836. end
  837. else if sym^.typ=varsym then
  838. begin
  839. if not(is_equal(pvarsym(sym)^.definition,
  840. p^.proptype)) then
  841. Message(parser_e_ill_property_access_sym);
  842. end;
  843. p^.writeaccesssym:=sym;
  844. end;
  845. consume(ID);
  846. end;
  847. if (token=ID) and (pattern='STORED') then
  848. begin
  849. consume(ID);
  850. { !!!!!!!! }
  851. end;
  852. if (token=ID) and (pattern='DEFAULT') then
  853. begin
  854. consume(ID);
  855. { !!!!!!! storage }
  856. consume(SEMICOLON);
  857. end
  858. else if (token=ID) and (pattern='NODEFAULT') then
  859. begin
  860. consume(ID);
  861. { !!!!!!!! }
  862. end;
  863. symtablestack^.insert(p);
  864. { default property ? }
  865. consume(SEMICOLON);
  866. if (token=ID) and (pattern='DEFAULT') then
  867. begin
  868. consume(ID);
  869. p2:=search_default_property(aktclass);
  870. if assigned(p2) then
  871. message1(parser_e_only_one_default_property,
  872. pobjectdef(p2^.owner^.defowner)^.name^)
  873. else
  874. begin
  875. p^.options:=p^.options or ppo_defaultproperty;
  876. if not(assigned(propertyparas)) then
  877. message(parser_e_property_need_paras);
  878. end;
  879. consume(SEMICOLON);
  880. end;
  881. { clean up }
  882. if assigned(datacoll) then
  883. dispose(datacoll);
  884. end
  885. else
  886. begin
  887. consume(ID);
  888. consume(SEMICOLON);
  889. end;
  890. end;
  891. procedure destructor_head;
  892. begin
  893. consume(_DESTRUCTOR);
  894. _proc_head(podestructor);
  895. if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'DONE') then
  896. Message(parser_e_destructorname_must_be_done);
  897. consume(SEMICOLON);
  898. if assigned(aktprocsym^.definition^.para1) then
  899. Message(parser_e_no_paras_for_destructor);
  900. { no return value }
  901. aktprocsym^.definition^.retdef:=voiddef;
  902. end;
  903. var
  904. hs : string;
  905. pcrd : pclassrefdef;
  906. hp1 : pdef;
  907. oldprocsym : Pprocsym;
  908. oldparse_only : boolean;
  909. classnamelabel : plabel;
  910. begin
  911. {Nowadays aktprocsym may already have a value, so we need to save
  912. it.}
  913. oldprocsym:=aktprocsym;
  914. { forward is resolved }
  915. if assigned(fd) then
  916. fd^.options:=fd^.options and not(oo_isforward);
  917. there_is_a_destructor:=false;
  918. actmembertype:=sp_public;
  919. { objects and class types can't be declared local }
  920. if (symtablestack^.symtabletype<>globalsymtable) and
  921. (symtablestack^.symtabletype<>staticsymtable) then
  922. Message(parser_e_no_local_objects);
  923. { distinguish classes and objects }
  924. if token=_OBJECT then
  925. begin
  926. is_a_class:=false;
  927. consume(_OBJECT)
  928. end
  929. else
  930. begin
  931. is_a_class:=true;
  932. consume(_CLASS);
  933. if not(assigned(fd)) and (token=_OF) then
  934. begin
  935. { a hack, but it's easy to handle }
  936. { class reference type }
  937. consume(_OF);
  938. if typecanbeforward then
  939. forwardsallowed:=true;
  940. hp1:=single_type(hs);
  941. { accept hp1, if is a forward def ...}
  942. if ((lasttypesym<>nil)
  943. and ((lasttypesym^.properties and sp_forwarddef)<>0)) or
  944. { or a class
  945. (if the foward defined type is a class is checked, when
  946. the forward is resolved)
  947. }
  948. ((hp1^.deftype=objectdef) and (
  949. (pobjectdef(hp1)^.options and oois_class)<>0)) then
  950. begin
  951. pcrd:=new(pclassrefdef,init(hp1));
  952. object_dec:=pcrd;
  953. {I add big troubles here
  954. with var p : ^byte in graph.putimage
  955. because a save_forward was called and
  956. no resolve forward
  957. => so the definition was rewritten after
  958. having been disposed !!
  959. Strange problems appeared !!!!}
  960. {Anyhow forwards should only be allowed
  961. inside a type statement ??
  962. don't you think so }
  963. if (lasttypesym<>nil)
  964. and ((lasttypesym^.properties and sp_forwarddef)<>0) then
  965. lasttypesym^.forwardpointer:=ppointerdef(pcrd);
  966. forwardsallowed:=false;
  967. end
  968. else
  969. begin
  970. Message(type_e_class_type_expected);
  971. object_dec:=new(perrordef,init);
  972. end;
  973. exit;
  974. end
  975. { forward class }
  976. else if not(assigned(fd)) and (token=SEMICOLON) then
  977. begin
  978. { also anonym objects aren't allow (o : object a : longint; end;) }
  979. if n='' then
  980. Message(parser_e_no_anonym_objects);
  981. if n='TOBJECT' then
  982. begin
  983. aktclass:=new(pobjectdef,init(n,nil));
  984. class_tobject:=aktclass;
  985. end
  986. else
  987. aktclass:=new(pobjectdef,init(n,class_tobject));
  988. aktclass^.options:=aktclass^.options or oois_class or oo_isforward;
  989. object_dec:=aktclass;
  990. exit;
  991. end;
  992. end;
  993. { also anonym objects aren't allow (o : object a : longint; end;) }
  994. if n='' then
  995. Message(parser_e_no_anonym_objects);
  996. { read the parent class }
  997. if token=LKLAMMER then
  998. begin
  999. consume(LKLAMMER);
  1000. { does not allow objects.tobject !! }
  1001. {if token<>ID then
  1002. consume(ID);
  1003. getsym(pattern,true);}
  1004. childof:=pobjectdef(id_type(pattern));
  1005. if (childof^.deftype<>objectdef) then
  1006. begin
  1007. Message(type_e_class_type_expected);
  1008. childof:=nil;
  1009. end;
  1010. { a mix of class and object isn't allowed }
  1011. if (((childof^.options and oois_class)<>0) and not is_a_class) or
  1012. (((childof^.options and oois_class)=0) and is_a_class) then
  1013. Message(parser_e_mix_of_classes_and_objects);
  1014. if assigned(fd) then
  1015. begin
  1016. { the forward of the child must be resolved to get
  1017. correct field addresses
  1018. }
  1019. if (childof^.options and oo_isforward)<>0 then
  1020. Message1(parser_e_forward_declaration_must_be_resolved,childof^.name^);
  1021. fd^.childof:=childof;
  1022. aktclass:=fd;
  1023. { ajust the size, because the child could be also
  1024. forward defined
  1025. }
  1026. aktclass^.publicsyms^.datasize:=
  1027. aktclass^.publicsyms^.datasize-4+childof^.publicsyms^.datasize;
  1028. end
  1029. else
  1030. aktclass:=new(pobjectdef,init(n,childof));
  1031. consume(RKLAMMER);
  1032. end
  1033. { if no parent class, then a class get tobject as parent }
  1034. else if is_a_class then
  1035. begin
  1036. { is the current class tobject? }
  1037. { so you could define your own tobject }
  1038. if n='TOBJECT' then
  1039. begin
  1040. if assigned(fd) then
  1041. aktclass:=fd
  1042. else
  1043. aktclass:=new(pobjectdef,init(n,nil));
  1044. class_tobject:=aktclass;
  1045. end
  1046. else
  1047. begin
  1048. childof:=class_tobject;
  1049. if assigned(fd) then
  1050. begin
  1051. { the forward of the child must be resolved to get
  1052. correct field addresses
  1053. }
  1054. if (childof^.options and oo_isforward)<>0 then
  1055. Message1(parser_e_forward_declaration_must_be_resolved,childof^.name^);
  1056. aktclass:=fd;
  1057. aktclass^.childof:=childof;
  1058. { ajust the size, because the child could be also
  1059. forward defined
  1060. }
  1061. aktclass^.publicsyms^.datasize:=
  1062. aktclass^.publicsyms^.datasize-4+childof^.publicsyms^.datasize;
  1063. end
  1064. else
  1065. aktclass:=new(pobjectdef,init(n,childof));
  1066. end;
  1067. end
  1068. else aktclass:=new(pobjectdef,init(n,nil));
  1069. { set the class attribute }
  1070. if is_a_class then
  1071. begin
  1072. aktclass^.options:=aktclass^.options or oois_class;
  1073. if (cs_generate_rtti in aktlocalswitches) or
  1074. (assigned(aktclass^.childof) and
  1075. ((aktclass^.childof^.options and oo_can_have_published)<>0)
  1076. ) then
  1077. aktclass^.options:=aktclass^.options or oo_can_have_published;
  1078. end;
  1079. aktobjectdef:=aktclass;
  1080. { default access is public }
  1081. actmembertype:=sp_public;
  1082. aktclass^.publicsyms^.next:=symtablestack;
  1083. symtablestack:=aktclass^.publicsyms;
  1084. procinfo._class:=aktclass;
  1085. testcurobject:=1;
  1086. curobjectname:=n;
  1087. { short class declaration ? }
  1088. if (not is_a_class) or (token<>SEMICOLON) then
  1089. begin
  1090. { Parse componenten }
  1091. repeat
  1092. if actmembertype=sp_private then
  1093. aktclass^.options:=aktclass^.options or oo_hasprivate;
  1094. if actmembertype=sp_protected then
  1095. aktclass^.options:=aktclass^.options or oo_hasprotected;
  1096. case token of
  1097. ID : begin
  1098. if (pattern='PRIVATE') then
  1099. begin
  1100. consume(ID);
  1101. actmembertype:=sp_private;
  1102. current_object_option:=sp_private;
  1103. end
  1104. else
  1105. if (pattern='PROTECTED') then
  1106. begin
  1107. consume(ID);
  1108. current_object_option:=sp_protected;
  1109. actmembertype:=sp_protected;
  1110. end
  1111. else
  1112. if (pattern='PUBLIC') then
  1113. begin
  1114. consume(ID);
  1115. current_object_option:=sp_public;
  1116. actmembertype:=sp_public;
  1117. end
  1118. else
  1119. if (pattern='PUBLISHED') then
  1120. begin
  1121. if (aktclass^.options and oo_can_have_published)=0 then
  1122. Message(parser_e_cant_have_published);
  1123. consume(ID);
  1124. current_object_option:=sp_published;
  1125. actmembertype:=sp_published;
  1126. end
  1127. else
  1128. read_var_decs(false,true);
  1129. end;
  1130. _PROPERTY : property_dec;
  1131. _PROCEDURE,
  1132. _FUNCTION,
  1133. _CLASS : begin
  1134. oldparse_only:=parse_only;
  1135. parse_only:=true;
  1136. proc_head;
  1137. parse_only:=oldparse_only;
  1138. if (token=ID) then
  1139. begin
  1140. if (pattern='VIRTUAL') or (pattern='DYNAMIC') then
  1141. begin
  1142. if actmembertype=sp_private then
  1143. Message(parser_w_priv_meth_not_virtual);
  1144. consume(ID);
  1145. consume(SEMICOLON);
  1146. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
  1147. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1148. end
  1149. else
  1150. if (pattern='OVERRIDE') then
  1151. begin
  1152. consume(ID);
  1153. consume(SEMICOLON);
  1154. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
  1155. pooverridingmethod or povirtualmethod;
  1156. end;
  1157. { Delphi II extension }
  1158. if (pattern='ABSTRACT') then
  1159. begin
  1160. consume(ID);
  1161. consume(SEMICOLON);
  1162. if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
  1163. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or poabstractmethod
  1164. else
  1165. Message(parser_e_only_virtual_methods_abstract);
  1166. { the method is defined }
  1167. aktprocsym^.definition^.forwarddef:=false;
  1168. end;
  1169. if (cs_static_keyword in aktglobalswitches) and (pattern='STATIC') then
  1170. begin
  1171. consume(ID);
  1172. consume(SEMICOLON);
  1173. aktprocsym^.properties:=aktprocsym^.properties or sp_static;
  1174. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or postaticmethod;
  1175. end;
  1176. end;
  1177. end;
  1178. _CONSTRUCTOR : begin
  1179. if actmembertype<>sp_public then
  1180. Message(parser_w_constructor_should_be_public);
  1181. oldparse_only:=parse_only;
  1182. parse_only:=true;
  1183. constructor_head;
  1184. parse_only:=oldparse_only;
  1185. if (token=ID) then
  1186. begin
  1187. if (pattern='VIRTUAL') or (pattern='DYNAMIC') then
  1188. begin
  1189. consume(ID);
  1190. consume(SEMICOLON);
  1191. if not(aktclass^.isclass) then
  1192. Message(parser_e_constructor_cannot_be_not_virtual)
  1193. else
  1194. begin
  1195. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
  1196. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1197. end;
  1198. end
  1199. else
  1200. if (pattern='OVERRIDE') then
  1201. begin
  1202. consume(ID);
  1203. consume(SEMICOLON);
  1204. if (aktclass^.options and oois_class=0) then
  1205. Message(parser_e_constructor_cannot_be_not_virtual)
  1206. else
  1207. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
  1208. pooverridingmethod or povirtualmethod;
  1209. end;
  1210. end;
  1211. end;
  1212. _DESTRUCTOR : begin
  1213. if there_is_a_destructor then
  1214. Message(parser_n_only_one_destructor);
  1215. there_is_a_destructor:=true;
  1216. if actmembertype<>sp_public then
  1217. Message(parser_w_destructor_should_be_public);
  1218. oldparse_only:=parse_only;
  1219. parse_only:=true;
  1220. destructor_head;
  1221. parse_only:=oldparse_only;
  1222. if (token=ID) then
  1223. begin
  1224. if (pattern='VIRTUAL') or (pattern='DYNAMIC') then
  1225. begin
  1226. consume(ID);
  1227. consume(SEMICOLON);
  1228. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
  1229. end
  1230. else
  1231. if (pattern='OVERRIDE') then
  1232. begin
  1233. consume(ID);
  1234. consume(SEMICOLON);
  1235. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
  1236. pooverridingmethod or povirtualmethod;
  1237. end;
  1238. end;
  1239. end;
  1240. _END : begin
  1241. consume(_END);
  1242. break;
  1243. end;
  1244. else
  1245. consume(ID); { Give a ident expected message, like tp7 }
  1246. end;
  1247. until false;
  1248. current_object_option:=sp_public;
  1249. end;
  1250. testcurobject:=0;
  1251. curobjectname:='';
  1252. aktclass^.generate_rtti;
  1253. if (cs_smartlink in aktmoduleswitches) then
  1254. datasegment^.concat(new(pai_cut,init));
  1255. { write extended info for classes }
  1256. if is_a_class then
  1257. begin
  1258. { write class name }
  1259. getlabel(classnamelabel);
  1260. datasegment^.concat(new(pai_label,init(classnamelabel)));
  1261. datasegment^.concat(new(pai_const,init_8bit(length(aktclass^.name^))));
  1262. datasegment^.concat(new(pai_string,init(aktclass^.name^)));
  1263. { interface table }
  1264. datasegment^.concat(new(pai_const,init_32bit(0)));
  1265. { auto table }
  1266. datasegment^.concat(new(pai_const,init_32bit(0)));
  1267. { inittable for con-/destruction }
  1268. if aktclass^.needs_inittable then
  1269. datasegment^.concat(new(pai_const,init_symbol(strpnew(lab2str(aktclass^.get_inittable_label)))))
  1270. else
  1271. datasegment^.concat(new(pai_const,init_32bit(0)));
  1272. { pointer to type info of published section }
  1273. datasegment^.concat(new(pai_const,init_symbol(strpnew(aktclass^.rtti_name))));
  1274. { pointer to field table }
  1275. datasegment^.concat(new(pai_const,init_32bit(0)));
  1276. { pointer to method table }
  1277. datasegment^.concat(new(pai_const,init_32bit(0)));
  1278. { pointer to dynamic table }
  1279. datasegment^.concat(new(pai_const,init_32bit(0)));
  1280. { pointer to class name string }
  1281. datasegment^.concat(new(pai_const,init_symbol(strpnew(lab2str(classnamelabel)))));
  1282. end;
  1283. {$ifdef GDB}
  1284. { generate the VMT }
  1285. if cs_debuginfo in aktmoduleswitches then
  1286. begin
  1287. do_count_dbx:=true;
  1288. if assigned(aktclass^.owner) and assigned(aktclass^.owner^.name) then
  1289. datasegment^.concat(new(pai_stabs,init(strpnew('"vmt_'+aktclass^.owner^.name^+n+':S'+
  1290. typeglobalnumber('__vtbl_ptr_type')+'",'+tostr(N_STSYM)+',0,0,'+aktclass^.vmt_mangledname))));
  1291. end;
  1292. {$endif GDB}
  1293. datasegment^.concat(new(pai_symbol,init_global(aktclass^.vmt_mangledname)));
  1294. { determine the size with publicsyms^.datasize, because }
  1295. { size gives back 4 for CLASSes }
  1296. datasegment^.concat(new(pai_const,init_32bit(aktclass^.publicsyms^.datasize)));
  1297. datasegment^.concat(new(pai_const,init_32bit(-aktclass^.publicsyms^.datasize)));
  1298. { write pointer to parent VMT, this isn't implemented in TP }
  1299. { but this is not used in FPC ? (PM) }
  1300. { it's not used yet, but the delphi-operators as and is need it (FK) }
  1301. if assigned(aktclass^.childof) then
  1302. begin
  1303. datasegment^.concat(new(pai_const,init_symbol(strpnew(aktclass^.childof^.vmt_mangledname))));
  1304. if aktclass^.childof^.owner^.symtabletype=unitsymtable then
  1305. concat_external(aktclass^.childof^.vmt_mangledname,EXT_NEAR);
  1306. end
  1307. else
  1308. datasegment^.concat(new(pai_const,init_32bit(0)));
  1309. { this generates the entries }
  1310. genvmt(aktclass);
  1311. { restore old state }
  1312. symtablestack:=symtablestack^.next;
  1313. procinfo._class:=nil;
  1314. {Restore the aktprocsym.}
  1315. aktprocsym:=oldprocsym;
  1316. object_dec:=aktclass;
  1317. end;
  1318. { reads a record declaration }
  1319. function record_dec : pdef;
  1320. var
  1321. symtable : psymtable;
  1322. begin
  1323. symtable:=new(psymtable,init(recordsymtable));
  1324. symtable^.next:=symtablestack;
  1325. symtablestack:=symtable;
  1326. consume(_RECORD);
  1327. read_var_decs(true,false);
  1328. { may be scale record size to a size of n*4 ? }
  1329. if ((symtablestack^.datasize mod aktpackrecords)<>0) then
  1330. inc(symtablestack^.datasize,aktpackrecords-(symtablestack^.datasize mod aktpackrecords));
  1331. consume(_END);
  1332. symtablestack:=symtable^.next;
  1333. record_dec:=new(precdef,init(symtable));
  1334. end;
  1335. { search in symtablestack used, but not defined type }
  1336. procedure testforward_types(p : psym);{$ifndef FPC}far;{$endif}
  1337. begin
  1338. if (p^.typ=typesym) and ((p^.properties and sp_forwarddef)<>0) then
  1339. Message(sym_e_type_id_not_defined);
  1340. end;
  1341. { reads a type definition and returns a pointer to it }
  1342. function read_type(const name : stringid) : pdef;
  1343. function handle_procvar:Pprocvardef;
  1344. var
  1345. sc : pstringcontainer;
  1346. s : string;
  1347. p : pdef;
  1348. varspez : tvarspez;
  1349. procvardef : pprocvardef;
  1350. begin
  1351. procvardef:=new(pprocvardef,init);
  1352. if token=LKLAMMER then
  1353. begin
  1354. consume(LKLAMMER);
  1355. inc(testcurobject);
  1356. repeat
  1357. if token=_VAR then
  1358. begin
  1359. consume(_VAR);
  1360. varspez:=vs_var;
  1361. end
  1362. else if token=_CONST then
  1363. begin
  1364. consume(_CONST);
  1365. varspez:=vs_const;
  1366. end
  1367. else varspez:=vs_value;
  1368. sc:=idlist;
  1369. if token=COLON then
  1370. begin
  1371. consume(COLON);
  1372. if token=_ARRAY then
  1373. begin
  1374. {
  1375. if (varspez<>vs_const) and
  1376. (varspez<>vs_var) then
  1377. begin
  1378. varspez:=vs_const;
  1379. Message(parser_e_illegal_open_parameter);
  1380. end;
  1381. }
  1382. consume(_ARRAY);
  1383. consume(_OF);
  1384. { define range and type of range }
  1385. p:=new(parraydef,init(0,-1,s32bitdef));
  1386. { define field type }
  1387. parraydef(p)^.definition:=single_type(s);
  1388. end
  1389. else
  1390. p:=single_type(s);
  1391. end
  1392. else
  1393. p:=new(pformaldef,init);
  1394. s:=sc^.get;
  1395. while s<>'' do
  1396. begin
  1397. procvardef^.concatdef(p,varspez);
  1398. s:=sc^.get;
  1399. end;
  1400. dispose(sc,done);
  1401. if token=SEMICOLON then consume(SEMICOLON)
  1402. else break;
  1403. until false;
  1404. dec(testcurobject);
  1405. consume(RKLAMMER);
  1406. end;
  1407. handle_procvar:=procvardef;
  1408. end;
  1409. var
  1410. hp1,p : pdef;
  1411. aufdef : penumdef;
  1412. aufsym : penumsym;
  1413. ap : parraydef;
  1414. s : stringid;
  1415. l,v,oldaktpackrecords : longint;
  1416. hs : string;
  1417. procedure expr_type;
  1418. var
  1419. pt1,pt2 : ptree;
  1420. begin
  1421. p:=nil;
  1422. { use of current parsed object ? }
  1423. if (token=ID) and (testcurobject=2) and (curobjectname=pattern) then
  1424. begin
  1425. consume(ID);
  1426. p:=aktobjectdef;
  1427. exit;
  1428. end;
  1429. { we can't accept a equal in type }
  1430. pt1:=comp_expr(not(ignore_equal));
  1431. if (pt1^.treetype=typen) and (token<>POINTPOINT) then
  1432. begin
  1433. { a simple type renaming }
  1434. p:=pt1^.resulttype;
  1435. end
  1436. else
  1437. begin
  1438. { range type }
  1439. consume(POINTPOINT);
  1440. { range type declaration }
  1441. do_firstpass(pt1);
  1442. pt2:=comp_expr(not(ignore_equal));
  1443. do_firstpass(pt2);
  1444. { valid expression ? }
  1445. if (pt1^.treetype<>ordconstn) or (pt2^.treetype<>ordconstn) then
  1446. Message(sym_e_error_in_type_def)
  1447. else
  1448. begin
  1449. { Check bounds }
  1450. if pt2^.value<pt1^.value then
  1451. Message(cg_e_upper_lower_than_lower)
  1452. else
  1453. begin
  1454. { is one an enum ? }
  1455. if (pt1^.resulttype^.deftype=enumdef) or (pt2^.resulttype^.deftype=enumdef) then
  1456. begin
  1457. { both must be the have the same (enumdef) definition, else its a type mismatch }
  1458. if (pt1^.resulttype=pt2^.resulttype) then
  1459. p:=new(penumdef,init_subrange(penumdef(pt1^.resulttype),pt1^.value,pt2^.value))
  1460. else
  1461. Message(type_e_mismatch);
  1462. end
  1463. else
  1464. begin
  1465. { both must be are orddefs, create an uauto orddef }
  1466. p:=new(porddef,init(uauto,pt1^.value,pt2^.value));
  1467. end;
  1468. end;
  1469. end;
  1470. disposetree(pt2);
  1471. end;
  1472. disposetree(pt1);
  1473. end;
  1474. var
  1475. pt : ptree;
  1476. procedure array_dec;
  1477. var
  1478. lowval,
  1479. highval : longint;
  1480. arraytype : pdef;
  1481. begin
  1482. consume(_ARRAY);
  1483. consume(LECKKLAMMER);
  1484. { defaults }
  1485. arraytype:=generrordef;
  1486. lowval:=$80000000;
  1487. highval:=$7fffffff;
  1488. p:=nil;
  1489. repeat
  1490. { read the expression and check it }
  1491. pt:=expr;
  1492. if pt^.treetype=typen then
  1493. begin
  1494. case pt^.resulttype^.deftype of
  1495. enumdef : begin
  1496. lowval:=penumdef(pt^.resulttype)^.min;
  1497. highval:=penumdef(pt^.resulttype)^.max;
  1498. arraytype:=pt^.resulttype;
  1499. end;
  1500. orddef : begin
  1501. case porddef(pt^.resulttype)^.typ of
  1502. s8bit,u8bit,
  1503. s16bit,u16bit,
  1504. s32bit : begin
  1505. lowval:=porddef(pt^.resulttype)^.low;
  1506. highval:=porddef(pt^.resulttype)^.high;
  1507. arraytype:=pt^.resulttype;
  1508. end;
  1509. bool8bit,
  1510. bool16bit,
  1511. bool32bit : begin
  1512. lowval:=0;
  1513. highval:=1;
  1514. arraytype:=pt^.resulttype;
  1515. end;
  1516. uchar : begin
  1517. lowval:=0;
  1518. highval:=255;
  1519. arraytype:=pt^.resulttype;
  1520. end;
  1521. else
  1522. Message(sym_e_error_in_type_def);
  1523. end;
  1524. end;
  1525. else
  1526. Message(sym_e_error_in_type_def);
  1527. end
  1528. end
  1529. else
  1530. begin
  1531. do_firstpass(pt);
  1532. if (pt^.treetype<>rangen) or
  1533. (pt^.left^.treetype<>ordconstn) then
  1534. Message(sym_e_error_in_type_def)
  1535. else
  1536. begin
  1537. {$ifndef GDB}
  1538. if pt^.right^.resulttype=pdef(s32bitdef) then
  1539. pt^.right^.resulttype:=new(porddef,init(s32bit,$80000000,$7fffffff));
  1540. {$endif GDB}
  1541. lowval:=pt^.left^.value;
  1542. highval:=pt^.right^.value;
  1543. arraytype:=pt^.right^.resulttype;
  1544. end;
  1545. end;
  1546. disposetree(pt);
  1547. { create arraydef }
  1548. if p=nil then
  1549. begin
  1550. ap:=new(parraydef,init(lowval,highval,arraytype));
  1551. p:=ap;
  1552. end
  1553. else
  1554. begin
  1555. ap^.definition:=new(parraydef,init(lowval,highval,arraytype));
  1556. ap:=parraydef(ap^.definition);
  1557. end;
  1558. if token=COMMA then
  1559. consume(COMMA)
  1560. else
  1561. break;
  1562. until false;
  1563. consume(RECKKLAMMER);
  1564. consume(_OF);
  1565. hp1:=read_type('');
  1566. { if no error, set element type }
  1567. if assigned(ap) then
  1568. ap^.definition:=hp1;
  1569. end;
  1570. begin
  1571. case token of
  1572. _STRING,_FILE:
  1573. p:=single_type(hs);
  1574. LKLAMMER:
  1575. begin
  1576. consume(LKLAMMER);
  1577. { allow negativ value_str }
  1578. l:=-1;
  1579. aufsym := Nil;
  1580. aufdef:=new(penumdef,init);
  1581. repeat
  1582. s:=pattern;
  1583. consume(ID);
  1584. if token=ASSIGNMENT then
  1585. begin
  1586. consume(ASSIGNMENT);
  1587. v:=get_intconst;
  1588. { please leave that a note, allows type save }
  1589. { declarations in the win32 units ! }
  1590. if v<=l then
  1591. Message(parser_n_duplicate_enum);
  1592. l:=v;
  1593. end
  1594. else
  1595. inc(l);
  1596. constsymtable^.insert(new(penumsym,init(s,aufdef,l)));
  1597. if token=COMMA then
  1598. consume(COMMA)
  1599. else
  1600. break;
  1601. until false;
  1602. {aufdef^.max:=l;
  1603. if we allow unordered enums
  1604. this can be wrong
  1605. min and max are now set in tenumsym.init PM }
  1606. p:=aufdef;
  1607. consume(RKLAMMER);
  1608. end;
  1609. _ARRAY:
  1610. array_dec;
  1611. _SET:
  1612. begin
  1613. consume(_SET);
  1614. consume(_OF);
  1615. hp1:=read_type('');
  1616. case hp1^.deftype of
  1617. { don't forget that min can be negativ PM }
  1618. enumdef : if penumdef(hp1)^.min>=0 then
  1619. p:=new(psetdef,init(hp1,penumdef(hp1)^.max))
  1620. else
  1621. Message(sym_e_ill_type_decl_set);
  1622. orddef : begin
  1623. case porddef(hp1)^.typ of
  1624. uchar : p:=new(psetdef,init(hp1,255));
  1625. u8bit,s8bit,u16bit,s16bit,s32bit :
  1626. begin
  1627. if (porddef(hp1)^.low>=0) then
  1628. p:=new(psetdef,init(hp1,porddef(hp1)^.high))
  1629. else Message(sym_e_ill_type_decl_set);
  1630. end;
  1631. else Message(sym_e_ill_type_decl_set);
  1632. end;
  1633. end;
  1634. else Message(sym_e_ill_type_decl_set);
  1635. end;
  1636. end;
  1637. CARET:
  1638. begin
  1639. consume(CARET);
  1640. { forwards allowed only inside TYPE statements }
  1641. if typecanbeforward then
  1642. forwardsallowed:=true;
  1643. hp1:=single_type(hs);
  1644. p:=new(ppointerdef,init(hp1));
  1645. {I add big troubles here
  1646. with var p : ^byte in graph.putimage
  1647. because a save_forward was called and
  1648. no resolve forward
  1649. => so the definition was rewritten after
  1650. having been disposed !!
  1651. Strange problems appeared !!!!}
  1652. {Anyhow forwards should only be allowed
  1653. inside a type statement ??
  1654. don't you think so }
  1655. if (lasttypesym<>nil)
  1656. and ((lasttypesym^.properties and sp_forwarddef)<>0) then
  1657. lasttypesym^.forwardpointer:=ppointerdef(p);
  1658. forwardsallowed:=false;
  1659. end;
  1660. _RECORD:
  1661. p:=record_dec;
  1662. _PACKED:
  1663. begin
  1664. consume(_PACKED);
  1665. if token=_ARRAY then
  1666. array_dec
  1667. else
  1668. begin
  1669. oldaktpackrecords:=aktpackrecords;
  1670. aktpackrecords:=1;
  1671. if token in [_CLASS,_OBJECT] then
  1672. p:=object_dec(name,nil)
  1673. else
  1674. p:=record_dec;
  1675. aktpackrecords:=oldaktpackrecords;
  1676. end;
  1677. end;
  1678. _CLASS,
  1679. _OBJECT:
  1680. p:=object_dec(name,nil);
  1681. _PROCEDURE:
  1682. begin
  1683. consume(_PROCEDURE);
  1684. p:=handle_procvar;
  1685. if token=_OF then
  1686. begin
  1687. consume(_OF);
  1688. consume(_OBJECT);
  1689. pprocvardef(p)^.options:=pprocvardef(p)^.options or pomethodpointer;
  1690. end;
  1691. end;
  1692. _FUNCTION:
  1693. begin
  1694. consume(_FUNCTION);
  1695. p:=handle_procvar;
  1696. consume(COLON);
  1697. pprocvardef(p)^.retdef:=single_type(hs);
  1698. if token=_OF then
  1699. begin
  1700. consume(_OF);
  1701. consume(_OBJECT);
  1702. pprocvardef(p)^.options:=pprocvardef(p)^.options or pomethodpointer;
  1703. end;
  1704. end;
  1705. else
  1706. expr_type;
  1707. end;
  1708. read_type:=p;
  1709. end;
  1710. { reads a type declaration to the symbol table }
  1711. procedure type_dec;
  1712. var
  1713. typename : stringid;
  1714. newtype : ptypesym;
  1715. {$ifdef dummy}
  1716. olddef,newdef : pdef;
  1717. s : string;
  1718. {$endif dummy}
  1719. begin
  1720. block_type:=bt_type;
  1721. consume(_TYPE);
  1722. typecanbeforward:=true;
  1723. repeat
  1724. typename:=pattern;
  1725. consume(ID);
  1726. consume(EQUAL);
  1727. { here you loose the strictness of pascal
  1728. for which a redefinition like
  1729. childtype = parenttype;
  1730. child2type = parenttype;
  1731. does not make the two child types equal !!
  1732. here all vars from childtype and child2type
  1733. get the definition of parenttype !! }
  1734. {$ifdef testequaltype}
  1735. if (token = ID) or (token=_FILE) or (token=_STRING) then
  1736. begin
  1737. olddef := single_type(s);
  1738. { make a clone of olddef }
  1739. { is that ok ??? }
  1740. getmem(newdef,SizeOf(olddef));
  1741. move(olddef^,newdef^,SizeOf(olddef));
  1742. newtype:=new(ptypesym,init(typename,newdef));
  1743. symtablestack^.insert(newtype);
  1744. end
  1745. else
  1746. {$endif testequaltype}
  1747. begin
  1748. getsym(typename,false);
  1749. { check if it is the definition of a forward defined class }
  1750. if assigned(srsym) and (token=_CLASS) and
  1751. (srsym^.typ=typesym) and
  1752. (ptypesym(srsym)^.definition^.deftype=objectdef) and
  1753. ((pobjectdef(ptypesym(srsym)^.definition)^.options and oo_isforward)<>0) and
  1754. ((pobjectdef(ptypesym(srsym)^.definition)^.options and oois_class)<>0) then
  1755. begin
  1756. { we can ignore the result }
  1757. { the definition is modified }
  1758. object_dec(typename,pobjectdef(ptypesym(srsym)^.definition));
  1759. newtype:=ptypesym(srsym);
  1760. end
  1761. else
  1762. begin
  1763. newtype:=new(ptypesym,init(typename,read_type(typename)));
  1764. { load newtype with the new pointer to the inserted type
  1765. because it can be an already defined forwarded type !! }
  1766. newtype:=ptypesym(symtablestack^.insert(newtype));
  1767. end;
  1768. end;
  1769. consume(SEMICOLON);
  1770. if assigned(newtype^.definition) and (newtype^.definition^.deftype=procvardef) then
  1771. parse_var_proc_directives(newtype);
  1772. until token<>ID;
  1773. typecanbeforward:=false;
  1774. {$ifdef tp}
  1775. symtablestack^.foreach(testforward_types);
  1776. {$else}
  1777. symtablestack^.foreach(@testforward_types);
  1778. {$endif}
  1779. resolve_forwards;
  1780. block_type:=bt_general;
  1781. end;
  1782. procedure var_dec;
  1783. { parses varaible declarations and inserts them in }
  1784. { the top symbol table of symtablestack }
  1785. begin
  1786. consume(_VAR);
  1787. read_var_decs(false,false);
  1788. end;
  1789. procedure Not_supported_for_inline(t : ttoken);
  1790. begin
  1791. if assigned(aktprocsym) and
  1792. ((aktprocsym^.definition^.options and poinline)<>0) then
  1793. Begin
  1794. Message1(parser_w_not_supported_for_inline,tokenstring(t));
  1795. Message(parser_w_inlining_disabled);
  1796. aktprocsym^.definition^.options:= aktprocsym^.definition^.options and not poinline;
  1797. End;
  1798. end;
  1799. procedure read_declarations(islibrary : boolean);
  1800. begin
  1801. repeat
  1802. case token of
  1803. _LABEL:
  1804. begin
  1805. Not_supported_for_inline(token);
  1806. label_dec;
  1807. end;
  1808. _CONST:
  1809. begin
  1810. Not_supported_for_inline(token);
  1811. const_dec;
  1812. end;
  1813. _TYPE:
  1814. begin
  1815. Not_supported_for_inline(token);
  1816. type_dec;
  1817. end;
  1818. _VAR:
  1819. var_dec;
  1820. _CONSTRUCTOR,_DESTRUCTOR,
  1821. _FUNCTION,_PROCEDURE,_OPERATOR,_CLASS:
  1822. begin
  1823. Not_supported_for_inline(token);
  1824. unter_dec;
  1825. end;
  1826. _EXPORTS:
  1827. begin
  1828. { here we should be at lexlevel 1, no ? PM }
  1829. Not_supported_for_inline(token);
  1830. if islibrary then
  1831. read_exports
  1832. else
  1833. break;
  1834. end
  1835. else break;
  1836. end;
  1837. until false;
  1838. end;
  1839. procedure read_interface_declarations;
  1840. begin
  1841. {Since the body is now parsed at lexlevel 1, and the declarations
  1842. must be parsed at the same lexlevel we increase the lexlevel.}
  1843. inc(lexlevel);
  1844. repeat
  1845. case token of
  1846. _CONST : const_dec;
  1847. _TYPE : type_dec;
  1848. _VAR : var_dec;
  1849. _FUNCTION,
  1850. _PROCEDURE,
  1851. _OPERATOR : unter_dec;
  1852. else
  1853. break;
  1854. end;
  1855. until false;
  1856. dec(lexlevel);
  1857. end;
  1858. end.
  1859. {
  1860. $Log$
  1861. Revision 1.50 1998-09-07 18:46:08 peter
  1862. * update smartlinking, uses getdatalabel
  1863. * renamed ptree.value vars to value_str,value_real,value_set
  1864. Revision 1.49 1998/09/07 17:37:00 florian
  1865. * first fixes for published properties
  1866. Revision 1.48 1998/09/04 08:42:02 peter
  1867. * updated some error messages
  1868. Revision 1.47 1998/09/03 16:03:18 florian
  1869. + rtti generation
  1870. * init table generation changed
  1871. Revision 1.46 1998/09/01 17:39:48 peter
  1872. + internal constant functions
  1873. Revision 1.45 1998/08/31 12:20:28 peter
  1874. * fixed array_dec when unknown type was used
  1875. Revision 1.44 1998/08/28 10:57:01 peter
  1876. * removed warnings
  1877. Revision 1.43 1998/08/25 13:09:25 pierre
  1878. * corrected mangling sheme :
  1879. cvar add Cprefix to the mixed case name whereas
  1880. export or public use direct name
  1881. Revision 1.42 1998/08/25 12:42:41 pierre
  1882. * CDECL changed to CVAR for variables
  1883. specifications are read in structures also
  1884. + started adding GPC compatibility mode ( option -Sp)
  1885. * names changed to lowercase
  1886. Revision 1.41 1998/08/23 21:04:36 florian
  1887. + rtti generation for classes added
  1888. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  1889. Revision 1.40 1998/08/21 15:48:58 pierre
  1890. * more cdecl chagnes
  1891. - better line info
  1892. - changes the definition options of a procvar
  1893. if it is a unnamed type
  1894. Revision 1.39 1998/08/19 00:42:40 peter
  1895. + subrange types for enums
  1896. + checking for bounds type with ranges
  1897. Revision 1.38 1998/08/12 19:20:39 peter
  1898. + public is the same as export for c_vars
  1899. * a exported/public c_var incs now the refcount
  1900. Revision 1.37 1998/08/11 15:31:38 peter
  1901. * write extended to ppu file
  1902. * new version 0.99.7
  1903. Revision 1.36 1998/08/10 14:50:09 peter
  1904. + localswitches, moduleswitches, globalswitches splitting
  1905. Revision 1.35 1998/07/26 21:59:00 florian
  1906. + better support for switch $H
  1907. + index access to ansi strings added
  1908. + assigment of data (records/arrays) containing ansi strings
  1909. Revision 1.34 1998/07/20 22:17:15 florian
  1910. * hex constants in numeric char (#$54#$43 ...) are now allowed
  1911. * there was a bug in record_var_dec which prevents the used
  1912. of nested variant records (for example drivers.tevent of tv)
  1913. Revision 1.33 1998/07/18 17:11:11 florian
  1914. + ansi string constants fixed
  1915. + switch $H partial implemented
  1916. Revision 1.32 1998/07/14 21:46:50 peter
  1917. * updated messages file
  1918. Revision 1.31 1998/07/14 14:46:53 peter
  1919. * released NEWINPUT
  1920. Revision 1.30 1998/07/10 00:00:00 peter
  1921. * fixed ttypesym bug finally
  1922. * fileinfo in the symtable and better using for unused vars
  1923. Revision 1.29 1998/06/25 14:04:21 peter
  1924. + internal inc/dec
  1925. Revision 1.28 1998/06/24 12:26:45 peter
  1926. * stricter var parsing like tp7 and some optimizes with directive
  1927. parsing
  1928. Revision 1.27 1998/06/12 16:15:34 pierre
  1929. * external name 'C_var';
  1930. export name 'intern_C_var';
  1931. cdecl;
  1932. cdecl;external;
  1933. are now supported only with -Sv switch
  1934. Revision 1.25 1998/06/09 16:01:45 pierre
  1935. + added procedure directive parsing for procvars
  1936. (accepted are popstack cdecl and pascal)
  1937. + added C vars with the following syntax
  1938. var C calias 'true_c_name';(can be followed by external)
  1939. reason is that you must add the Cprefix
  1940. which is target dependent
  1941. Revision 1.24 1998/06/05 14:37:32 pierre
  1942. * fixes for inline for operators
  1943. * inline procedure more correctly restricted
  1944. Revision 1.23 1998/06/04 23:51:50 peter
  1945. * m68k compiles
  1946. + .def file creation moved to gendef.pas so it could also be used
  1947. for win32
  1948. Revision 1.22 1998/06/03 22:48:59 peter
  1949. + wordbool,longbool
  1950. * rename bis,von -> high,low
  1951. * moved some systemunit loading/creating to psystem.pas
  1952. Revision 1.21 1998/06/03 22:14:19 florian
  1953. * problem with sizes of classes fixed (if the anchestor was declared
  1954. forward, the compiler doesn't update the child classes size)
  1955. Revision 1.20 1998/05/28 14:35:54 peter
  1956. * nicer error message when no id is used after var
  1957. Revision 1.19 1998/05/23 01:21:19 peter
  1958. + aktasmmode, aktoptprocessor, aktoutputformat
  1959. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1960. + $LIBNAME to set the library name where the unit will be put in
  1961. * splitted cgi386 a bit (codeseg to large for bp7)
  1962. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1963. Revision 1.18 1998/05/20 09:42:35 pierre
  1964. + UseTokenInfo now default
  1965. * unit in interface uses and implementation uses gives error now
  1966. * only one error for unknown symbol (uses lastsymknown boolean)
  1967. the problem came from the label code !
  1968. + first inlined procedures and function work
  1969. (warning there might be allowed cases were the result is still wrong !!)
  1970. * UseBrower updated gives a global list of all position of all used symbols
  1971. with switch -gb
  1972. Revision 1.17 1998/05/11 13:07:55 peter
  1973. + $ifdef NEWPPU for the new ppuformat
  1974. + $define GDB not longer required
  1975. * removed all warnings and stripped some log comments
  1976. * no findfirst/findnext anymore to remove smartlink *.o files
  1977. Revision 1.16 1998/05/05 12:05:42 florian
  1978. * problems with properties fixed
  1979. * crash fixed: i:=l when i and l are undefined, was a problem with
  1980. implementation of private/protected
  1981. Revision 1.15 1998/05/01 09:01:23 florian
  1982. + correct semantics of private and protected
  1983. * small fix in variable scope:
  1984. a id can be used in a parameter list of a method, even it is used in
  1985. an anchestor class as field id
  1986. Revision 1.14 1998/05/01 07:43:56 florian
  1987. + basics for rtti implemented
  1988. + switch $m (generate rtti for published sections)
  1989. Revision 1.13 1998/04/30 15:59:41 pierre
  1990. * GDB works again better :
  1991. correct type info in one pass
  1992. + UseTokenInfo for better source position
  1993. * fixed one remaining bug in scanner for line counts
  1994. * several little fixes
  1995. Revision 1.12 1998/04/29 10:33:57 pierre
  1996. + added some code for ansistring (not complete nor working yet)
  1997. * corrected operator overloading
  1998. * corrected nasm output
  1999. + started inline procedures
  2000. + added starstarn : use ** for exponentiation (^ gave problems)
  2001. + started UseTokenInfo cond to get accurate positions
  2002. Revision 1.11 1998/04/28 11:45:52 florian
  2003. * make it compilable with TP
  2004. + small COM problems solved to compile classes.pp
  2005. Revision 1.10 1998/04/27 23:10:28 peter
  2006. + new scanner
  2007. * $makelib -> if smartlink
  2008. * small filename fixes pmodule.setfilename
  2009. * moved import from files.pas -> import.pas
  2010. Revision 1.9 1998/04/10 21:36:56 florian
  2011. + some stuff to support method pointers (procedure of object) added
  2012. (declaration, parameter handling)
  2013. Revision 1.8 1998/04/10 15:39:48 florian
  2014. * more fixes to get classes.pas compiled
  2015. Revision 1.7 1998/04/09 23:02:15 florian
  2016. * small problems solved to get remake3 work
  2017. Revision 1.6 1998/04/09 22:16:35 florian
  2018. * problem with previous REGALLOC solved
  2019. * improved property support
  2020. Revision 1.5 1998/04/08 14:59:20 florian
  2021. * problem with new expr_type solved
  2022. Revision 1.4 1998/04/08 10:26:09 florian
  2023. * correct error handling of virtual constructors
  2024. * problem with new type declaration handling fixed
  2025. Revision 1.3 1998/04/07 22:45:05 florian
  2026. * bug0092, bug0115 and bug0121 fixed
  2027. + packed object/class/array
  2028. Revision 1.2 1998/04/05 13:58:35 peter
  2029. * fixed the -Ss bug
  2030. + warning for Virtual constructors
  2031. * helppages updated with -TGO32V1
  2032. }