pdecl.pas 80 KB

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