pdecl.pas 101 KB

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