pdecl.pas 122 KB

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