pdecl.pas 122 KB

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