pdecl.pas 103 KB

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