pdecl.pas 122 KB

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