pdecl.pas 103 KB

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