pdecl.pas 104 KB

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