pdecl.pas 106 KB

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