pdecl.pas 122 KB

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