pdecl.pas 99 KB

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