pdecl.pas 100 KB

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