pdecl.pas 102 KB

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