pdecl.pas 99 KB

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