pdecobj.pas 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Does object types 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 pdecobj;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. globtype,symtype,symdef;
  23. { parses a object declaration }
  24. function object_dec(const n : stringid;fd : tobjectdef) : tdef;
  25. implementation
  26. uses
  27. cutils,cclasses,
  28. globals,verbose,systems,tokens,
  29. symconst,symbase,symsym,symtable,defutil,defcmp,
  30. node,nld,nmem,ncon,ncnv,ncal,pass_1,
  31. scanner,
  32. pbase,pexpr,pdecsub,pdecvar,ptype
  33. {$ifdef delphi}
  34. ,dmisc
  35. ,sysutils
  36. {$endif}
  37. ;
  38. const
  39. { Please leave this here, this module should NOT use
  40. these variables.
  41. Declaring it as string here results in an error when compiling (PFV) }
  42. current_procinfo = 'error';
  43. function object_dec(const n : stringid;fd : tobjectdef) : tdef;
  44. { this function parses an object or class declaration }
  45. var
  46. there_is_a_destructor : boolean;
  47. classtype : tobjectdeftype;
  48. childof : tobjectdef;
  49. aktclass : tobjectdef;
  50. function constructor_head:tprocdef;
  51. var
  52. pd : tprocdef;
  53. begin
  54. consume(_CONSTRUCTOR);
  55. { must be at same level as in implementation }
  56. pd:=parse_proc_head(aktclass,potype_constructor);
  57. if (cs_constructor_name in aktglobalswitches) and
  58. (pd.procsym.name<>'INIT') then
  59. Message(parser_e_constructorname_must_be_init);
  60. consume(_SEMICOLON);
  61. include(aktclass.objectoptions,oo_has_constructor);
  62. { Set return type, class constructors return the
  63. created instance, object constructors return boolean }
  64. if is_class(pd._class) then
  65. pd.rettype.setdef(pd._class)
  66. else
  67. pd.rettype:=booltype;
  68. constructor_head:=pd;
  69. end;
  70. procedure property_dec;
  71. { convert a node tree to symlist and return the last
  72. symbol }
  73. function parse_symlist(pl:tsymlist;var def:tdef):boolean;
  74. var
  75. idx : longint;
  76. sym : tsym;
  77. st : tsymtable;
  78. begin
  79. result:=true;
  80. def:=nil;
  81. if token=_ID then
  82. begin
  83. sym:=search_class_member(aktclass,pattern);
  84. if assigned(sym) then
  85. begin
  86. case sym.typ of
  87. varsym :
  88. begin
  89. pl.addsym(sl_load,sym);
  90. def:=tvarsym(sym).vartype.def;
  91. end;
  92. procsym :
  93. begin
  94. pl.addsym(sl_call,sym);
  95. end;
  96. end;
  97. end
  98. else
  99. begin
  100. Message1(parser_e_illegal_field_or_method,pattern);
  101. result:=false;
  102. end;
  103. consume(_ID);
  104. repeat
  105. case token of
  106. _ID,
  107. _SEMICOLON :
  108. begin
  109. break;
  110. end;
  111. _POINT :
  112. begin
  113. consume(_POINT);
  114. if assigned(def) then
  115. begin
  116. st:=def.getsymtable(gs_record);
  117. if assigned(st) then
  118. begin
  119. sym:=searchsymonlyin(st,pattern);
  120. if assigned(sym) then
  121. begin
  122. pl.addsym(sl_subscript,sym);
  123. case sym.typ of
  124. varsym :
  125. def:=tvarsym(sym).vartype.def;
  126. else
  127. begin
  128. Message1(sym_e_illegal_field,pattern);
  129. result:=false;
  130. end;
  131. end;
  132. end
  133. else
  134. begin
  135. Message1(sym_e_illegal_field,pattern);
  136. result:=false;
  137. end;
  138. end
  139. else
  140. begin
  141. Message(cg_e_invalid_qualifier);
  142. result:=false;
  143. end;
  144. end
  145. else
  146. begin
  147. Message(cg_e_invalid_qualifier);
  148. result:=false;
  149. end;
  150. consume(_ID);
  151. end;
  152. _LECKKLAMMER :
  153. begin
  154. consume(_LECKKLAMMER);
  155. repeat
  156. if def.deftype=arraydef then
  157. begin
  158. idx:=get_intconst;
  159. pl.addconst(sl_vec,idx);
  160. def:=tarraydef(def).elementtype.def;
  161. end
  162. else
  163. begin
  164. Message(cg_e_invalid_qualifier);
  165. result:=false;
  166. end;
  167. until not try_to_consume(_COMMA);
  168. consume(_RECKKLAMMER);
  169. end;
  170. else
  171. begin
  172. Message(parser_e_ill_property_access_sym);
  173. result:=false;
  174. break;
  175. end;
  176. end;
  177. until false;
  178. end
  179. else
  180. begin
  181. Message(parser_e_ill_property_access_sym);
  182. result:=false;
  183. end;
  184. end;
  185. var
  186. sym : tsym;
  187. p : tpropertysym;
  188. overriden : tsym;
  189. hs : string;
  190. varspez : tvarspez;
  191. s : string;
  192. tt : ttype;
  193. arraytype : ttype;
  194. def : tdef;
  195. pt : tnode;
  196. propname : stringid;
  197. sc : tsinglelist;
  198. oldregisterdef : boolean;
  199. readvs,
  200. hvs : tvarsym;
  201. readprocdef,
  202. writeprocdef : tprocvardef;
  203. begin
  204. { check for a class }
  205. if not((is_class_or_interface(aktclass)) or
  206. ((m_delphi in aktmodeswitches) and (is_object(aktclass)))) then
  207. Message(parser_e_syntax_error);
  208. consume(_PROPERTY);
  209. { Generate temp procvardefs to search for matching read/write
  210. procedures. the readprocdef will store all definitions }
  211. oldregisterdef:=registerdef;
  212. registerdef:=false;
  213. readprocdef:=tprocvardef.create(normal_function_level);
  214. include(readprocdef.procoptions,po_methodpointer);
  215. writeprocdef:=tprocvardef.create(normal_function_level);
  216. include(writeprocdef.procoptions,po_methodpointer);
  217. registerdef:=oldregisterdef;
  218. if token<>_ID then
  219. begin
  220. consume(_ID);
  221. consume(_SEMICOLON);
  222. exit;
  223. end;
  224. { Generate propertysym and insert in symtablestack }
  225. p:=tpropertysym.create(orgpattern);
  226. symtablestack.insert(p);
  227. propname:=pattern;
  228. consume(_ID);
  229. { Set the symtablestack to the parast of readprop so
  230. temp defs will be destroyed after declaration }
  231. readprocdef.parast.next:=symtablestack;
  232. symtablestack:=readprocdef.parast;
  233. { property parameters ? }
  234. if token=_LECKKLAMMER then
  235. begin
  236. if (sp_published in current_object_option) then
  237. Message(parser_e_cant_publish_that_property);
  238. { create a list of the parameters }
  239. sc:=tsinglelist.create;
  240. consume(_LECKKLAMMER);
  241. inc(testcurobject);
  242. repeat
  243. if token=_VAR then
  244. begin
  245. consume(_VAR);
  246. varspez:=vs_var;
  247. end
  248. else if token=_CONST then
  249. begin
  250. consume(_CONST);
  251. varspez:=vs_const;
  252. end
  253. else if (idtoken=_OUT) and (m_out in aktmodeswitches) then
  254. begin
  255. consume(_OUT);
  256. varspez:=vs_out;
  257. end
  258. else
  259. varspez:=vs_value;
  260. sc.reset;
  261. repeat
  262. readvs:=tvarsym.create(orgpattern,varspez,generrortype);
  263. readprocdef.parast.insert(readvs);
  264. sc.insert(readvs);
  265. consume(_ID);
  266. until not try_to_consume(_COMMA);
  267. if token=_COLON then
  268. begin
  269. consume(_COLON);
  270. if token=_ARRAY then
  271. begin
  272. consume(_ARRAY);
  273. consume(_OF);
  274. { define range and type of range }
  275. tt.setdef(tarraydef.create(0,-1,s32bittype));
  276. { define field type }
  277. single_type(arraytype,s,false);
  278. tarraydef(tt.def).setelementtype(arraytype);
  279. end
  280. else
  281. single_type(tt,s,false);
  282. end
  283. else
  284. tt:=cformaltype;
  285. readvs:=tvarsym(sc.first);
  286. while assigned(readvs) do
  287. begin
  288. readprocdef.concatpara(nil,tt,readvs,nil,false);
  289. { also update the writeprocdef }
  290. hvs:=tvarsym.create(readvs.realname,vs_value,generrortype);
  291. writeprocdef.parast.insert(hvs);
  292. writeprocdef.concatpara(nil,tt,hvs,nil,false);
  293. readvs:=tvarsym(readvs.listnext);
  294. end;
  295. until not try_to_consume(_SEMICOLON);
  296. sc.free;
  297. dec(testcurobject);
  298. consume(_RECKKLAMMER);
  299. { the parser need to know if a property has parameters, the
  300. index parameter doesn't count (PFV) }
  301. if readprocdef.minparacount>0 then
  302. include(p.propoptions,ppo_hasparameters);
  303. end;
  304. { overriden property ? }
  305. { force property interface, if there is a property parameter }
  306. if (token=_COLON) or (readprocdef.minparacount>0) then
  307. begin
  308. consume(_COLON);
  309. single_type(p.proptype,hs,false);
  310. if (idtoken=_INDEX) then
  311. begin
  312. consume(_INDEX);
  313. pt:=comp_expr(true);
  314. if is_constnode(pt) and
  315. is_ordinal(pt.resulttype.def) and
  316. (not is_64bitint(pt.resulttype.def)) then
  317. p.index:=tordconstnode(pt).value
  318. else
  319. begin
  320. Message(parser_e_invalid_property_index_value);
  321. p.index:=0;
  322. end;
  323. p.indextype.setdef(pt.resulttype.def);
  324. include(p.propoptions,ppo_indexed);
  325. { concat a longint to the para templates }
  326. hvs:=tvarsym.create('$index',vs_value,p.indextype);
  327. readprocdef.parast.insert(hvs);
  328. readprocdef.concatpara(nil,p.indextype,hvs,nil,false);
  329. hvs:=tvarsym.create('$index',vs_value,p.indextype);
  330. writeprocdef.parast.insert(hvs);
  331. writeprocdef.concatpara(nil,p.indextype,hvs,nil,false);
  332. pt.free;
  333. end;
  334. end
  335. else
  336. begin
  337. { do an property override }
  338. overriden:=search_class_member(aktclass.childof,propname);
  339. if assigned(overriden) and (overriden.typ=propertysym) then
  340. begin
  341. p.dooverride(tpropertysym(overriden));
  342. end
  343. else
  344. begin
  345. p.proptype:=generrortype;
  346. message(parser_e_no_property_found_to_override);
  347. end;
  348. end;
  349. if (sp_published in current_object_option) and
  350. not(p.proptype.def.is_publishable) then
  351. Message(parser_e_cant_publish_that_property);
  352. if try_to_consume(_READ) then
  353. begin
  354. p.readaccess.clear;
  355. if parse_symlist(p.readaccess,def) then
  356. begin
  357. sym:=p.readaccess.firstsym^.sym;
  358. case sym.typ of
  359. procsym :
  360. begin
  361. { read is function returning the type of the property }
  362. readprocdef.rettype:=p.proptype;
  363. { Insert hidden parameters }
  364. calc_parast(readprocdef);
  365. { search procdefs matching readprocdef }
  366. p.readaccess.procdef:=Tprocsym(sym).search_procdef_bypara(readprocdef.para,p.proptype.def,[cpo_allowdefaults]);
  367. if not assigned(p.readaccess.procdef) then
  368. Message(parser_e_ill_property_access_sym);
  369. end;
  370. varsym :
  371. begin
  372. if not assigned(def) then
  373. internalerror(200310071);
  374. if compare_defs(def,p.proptype.def,nothingn)>=te_equal then
  375. begin
  376. { property parameters are allowed if this is
  377. an indexed property, because the index is then
  378. the parameter.
  379. Note: In the help of Kylix it is written
  380. that it isn't allowed, but the compiler accepts it (PFV) }
  381. if (ppo_hasparameters in p.propoptions) then
  382. Message(parser_e_ill_property_access_sym);
  383. end
  384. else
  385. IncompatibleTypes(def,p.proptype.def);
  386. end;
  387. else
  388. Message(parser_e_ill_property_access_sym);
  389. end;
  390. end;
  391. end;
  392. if try_to_consume(_WRITE) then
  393. begin
  394. p.writeaccess.clear;
  395. if parse_symlist(p.writeaccess,def) then
  396. begin
  397. sym:=p.writeaccess.firstsym^.sym;
  398. case sym.typ of
  399. procsym :
  400. begin
  401. { write is a procedure with an extra value parameter
  402. of the of the property }
  403. writeprocdef.rettype:=voidtype;
  404. hvs:=tvarsym.create('$value',vs_value,p.proptype);
  405. writeprocdef.parast.insert(hvs);
  406. writeprocdef.concatpara(nil,p.proptype,hvs,nil,false);
  407. { Insert hidden parameters }
  408. calc_parast(writeprocdef);
  409. { search procdefs matching writeprocdef }
  410. p.writeaccess.procdef:=Tprocsym(sym).search_procdef_bypara(writeprocdef.para,writeprocdef.rettype.def,[cpo_allowdefaults]);
  411. if not assigned(p.writeaccess.procdef) then
  412. Message(parser_e_ill_property_access_sym);
  413. end;
  414. varsym :
  415. begin
  416. if not assigned(def) then
  417. internalerror(200310072);
  418. if compare_defs(def,p.proptype.def,nothingn)>=te_equal then
  419. begin
  420. { property parameters are allowed if this is
  421. an indexed property, because the index is then
  422. the parameter.
  423. Note: In the help of Kylix it is written
  424. that it isn't allowed, but the compiler accepts it (PFV) }
  425. if (ppo_hasparameters in p.propoptions) then
  426. Message(parser_e_ill_property_access_sym);
  427. end
  428. else
  429. IncompatibleTypes(def,p.proptype.def);
  430. end;
  431. else
  432. Message(parser_e_ill_property_access_sym);
  433. end;
  434. end;
  435. end;
  436. include(p.propoptions,ppo_stored);
  437. if try_to_consume(_STORED) then
  438. begin
  439. p.storedaccess.clear;
  440. case token of
  441. _ID:
  442. begin
  443. { in the case that idtoken=_DEFAULT }
  444. { we have to do nothing except }
  445. { setting ppo_stored, it's the same }
  446. { as stored true }
  447. if idtoken<>_DEFAULT then
  448. begin
  449. if parse_symlist(p.storedaccess,def) then
  450. begin
  451. sym:=p.storedaccess.firstsym^.sym;
  452. case sym.typ of
  453. procsym :
  454. begin
  455. p.storedaccess.procdef:=Tprocsym(sym).search_procdef_nopara_boolret;
  456. if not assigned(p.storedaccess.procdef) then
  457. message(parser_e_ill_property_storage_sym);
  458. end;
  459. varsym :
  460. begin
  461. if not assigned(def) then
  462. internalerror(200310073);
  463. if (ppo_hasparameters in p.propoptions) or
  464. not(is_boolean(def)) then
  465. Message(parser_e_stored_property_must_be_boolean);
  466. end;
  467. else
  468. Message(parser_e_ill_property_access_sym);
  469. end;
  470. end;
  471. end;
  472. end;
  473. _FALSE:
  474. begin
  475. consume(_FALSE);
  476. exclude(p.propoptions,ppo_stored);
  477. end;
  478. _TRUE:
  479. consume(_TRUE);
  480. end;
  481. end;
  482. if try_to_consume(_DEFAULT) then
  483. begin
  484. if not(is_ordinal(p.proptype.def) or
  485. is_64bitint(p.proptype.def) or
  486. is_class(p.proptype.def) or
  487. is_single(p.proptype.def) or
  488. (p.proptype.def.deftype in [classrefdef,pointerdef]) or
  489. ((p.proptype.def.deftype=setdef) and
  490. (tsetdef(p.proptype.def).settype=smallset))) or
  491. ((p.proptype.def.deftype=arraydef) and
  492. (ppo_indexed in p.propoptions)) or
  493. (ppo_hasparameters in p.propoptions) then
  494. begin
  495. Message(parser_e_property_cant_have_a_default_value);
  496. { Error recovery }
  497. pt:=comp_expr(true);
  498. pt.free;
  499. end
  500. else
  501. begin
  502. { Get the result of the default, the firstpass is
  503. needed to support values like -1 }
  504. pt:=comp_expr(true);
  505. if (p.proptype.def.deftype=setdef) and
  506. (pt.nodetype=arrayconstructorn) then
  507. begin
  508. arrayconstructor_to_set(pt);
  509. do_resulttypepass(pt);
  510. end;
  511. inserttypeconv(pt,p.proptype);
  512. if not(is_constnode(pt)) then
  513. Message(parser_e_property_default_value_must_const);
  514. { Set default value }
  515. case pt.nodetype of
  516. setconstn :
  517. p.default:=plongint(tsetconstnode(pt).value_set)^;
  518. ordconstn :
  519. p.default:=tordconstnode(pt).value;
  520. niln :
  521. p.default:=0;
  522. realconstn:
  523. p.default:=longint(single(trealconstnode(pt).value_real));
  524. end;
  525. pt.free;
  526. end;
  527. end
  528. else if try_to_consume(_NODEFAULT) then
  529. begin
  530. p.default:=0;
  531. end;
  532. consume(_SEMICOLON);
  533. { default property ? }
  534. if try_to_consume(_DEFAULT) then
  535. begin
  536. include(p.propoptions,ppo_defaultproperty);
  537. if readprocdef.maxparacount=0 then
  538. message(parser_e_property_need_paras);
  539. consume(_SEMICOLON);
  540. end;
  541. { remove temporary procvardefs }
  542. symtablestack:=symtablestack.next;
  543. readprocdef.free;
  544. writeprocdef.free;
  545. end;
  546. function destructor_head:tprocdef;
  547. var
  548. pd : tprocdef;
  549. begin
  550. consume(_DESTRUCTOR);
  551. pd:=parse_proc_head(aktclass,potype_destructor);
  552. if (cs_constructor_name in aktglobalswitches) and
  553. (pd.procsym.name<>'DONE') then
  554. Message(parser_e_destructorname_must_be_done);
  555. if not(pd.maxparacount=0) and
  556. (m_fpc in aktmodeswitches) then
  557. Message(parser_e_no_paras_for_destructor);
  558. consume(_SEMICOLON);
  559. include(aktclass.objectoptions,oo_has_destructor);
  560. { no return value }
  561. pd.rettype:=voidtype;
  562. destructor_head:=pd;
  563. end;
  564. var
  565. hs : string;
  566. pcrd : tclassrefdef;
  567. tt : ttype;
  568. old_object_option : tsymoptions;
  569. oldparse_only : boolean;
  570. storetypecanbeforward : boolean;
  571. procedure setclassattributes;
  572. begin
  573. { publishable }
  574. if classtype in [odt_interfacecom,odt_class] then
  575. begin
  576. aktclass.objecttype:=classtype;
  577. if (cs_generate_rtti in aktlocalswitches) or
  578. (assigned(aktclass.childof) and
  579. (oo_can_have_published in aktclass.childof.objectoptions)) then
  580. begin
  581. include(aktclass.objectoptions,oo_can_have_published);
  582. { in "publishable" classes the default access type is published }
  583. current_object_option:=[sp_published];
  584. end;
  585. end;
  586. end;
  587. procedure setclassparent;
  588. begin
  589. if assigned(fd) then
  590. aktclass:=fd
  591. else
  592. aktclass:=tobjectdef.create(classtype,n,nil);
  593. { is the current class tobject? }
  594. { so you could define your own tobject }
  595. if (cs_compilesystem in aktmoduleswitches) and (classtype=odt_class) and (upper(n)='TOBJECT') then
  596. class_tobject:=aktclass
  597. else if (cs_compilesystem in aktmoduleswitches) and (classtype=odt_interfacecom) and (upper(n)='IUNKNOWN') then
  598. interface_iunknown:=aktclass
  599. else
  600. begin
  601. case classtype of
  602. odt_class:
  603. childof:=class_tobject;
  604. odt_interfacecom:
  605. childof:=interface_iunknown;
  606. end;
  607. if (oo_is_forward in childof.objectoptions) then
  608. Message1(parser_e_forward_declaration_must_be_resolved,childof.objrealname^);
  609. aktclass.set_parent(childof);
  610. end;
  611. end;
  612. procedure setinterfacemethodoptions;
  613. var
  614. i: longint;
  615. defs: TIndexArray;
  616. pd: tprocdef;
  617. begin
  618. include(aktclass.objectoptions,oo_has_virtual);
  619. defs:=aktclass.symtable.defindex;
  620. for i:=1 to defs.count do
  621. begin
  622. pd:=tprocdef(defs.search(i));
  623. if pd.deftype=procdef then
  624. begin
  625. pd.extnumber:=aktclass.lastvtableindex;
  626. inc(aktclass.lastvtableindex);
  627. include(pd.procoptions,po_virtualmethod);
  628. pd.forwarddef:=false;
  629. end;
  630. end;
  631. end;
  632. function readobjecttype : boolean;
  633. begin
  634. readobjecttype:=true;
  635. { distinguish classes and objects }
  636. case token of
  637. _OBJECT:
  638. begin
  639. classtype:=odt_object;
  640. consume(_OBJECT)
  641. end;
  642. _CPPCLASS:
  643. begin
  644. classtype:=odt_cppclass;
  645. consume(_CPPCLASS);
  646. end;
  647. _INTERFACE:
  648. begin
  649. { need extra check here since interface is a keyword
  650. in all pascal modes }
  651. if not(m_class in aktmodeswitches) then
  652. Message(parser_f_need_objfpc_or_delphi_mode);
  653. if aktinterfacetype=it_interfacecom then
  654. classtype:=odt_interfacecom
  655. else {it_interfacecorba}
  656. classtype:=odt_interfacecorba;
  657. consume(_INTERFACE);
  658. { forward declaration }
  659. if not(assigned(fd)) and (token=_SEMICOLON) then
  660. begin
  661. { also anonym objects aren't allow (o : object a : longint; end;) }
  662. if n='' then
  663. Message(parser_f_no_anonym_objects);
  664. aktclass:=tobjectdef.create(classtype,n,nil);
  665. if (cs_compilesystem in aktmoduleswitches) and
  666. (classtype=odt_interfacecom) and (upper(n)='IUNKNOWN') then
  667. interface_iunknown:=aktclass;
  668. include(aktclass.objectoptions,oo_is_forward);
  669. object_dec:=aktclass;
  670. typecanbeforward:=storetypecanbeforward;
  671. readobjecttype:=false;
  672. exit;
  673. end;
  674. end;
  675. _CLASS:
  676. begin
  677. classtype:=odt_class;
  678. consume(_CLASS);
  679. if not(assigned(fd)) and
  680. (token=_OF) and
  681. { Delphi only allows class of in type blocks.
  682. Note that when parsing the type of a variable declaration
  683. the blocktype is bt_type so the check for typecanbeforward
  684. is also necessary (PFV) }
  685. (((block_type=bt_type) and typecanbeforward) or
  686. not(m_delphi in aktmodeswitches)) then
  687. begin
  688. { a hack, but it's easy to handle }
  689. { class reference type }
  690. consume(_OF);
  691. single_type(tt,hs,typecanbeforward);
  692. { accept hp1, if is a forward def or a class }
  693. if (tt.def.deftype=forwarddef) or
  694. is_class(tt.def) then
  695. begin
  696. pcrd:=tclassrefdef.create(tt);
  697. object_dec:=pcrd;
  698. end
  699. else
  700. begin
  701. object_dec:=generrortype.def;
  702. Message1(type_e_class_type_expected,generrortype.def.typename);
  703. end;
  704. typecanbeforward:=storetypecanbeforward;
  705. readobjecttype:=false;
  706. exit;
  707. end
  708. { forward class }
  709. else if not(assigned(fd)) and (token=_SEMICOLON) then
  710. begin
  711. { also anonym objects aren't allow (o : object a : longint; end;) }
  712. if n='' then
  713. Message(parser_f_no_anonym_objects);
  714. aktclass:=tobjectdef.create(odt_class,n,nil);
  715. if (cs_compilesystem in aktmoduleswitches) and (upper(n)='TOBJECT') then
  716. class_tobject:=aktclass;
  717. aktclass.objecttype:=odt_class;
  718. include(aktclass.objectoptions,oo_is_forward);
  719. { all classes must have a vmt !! at offset zero }
  720. if not(oo_has_vmt in aktclass.objectoptions) then
  721. aktclass.insertvmt;
  722. object_dec:=aktclass;
  723. typecanbeforward:=storetypecanbeforward;
  724. readobjecttype:=false;
  725. exit;
  726. end;
  727. end;
  728. else
  729. begin
  730. classtype:=odt_class; { this is error but try to recover }
  731. consume(_OBJECT);
  732. end;
  733. end;
  734. end;
  735. procedure handleimplementedinterface(implintf : tobjectdef);
  736. begin
  737. if not is_interface(implintf) then
  738. begin
  739. Message1(type_e_interface_type_expected,implintf.typename);
  740. exit;
  741. end;
  742. if aktclass.implementedinterfaces.searchintf(implintf)<>-1 then
  743. Message1(sym_e_duplicate_id,implintf.name)
  744. else
  745. begin
  746. { allocate and prepare the GUID only if the class
  747. implements some interfaces.
  748. }
  749. if aktclass.implementedinterfaces.count = 0 then
  750. aktclass.prepareguid;
  751. aktclass.implementedinterfaces.addintf(implintf);
  752. end;
  753. end;
  754. procedure readimplementedinterfaces;
  755. var
  756. tt : ttype;
  757. begin
  758. while try_to_consume(_COMMA) do
  759. begin
  760. id_type(tt,pattern,false);
  761. if (tt.def.deftype<>objectdef) then
  762. begin
  763. Message1(type_e_interface_type_expected,tt.def.typename);
  764. continue;
  765. end;
  766. handleimplementedinterface(tobjectdef(tt.def));
  767. end;
  768. end;
  769. procedure readinterfaceiid;
  770. var
  771. p : tnode;
  772. valid : boolean;
  773. begin
  774. p:=comp_expr(true);
  775. if p.nodetype=stringconstn then
  776. begin
  777. stringdispose(aktclass.iidstr);
  778. aktclass.iidstr:=stringdup(strpas(tstringconstnode(p).value_str)); { or upper? }
  779. p.free;
  780. valid:=string2guid(aktclass.iidstr^,aktclass.iidguid^);
  781. if (classtype=odt_interfacecom) and not assigned(aktclass.iidguid) and not valid then
  782. Message(parser_e_improper_guid_syntax);
  783. end
  784. else
  785. begin
  786. p.free;
  787. Message(cg_e_illegal_expression);
  788. end;
  789. end;
  790. procedure readparentclasses;
  791. var
  792. hp : tobjectdef;
  793. begin
  794. hp:=nil;
  795. { reads the parent class }
  796. if try_to_consume(_LKLAMMER) then
  797. begin
  798. id_type(tt,pattern,false);
  799. childof:=tobjectdef(tt.def);
  800. if (not assigned(childof)) or
  801. (childof.deftype<>objectdef) then
  802. begin
  803. if assigned(childof) then
  804. Message1(type_e_class_type_expected,childof.typename);
  805. childof:=nil;
  806. aktclass:=tobjectdef.create(classtype,n,nil);
  807. end
  808. else
  809. begin
  810. { a mix of class, interfaces, objects and cppclasses
  811. isn't allowed }
  812. case classtype of
  813. odt_class:
  814. if not(is_class(childof)) then
  815. begin
  816. if is_interface(childof) then
  817. begin
  818. { we insert the interface after the child
  819. is set, see below
  820. }
  821. hp:=childof;
  822. childof:=class_tobject;
  823. end
  824. else
  825. Message(parser_e_mix_of_classes_and_objects);
  826. end;
  827. odt_interfacecorba,
  828. odt_interfacecom:
  829. if not(is_interface(childof)) then
  830. Message(parser_e_mix_of_classes_and_objects);
  831. odt_cppclass:
  832. if not(is_cppclass(childof)) then
  833. Message(parser_e_mix_of_classes_and_objects);
  834. odt_object:
  835. if not(is_object(childof)) then
  836. Message(parser_e_mix_of_classes_and_objects);
  837. end;
  838. { the forward of the child must be resolved to get
  839. correct field addresses }
  840. if assigned(fd) then
  841. begin
  842. if (oo_is_forward in childof.objectoptions) then
  843. Message1(parser_e_forward_declaration_must_be_resolved,childof.objrealname^);
  844. aktclass:=fd;
  845. { we must inherit several options !!
  846. this was missing !!
  847. all is now done in set_parent
  848. including symtable datasize setting PM }
  849. fd.set_parent(childof);
  850. end
  851. else
  852. aktclass:=tobjectdef.create(classtype,n,childof);
  853. if aktclass.objecttype=odt_class then
  854. begin
  855. if assigned(hp) then
  856. handleimplementedinterface(hp);
  857. readimplementedinterfaces;
  858. end;
  859. end;
  860. consume(_RKLAMMER);
  861. end
  862. { if no parent class, then a class get tobject as parent }
  863. else if classtype in [odt_class,odt_interfacecom] then
  864. setclassparent
  865. else
  866. aktclass:=tobjectdef.create(classtype,n,nil);
  867. { read GUID }
  868. if (classtype in [odt_interfacecom,odt_interfacecorba]) and
  869. try_to_consume(_LECKKLAMMER) then
  870. begin
  871. readinterfaceiid;
  872. consume(_RECKKLAMMER);
  873. end;
  874. end;
  875. procedure chkcpp(pd:tprocdef);
  876. begin
  877. if is_cppclass(pd._class) then
  878. begin
  879. pd.proccalloption:=pocall_cppdecl;
  880. pd.setmangledname(target_info.Cprefix+pd.cplusplusmangledname);
  881. end;
  882. end;
  883. var
  884. pd : tprocdef;
  885. begin
  886. old_object_option:=current_object_option;
  887. { forward is resolved }
  888. if assigned(fd) then
  889. exclude(fd.objectoptions,oo_is_forward);
  890. { objects and class types can't be declared local }
  891. if not(symtablestack.symtabletype in [globalsymtable,staticsymtable]) then
  892. Message(parser_e_no_local_objects);
  893. storetypecanbeforward:=typecanbeforward;
  894. { for tp7 don't allow forward types }
  895. if (m_tp7 in aktmodeswitches) then
  896. typecanbeforward:=false;
  897. if not(readobjecttype) then
  898. exit;
  899. { also anonym objects aren't allow (o : object a : longint; end;) }
  900. if n='' then
  901. Message(parser_f_no_anonym_objects);
  902. { read list of parent classes }
  903. readparentclasses;
  904. { default access is public }
  905. there_is_a_destructor:=false;
  906. current_object_option:=[sp_public];
  907. { set class flags and inherits published }
  908. setclassattributes;
  909. aktobjectdef:=aktclass;
  910. aktclass.symtable.next:=symtablestack;
  911. symtablestack:=aktclass.symtable;
  912. testcurobject:=1;
  913. curobjectname:=Upper(n);
  914. { short class declaration ? }
  915. if (classtype<>odt_class) or (token<>_SEMICOLON) then
  916. begin
  917. { Parse componenten }
  918. repeat
  919. case token of
  920. _ID :
  921. begin
  922. case idtoken of
  923. _PRIVATE :
  924. begin
  925. if is_interface(aktclass) then
  926. Message(parser_e_no_access_specifier_in_interfaces);
  927. consume(_PRIVATE);
  928. current_object_option:=[sp_private];
  929. include(aktclass.objectoptions,oo_has_private);
  930. end;
  931. _PROTECTED :
  932. begin
  933. if is_interface(aktclass) then
  934. Message(parser_e_no_access_specifier_in_interfaces);
  935. consume(_PROTECTED);
  936. current_object_option:=[sp_protected];
  937. include(aktclass.objectoptions,oo_has_protected);
  938. end;
  939. _PUBLIC :
  940. begin
  941. if is_interface(aktclass) then
  942. Message(parser_e_no_access_specifier_in_interfaces);
  943. consume(_PUBLIC);
  944. current_object_option:=[sp_public];
  945. end;
  946. _PUBLISHED :
  947. begin
  948. { we've to check for a pushlished section in non- }
  949. { publishable classes later, if a real declaration }
  950. { this is the way, delphi does it }
  951. if is_interface(aktclass) then
  952. Message(parser_e_no_access_specifier_in_interfaces);
  953. consume(_PUBLISHED);
  954. current_object_option:=[sp_published];
  955. end;
  956. else
  957. begin
  958. if is_interface(aktclass) then
  959. Message(parser_e_no_vars_in_interfaces);
  960. if (sp_published in current_object_option) and
  961. not(oo_can_have_published in aktclass.objectoptions) then
  962. Message(parser_e_cant_have_published);
  963. read_var_decs(false,true,false);
  964. end;
  965. end;
  966. end;
  967. _PROPERTY :
  968. begin
  969. property_dec;
  970. end;
  971. _PROCEDURE,
  972. _FUNCTION,
  973. _CLASS :
  974. begin
  975. if (sp_published in current_object_option) and
  976. not(oo_can_have_published in aktclass.objectoptions) then
  977. Message(parser_e_cant_have_published);
  978. oldparse_only:=parse_only;
  979. parse_only:=true;
  980. pd:=parse_proc_dec(aktclass);
  981. { this is for error recovery as well as forward }
  982. { interface mappings, i.e. mapping to a method }
  983. { which isn't declared yet }
  984. if assigned(pd) then
  985. begin
  986. parse_object_proc_directives(pd);
  987. handle_calling_convention(pd);
  988. calc_parast(pd);
  989. { add definition to procsym }
  990. proc_add_definition(pd);
  991. { add procdef options to objectdef options }
  992. if (po_msgint in pd.procoptions) then
  993. include(aktclass.objectoptions,oo_has_msgint);
  994. if (po_msgstr in pd.procoptions) then
  995. include(aktclass.objectoptions,oo_has_msgstr);
  996. if (po_virtualmethod in pd.procoptions) then
  997. include(aktclass.objectoptions,oo_has_virtual);
  998. chkcpp(pd);
  999. end;
  1000. parse_only:=oldparse_only;
  1001. end;
  1002. _CONSTRUCTOR :
  1003. begin
  1004. if (sp_published in current_object_option) and
  1005. not(oo_can_have_published in aktclass.objectoptions) then
  1006. Message(parser_e_cant_have_published);
  1007. if not(sp_public in current_object_option) then
  1008. Message(parser_w_constructor_should_be_public);
  1009. if is_interface(aktclass) then
  1010. Message(parser_e_no_con_des_in_interfaces);
  1011. oldparse_only:=parse_only;
  1012. parse_only:=true;
  1013. pd:=constructor_head;
  1014. parse_object_proc_directives(pd);
  1015. handle_calling_convention(pd);
  1016. calc_parast(pd);
  1017. { add definition to procsym }
  1018. proc_add_definition(pd);
  1019. { add procdef options to objectdef options }
  1020. if (po_virtualmethod in pd.procoptions) then
  1021. include(aktclass.objectoptions,oo_has_virtual);
  1022. chkcpp(pd);
  1023. parse_only:=oldparse_only;
  1024. end;
  1025. _DESTRUCTOR :
  1026. begin
  1027. if (sp_published in current_object_option) and
  1028. not(oo_can_have_published in aktclass.objectoptions) then
  1029. Message(parser_e_cant_have_published);
  1030. if there_is_a_destructor then
  1031. Message(parser_n_only_one_destructor);
  1032. if is_interface(aktclass) then
  1033. Message(parser_e_no_con_des_in_interfaces);
  1034. if not(sp_public in current_object_option) then
  1035. Message(parser_w_destructor_should_be_public);
  1036. there_is_a_destructor:=true;
  1037. oldparse_only:=parse_only;
  1038. parse_only:=true;
  1039. pd:=destructor_head;
  1040. parse_object_proc_directives(pd);
  1041. handle_calling_convention(pd);
  1042. calc_parast(pd);
  1043. { add definition to procsym }
  1044. proc_add_definition(pd);
  1045. { add procdef options to objectdef options }
  1046. if (po_virtualmethod in pd.procoptions) then
  1047. include(aktclass.objectoptions,oo_has_virtual);
  1048. chkcpp(pd);
  1049. parse_only:=oldparse_only;
  1050. end;
  1051. _END :
  1052. begin
  1053. consume(_END);
  1054. break;
  1055. end;
  1056. else
  1057. consume(_ID); { Give a ident expected message, like tp7 }
  1058. end;
  1059. until false;
  1060. end;
  1061. { generate vmt space if needed }
  1062. if not(oo_has_vmt in aktclass.objectoptions) and
  1063. (([oo_has_virtual,oo_has_constructor,oo_has_destructor]*aktclass.objectoptions<>[]) or
  1064. (classtype in [odt_class])
  1065. ) then
  1066. aktclass.insertvmt;
  1067. if is_interface(aktclass) then
  1068. setinterfacemethodoptions;
  1069. { reset }
  1070. testcurobject:=0;
  1071. curobjectname:='';
  1072. typecanbeforward:=storetypecanbeforward;
  1073. { restore old state }
  1074. symtablestack:=symtablestack.next;
  1075. aktobjectdef:=nil;
  1076. current_object_option:=old_object_option;
  1077. object_dec:=aktclass;
  1078. end;
  1079. end.
  1080. {
  1081. $Log$
  1082. Revision 1.73 2003-11-10 18:06:25 florian
  1083. + published single properties can have a default value now
  1084. Revision 1.72 2003/10/30 16:23:13 peter
  1085. * don't search for overloads in parents for constructors
  1086. Revision 1.71 2003/10/22 15:22:33 peter
  1087. * fixed unitsym-globalsymtable relation so the uses of a unit
  1088. is counted correctly
  1089. Revision 1.70 2003/10/21 18:16:13 peter
  1090. * IncompatibleTypes() added that will include unit names when
  1091. the typenames are the same
  1092. Revision 1.69 2003/10/07 16:06:30 peter
  1093. * tsymlist.def renamed to tsymlist.procdef
  1094. * tsymlist.procdef is now only used to store the procdef
  1095. Revision 1.68 2003/10/02 21:15:12 peter
  1096. * support nil as default value
  1097. * when no default property is allowed don't check default value
  1098. Revision 1.67 2003/06/13 21:19:30 peter
  1099. * current_procdef removed, use current_procinfo.procdef instead
  1100. Revision 1.66 2003/05/23 14:27:35 peter
  1101. * remove some unit dependencies
  1102. * current_procinfo changes to store more info
  1103. Revision 1.65 2003/05/09 17:47:02 peter
  1104. * self moved to hidden parameter
  1105. * removed hdisposen,hnewn,selfn
  1106. Revision 1.64 2003/05/05 14:53:16 peter
  1107. * vs_hidden replaced by is_hidden boolean
  1108. Revision 1.63 2003/04/27 11:21:33 peter
  1109. * aktprocdef renamed to current_procinfo.procdef
  1110. * procinfo renamed to current_procinfo
  1111. * procinfo will now be stored in current_module so it can be
  1112. cleaned up properly
  1113. * gen_main_procsym changed to create_main_proc and release_main_proc
  1114. to also generate a tprocinfo structure
  1115. * fixed unit implicit initfinal
  1116. Revision 1.62 2003/04/27 07:29:50 peter
  1117. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  1118. a new procdef declaration
  1119. * aktprocsym removed
  1120. * lexlevel removed, use symtable.symtablelevel instead
  1121. * implicit init/final code uses the normal genentry/genexit
  1122. * funcret state checking updated for new funcret handling
  1123. Revision 1.61 2003/04/26 00:32:37 peter
  1124. * start search for overriden properties in the parent class
  1125. Revision 1.60 2003/04/25 20:59:33 peter
  1126. * removed funcretn,funcretsym, function result is now in varsym
  1127. and aliases for result and function name are added using absolutesym
  1128. * vs_hidden parameter for funcret passed in parameter
  1129. * vs_hidden fixes
  1130. * writenode changed to printnode and released from extdebug
  1131. * -vp option added to generate a tree.log with the nodetree
  1132. * nicer printnode for statements, callnode
  1133. Revision 1.59 2003/04/10 17:57:52 peter
  1134. * vs_hidden released
  1135. Revision 1.58 2003/01/09 21:52:37 peter
  1136. * merged some verbosity options.
  1137. * V_LineInfo is a verbosity flag to include line info
  1138. Revision 1.57 2002/11/25 17:43:21 peter
  1139. * splitted defbase in defutil,symutil,defcmp
  1140. * merged isconvertable and is_equal into compare_defs(_ext)
  1141. * made operator search faster by walking the list only once
  1142. Revision 1.56 2002/11/17 16:31:56 carl
  1143. * memory optimization (3-4%) : cleanup of tai fields,
  1144. cleanup of tdef and tsym fields.
  1145. * make it work for m68k
  1146. Revision 1.55 2002/10/05 12:43:25 carl
  1147. * fixes for Delphi 6 compilation
  1148. (warning : Some features do not work under Delphi)
  1149. Revision 1.54 2002/10/02 18:20:20 peter
  1150. * don't allow interface without m_class mode
  1151. Revision 1.53 2002/09/27 21:13:28 carl
  1152. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  1153. Revision 1.52 2002/09/16 14:11:13 peter
  1154. * add argument to equal_paras() to support default values or not
  1155. Revision 1.51 2002/09/09 17:34:15 peter
  1156. * tdicationary.replace added to replace and item in a dictionary. This
  1157. is only allowed for the same name
  1158. * varsyms are inserted in symtable before the types are parsed. This
  1159. fixes the long standing "var longint : longint" bug
  1160. - consume_idlist and idstringlist removed. The loops are inserted
  1161. at the callers place and uses the symtable for duplicate id checking
  1162. Revision 1.50 2002/09/03 16:26:26 daniel
  1163. * Make Tprocdef.defs protected
  1164. Revision 1.49 2002/08/17 09:23:38 florian
  1165. * first part of procinfo rewrite
  1166. Revision 1.48 2002/08/09 07:33:02 florian
  1167. * a couple of interface related fixes
  1168. Revision 1.47 2002/07/20 11:57:55 florian
  1169. * types.pas renamed to defbase.pas because D6 contains a types
  1170. unit so this would conflicts if D6 programms are compiled
  1171. + Willamette/SSE2 instructions to assembler added
  1172. Revision 1.46 2002/07/01 16:23:53 peter
  1173. * cg64 patch
  1174. * basics for currency
  1175. * asnode updates for class and interface (not finished)
  1176. Revision 1.45 2002/05/18 13:34:12 peter
  1177. * readded missing revisions
  1178. Revision 1.44 2002/05/16 19:46:42 carl
  1179. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1180. + try to fix temp allocation (still in ifdef)
  1181. + generic constructor calls
  1182. + start of tassembler / tmodulebase class cleanup
  1183. Revision 1.42 2002/05/12 16:53:08 peter
  1184. * moved entry and exitcode to ncgutil and cgobj
  1185. * foreach gets extra argument for passing local data to the
  1186. iterator function
  1187. * -CR checks also class typecasts at runtime by changing them
  1188. into as
  1189. * fixed compiler to cycle with the -CR option
  1190. * fixed stabs with elf writer, finally the global variables can
  1191. be watched
  1192. * removed a lot of routines from cga unit and replaced them by
  1193. calls to cgobj
  1194. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1195. u32bit then the other is typecasted also to u32bit without giving
  1196. a rangecheck warning/error.
  1197. * fixed pascal calling method with reversing also the high tree in
  1198. the parast, detected by tcalcst3 test
  1199. Revision 1.41 2002/04/21 19:02:04 peter
  1200. * removed newn and disposen nodes, the code is now directly
  1201. inlined from pexpr
  1202. * -an option that will write the secondpass nodes to the .s file, this
  1203. requires EXTDEBUG define to actually write the info
  1204. * fixed various internal errors and crashes due recent code changes
  1205. Revision 1.40 2002/04/19 15:46:02 peter
  1206. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  1207. in most cases and not written to the ppu
  1208. * add mangeledname_prefix() routine to generate the prefix of
  1209. manglednames depending on the current procedure, object and module
  1210. * removed static procprefix since the mangledname is now build only
  1211. on demand from tprocdef.mangledname
  1212. Revision 1.39 2002/04/04 19:06:00 peter
  1213. * removed unused units
  1214. * use tlocation.size in cg.a_*loc*() routines
  1215. Revision 1.38 2002/01/25 17:38:19 peter
  1216. * fixed default value for properties with index values
  1217. Revision 1.37 2002/01/24 18:25:48 peter
  1218. * implicit result variable generation for assembler routines
  1219. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1220. Revision 1.36 2002/01/06 12:08:15 peter
  1221. * removed uauto from orddef, use new range_to_basetype generating
  1222. the correct ordinal type for a range
  1223. }