pstatmnt.pas 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Does the parsing of the statements
  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. {$ifdef FPC}
  19. {$goto on}
  20. {$endif FPC}
  21. unit pstatmnt;
  22. interface
  23. uses tree;
  24. { reads a block }
  25. function block(islibrary : boolean) : ptree;
  26. { reads an assembler block }
  27. function assembler_block : ptree;
  28. implementation
  29. uses
  30. globtype,systems,tokens,
  31. strings,cobjects,globals,files,verbose,
  32. symconst,symtable,aasm,pass_1,types,scanner,
  33. {$ifdef newcg}
  34. cgbase,
  35. {$else}
  36. hcodegen,
  37. {$endif}
  38. ppu
  39. ,pbase,pexpr,pdecl,cpubase,cpuasm
  40. {$ifdef i386}
  41. ,tgeni386
  42. {$ifndef NoRa386Int}
  43. ,ra386int
  44. {$endif NoRa386Int}
  45. {$ifndef NoRa386Att}
  46. ,ra386att
  47. {$endif NoRa386Att}
  48. {$ifndef NoRa386Dir}
  49. ,ra386dir
  50. {$endif NoRa386Dir}
  51. {$endif i386}
  52. {$ifdef m68k}
  53. ,tgen68k
  54. {$ifndef NoRa68kMot}
  55. ,ra68kmot
  56. {$endif NoRa68kMot}
  57. {$endif m68k}
  58. {$ifdef alpha}
  59. ,tgeni386 { this is a dummy!! }
  60. {$endif alpha}
  61. {$ifdef powerpc}
  62. ,tgeni386 { this is a dummy!! }
  63. {$endif powerpc}
  64. ;
  65. const
  66. statement_level : longint = 0;
  67. function statement : ptree;forward;
  68. function if_statement : ptree;
  69. var
  70. ex,if_a,else_a : ptree;
  71. begin
  72. consume(_IF);
  73. ex:=comp_expr(true);
  74. consume(_THEN);
  75. if token<>_ELSE then
  76. if_a:=statement
  77. else
  78. if_a:=nil;
  79. if try_to_consume(_ELSE) then
  80. else_a:=statement
  81. else
  82. else_a:=nil;
  83. if_statement:=genloopnode(ifn,ex,if_a,else_a,false);
  84. end;
  85. { creates a block (list) of statements, til the next END token }
  86. function statements_til_end : ptree;
  87. var
  88. first,last : ptree;
  89. begin
  90. first:=nil;
  91. while token<>_END do
  92. begin
  93. if first=nil then
  94. begin
  95. last:=gennode(statementn,nil,statement);
  96. first:=last;
  97. end
  98. else
  99. begin
  100. last^.left:=gennode(statementn,nil,statement);
  101. last:=last^.left;
  102. end;
  103. if not try_to_consume(_SEMICOLON) then
  104. break;
  105. emptystats;
  106. end;
  107. consume(_END);
  108. statements_til_end:=gensinglenode(blockn,first);
  109. end;
  110. function case_statement : ptree;
  111. var
  112. { contains the label number of currently parsed case block }
  113. aktcaselabel : pasmlabel;
  114. firstlabel : boolean;
  115. root : pcaserecord;
  116. { the typ of the case expression }
  117. casedef : pdef;
  118. procedure newcaselabel(l,h : longint;first:boolean);
  119. var
  120. hcaselabel : pcaserecord;
  121. procedure insertlabel(var p : pcaserecord);
  122. begin
  123. if p=nil then p:=hcaselabel
  124. else
  125. if (p^._low>hcaselabel^._low) and
  126. (p^._low>hcaselabel^._high) then
  127. if (hcaselabel^.statement = p^.statement) and
  128. (p^._low = hcaselabel^._high + 1) then
  129. begin
  130. p^._low := hcaselabel^._low;
  131. dispose(hcaselabel);
  132. end
  133. else
  134. insertlabel(p^.less)
  135. else
  136. if (p^._high<hcaselabel^._low) and
  137. (p^._high<hcaselabel^._high) then
  138. if (hcaselabel^.statement = p^.statement) and
  139. (p^._high+1 = hcaselabel^._low) then
  140. begin
  141. p^._high := hcaselabel^._high;
  142. dispose(hcaselabel);
  143. end
  144. else
  145. insertlabel(p^.greater)
  146. else Message(parser_e_double_caselabel);
  147. end;
  148. begin
  149. new(hcaselabel);
  150. hcaselabel^.less:=nil;
  151. hcaselabel^.greater:=nil;
  152. hcaselabel^.statement:=aktcaselabel;
  153. hcaselabel^.firstlabel:=first;
  154. getlabel(hcaselabel^._at);
  155. hcaselabel^._low:=l;
  156. hcaselabel^._high:=h;
  157. insertlabel(root);
  158. end;
  159. var
  160. code,caseexpr,p,instruc,elseblock : ptree;
  161. hl1,hl2 : longint;
  162. casedeferror : boolean;
  163. begin
  164. consume(_CASE);
  165. caseexpr:=comp_expr(true);
  166. { determines result type }
  167. cleartempgen;
  168. do_firstpass(caseexpr);
  169. casedeferror:=false;
  170. casedef:=caseexpr^.resulttype;
  171. if (not assigned(casedef)) or
  172. not(is_ordinal(casedef) or is_64bitint(casedef)) then
  173. begin
  174. Message(type_e_ordinal_expr_expected);
  175. { set error flag so no rangechecks are done }
  176. casedeferror:=true;
  177. end;
  178. consume(_OF);
  179. inc(statement_level);
  180. root:=nil;
  181. instruc:=nil;
  182. repeat
  183. getlabel(aktcaselabel);
  184. firstlabel:=true;
  185. { may be an instruction has more case labels }
  186. repeat
  187. p:=expr;
  188. cleartempgen;
  189. do_firstpass(p);
  190. hl1:=0;
  191. hl2:=0;
  192. if (p^.treetype=rangen) then
  193. begin
  194. { type checking for case statements }
  195. if is_subequal(casedef, p^.left^.resulttype) and
  196. is_subequal(casedef, p^.right^.resulttype) then
  197. begin
  198. hl1:=get_ordinal_value(p^.left);
  199. hl2:=get_ordinal_value(p^.right);
  200. if hl1>hl2 then
  201. Message(parser_e_case_lower_less_than_upper_bound);
  202. if not casedeferror then
  203. begin
  204. testrange(casedef,hl1);
  205. testrange(casedef,hl2);
  206. end;
  207. end
  208. else
  209. Message(parser_e_case_mismatch);
  210. newcaselabel(hl1,hl2,firstlabel);
  211. end
  212. else
  213. begin
  214. { type checking for case statements }
  215. if not is_subequal(casedef, p^.resulttype) then
  216. Message(parser_e_case_mismatch);
  217. hl1:=get_ordinal_value(p);
  218. if not casedeferror then
  219. testrange(casedef,hl1);
  220. newcaselabel(hl1,hl1,firstlabel);
  221. end;
  222. disposetree(p);
  223. if token=_COMMA then
  224. consume(_COMMA)
  225. else
  226. break;
  227. firstlabel:=false;
  228. until false;
  229. consume(_COLON);
  230. { handles instruction block }
  231. p:=gensinglenode(labeln,statement);
  232. p^.labelnr:=aktcaselabel;
  233. { concats instruction }
  234. instruc:=gennode(statementn,instruc,p);
  235. if not((token=_ELSE) or (token=_OTHERWISE) or (token=_END)) then
  236. consume(_SEMICOLON);
  237. until (token=_ELSE) or (token=_OTHERWISE) or (token=_END);
  238. if (token=_ELSE) or (token=_OTHERWISE) then
  239. begin
  240. if not try_to_consume(_ELSE) then
  241. consume(_OTHERWISE);
  242. elseblock:=statements_til_end;
  243. end
  244. else
  245. begin
  246. elseblock:=nil;
  247. consume(_END);
  248. end;
  249. dec(statement_level);
  250. code:=gencasenode(caseexpr,instruc,root);
  251. code^.elseblock:=elseblock;
  252. case_statement:=code;
  253. end;
  254. function repeat_statement : ptree;
  255. var
  256. first,last,p_e : ptree;
  257. begin
  258. consume(_REPEAT);
  259. first:=nil;
  260. inc(statement_level);
  261. while token<>_UNTIL do
  262. begin
  263. if first=nil then
  264. begin
  265. last:=gennode(statementn,nil,statement);
  266. first:=last;
  267. end
  268. else
  269. begin
  270. last^.left:=gennode(statementn,nil,statement);
  271. last:=last^.left;
  272. end;
  273. if not try_to_consume(_SEMICOLON) then
  274. break;
  275. emptystats;
  276. end;
  277. consume(_UNTIL);
  278. dec(statement_level);
  279. first:=gensinglenode(blockn,first);
  280. p_e:=comp_expr(true);
  281. repeat_statement:=genloopnode(repeatn,p_e,first,nil,false);
  282. end;
  283. function while_statement : ptree;
  284. var
  285. p_e,p_a : ptree;
  286. begin
  287. consume(_WHILE);
  288. p_e:=comp_expr(true);
  289. consume(_DO);
  290. p_a:=statement;
  291. while_statement:=genloopnode(whilen,p_e,p_a,nil,false);
  292. end;
  293. function for_statement : ptree;
  294. var
  295. p_e,tovalue,p_a : ptree;
  296. backward : boolean;
  297. begin
  298. { parse loop header }
  299. consume(_FOR);
  300. p_e:=expr;
  301. if token=_DOWNTO then
  302. begin
  303. consume(_DOWNTO);
  304. backward:=true;
  305. end
  306. else
  307. begin
  308. consume(_TO);
  309. backward:=false;
  310. end;
  311. tovalue:=comp_expr(true);
  312. consume(_DO);
  313. { ... now the instruction }
  314. p_a:=statement;
  315. for_statement:=genloopnode(forn,p_e,tovalue,p_a,backward);
  316. end;
  317. function _with_statement : ptree;
  318. var
  319. right,p : ptree;
  320. i,levelcount : longint;
  321. withsymtable,symtab : psymtable;
  322. obj : pobjectdef;
  323. {$ifdef tp}
  324. hp : ptree;
  325. {$endif}
  326. begin
  327. p:=comp_expr(true);
  328. do_firstpass(p);
  329. set_varstate(p,false);
  330. right:=nil;
  331. if (not codegenerror) and
  332. (p^.resulttype^.deftype in [objectdef,recorddef]) then
  333. begin
  334. case p^.resulttype^.deftype of
  335. objectdef : begin
  336. obj:=pobjectdef(p^.resulttype);
  337. withsymtable:=new(pwithsymtable,init);
  338. withsymtable^.symsearch:=obj^.symtable^.symsearch;
  339. withsymtable^.defowner:=obj;
  340. symtab:=withsymtable;
  341. if (p^.treetype=loadn) and
  342. (p^.symtable=aktprocsym^.definition^.localst) then
  343. pwithsymtable(symtab)^.direct_with:=true;
  344. {symtab^.withnode:=p; not yet allocated !! }
  345. pwithsymtable(symtab)^.withrefnode:=p;
  346. levelcount:=1;
  347. obj:=obj^.childof;
  348. while assigned(obj) do
  349. begin
  350. symtab^.next:=new(pwithsymtable,init);
  351. symtab:=symtab^.next;
  352. symtab^.symsearch:=obj^.symtable^.symsearch;
  353. if (p^.treetype=loadn) and
  354. (p^.symtable=aktprocsym^.definition^.localst) then
  355. pwithsymtable(symtab)^.direct_with:=true;
  356. {symtab^.withnode:=p; not yet allocated !! }
  357. pwithsymtable(symtab)^.withrefnode:=p;
  358. symtab^.defowner:=obj;
  359. obj:=obj^.childof;
  360. inc(levelcount);
  361. end;
  362. symtab^.next:=symtablestack;
  363. symtablestack:=withsymtable;
  364. end;
  365. recorddef : begin
  366. symtab:=precorddef(p^.resulttype)^.symtable;
  367. levelcount:=1;
  368. withsymtable:=new(pwithsymtable,init);
  369. withsymtable^.symsearch:=symtab^.symsearch;
  370. withsymtable^.next:=symtablestack;
  371. if (p^.treetype=loadn) and
  372. (p^.symtable=aktprocsym^.definition^.localst) then
  373. pwithsymtable(withsymtable)^.direct_with:=true;
  374. {symtab^.withnode:=p; not yet allocated !! }
  375. pwithsymtable(withsymtable)^.withrefnode:=p;
  376. withsymtable^.defowner:=obj;
  377. symtablestack:=withsymtable;
  378. end;
  379. end;
  380. if token=_COMMA then
  381. begin
  382. consume(_COMMA);
  383. right:=_with_statement{$ifndef tp}(){$endif};
  384. end
  385. else
  386. begin
  387. consume(_DO);
  388. if token<>_SEMICOLON then
  389. right:=statement
  390. else
  391. right:=nil;
  392. end;
  393. for i:=1 to levelcount do
  394. symtablestack:=symtablestack^.next;
  395. _with_statement:=genwithnode(pwithsymtable(withsymtable),p,right,levelcount);
  396. end
  397. else
  398. begin
  399. Message(parser_e_false_with_expr);
  400. { try to recover from error }
  401. if token=_COMMA then
  402. begin
  403. consume(_COMMA);
  404. {$ifdef tp}
  405. hp:=_with_statement;
  406. {$else}
  407. _with_statement();
  408. {$endif}
  409. end
  410. else
  411. begin
  412. consume(_DO);
  413. { ignore all }
  414. if token<>_SEMICOLON then
  415. statement;
  416. end;
  417. _with_statement:=nil;
  418. end;
  419. end;
  420. function with_statement : ptree;
  421. begin
  422. consume(_WITH);
  423. with_statement:=_with_statement;
  424. end;
  425. function raise_statement : ptree;
  426. var
  427. p,pobj,paddr,pframe : ptree;
  428. begin
  429. pobj:=nil;
  430. paddr:=nil;
  431. pframe:=nil;
  432. consume(_RAISE);
  433. if not(token in [_SEMICOLON,_END]) then
  434. begin
  435. { object }
  436. pobj:=comp_expr(true);
  437. if try_to_consume(_AT) then
  438. begin
  439. paddr:=comp_expr(true);
  440. if try_to_consume(_COMMA) then
  441. pframe:=comp_expr(true);
  442. end;
  443. end
  444. else
  445. begin
  446. if (block_type<>bt_except) then
  447. Message(parser_e_no_reraise_possible);
  448. end;
  449. p:=gennode(raisen,pobj,paddr);
  450. p^.frametree:=pframe;
  451. raise_statement:=p;
  452. end;
  453. function try_statement : ptree;
  454. var
  455. p_try_block,p_finally_block,first,last,
  456. p_default,p_specific,hp : ptree;
  457. ot : pobjectdef;
  458. sym : pvarsym;
  459. old_block_type : tblock_type;
  460. exceptsymtable : psymtable;
  461. objname : stringid;
  462. begin
  463. procinfo^.flags:=procinfo^.flags or
  464. pi_uses_exceptions;
  465. p_default:=nil;
  466. p_specific:=nil;
  467. { read statements to try }
  468. consume(_TRY);
  469. first:=nil;
  470. inc(statement_level);
  471. while (token<>_FINALLY) and (token<>_EXCEPT) do
  472. begin
  473. if first=nil then
  474. begin
  475. last:=gennode(statementn,nil,statement);
  476. first:=last;
  477. end
  478. else
  479. begin
  480. last^.left:=gennode(statementn,nil,statement);
  481. last:=last^.left;
  482. end;
  483. if not try_to_consume(_SEMICOLON) then
  484. break;
  485. emptystats;
  486. end;
  487. p_try_block:=gensinglenode(blockn,first);
  488. if try_to_consume(_FINALLY) then
  489. begin
  490. p_finally_block:=statements_til_end;
  491. try_statement:=gennode(tryfinallyn,p_try_block,p_finally_block);
  492. dec(statement_level);
  493. end
  494. else
  495. begin
  496. consume(_EXCEPT);
  497. old_block_type:=block_type;
  498. block_type:=bt_except;
  499. p_specific:=nil;
  500. if token=_ON then
  501. { catch specific exceptions }
  502. begin
  503. repeat
  504. consume(_ON);
  505. if token=_ID then
  506. begin
  507. objname:=pattern;
  508. getsym(objname,false);
  509. consume(_ID);
  510. { is a explicit name for the exception given ? }
  511. if try_to_consume(_COLON) then
  512. begin
  513. getsym(pattern,true);
  514. consume(_ID);
  515. if srsym^.typ=unitsym then
  516. begin
  517. consume(_POINT);
  518. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  519. consume(_ID);
  520. end;
  521. if (srsym^.typ=typesym) and
  522. (ptypesym(srsym)^.restype.def^.deftype=objectdef) and
  523. pobjectdef(ptypesym(srsym)^.restype.def)^.is_class then
  524. begin
  525. ot:=pobjectdef(ptypesym(srsym)^.restype.def);
  526. sym:=new(pvarsym,initdef(objname,ot));
  527. end
  528. else
  529. begin
  530. sym:=new(pvarsym,initdef(objname,new(perrordef,init)));
  531. if (srsym^.typ=typesym) then
  532. Message1(type_e_class_type_expected,ptypesym(srsym)^.restype.def^.typename)
  533. else
  534. Message1(type_e_class_type_expected,ot^.typename);
  535. end;
  536. exceptsymtable:=new(psymtable,init(stt_exceptsymtable));
  537. exceptsymtable^.insert(sym);
  538. { insert the exception symtable stack }
  539. exceptsymtable^.next:=symtablestack;
  540. symtablestack:=exceptsymtable;
  541. end
  542. else
  543. begin
  544. { check if type is valid, must be done here because
  545. with "e: Exception" the e is not necessary }
  546. if srsym=nil then
  547. begin
  548. Message1(sym_e_id_not_found,objname);
  549. srsym:=generrorsym;
  550. end;
  551. { only exception type }
  552. if srsym^.typ=unitsym then
  553. begin
  554. consume(_POINT);
  555. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  556. consume(_ID);
  557. end;
  558. if (srsym^.typ=typesym) and
  559. (ptypesym(srsym)^.restype.def^.deftype=objectdef) and
  560. pobjectdef(ptypesym(srsym)^.restype.def)^.is_class then
  561. ot:=pobjectdef(ptypesym(srsym)^.restype.def)
  562. else
  563. begin
  564. ot:=pobjectdef(generrordef);
  565. if (srsym^.typ=typesym) then
  566. Message1(type_e_class_type_expected,ptypesym(srsym)^.restype.def^.typename)
  567. else
  568. Message1(type_e_class_type_expected,ot^.typename);
  569. end;
  570. exceptsymtable:=nil;
  571. end;
  572. end
  573. else
  574. consume(_ID);
  575. consume(_DO);
  576. hp:=gennode(onn,nil,statement);
  577. if ot^.deftype=errordef then
  578. begin
  579. disposetree(hp);
  580. hp:=genzeronode(errorn);
  581. end;
  582. if p_specific=nil then
  583. begin
  584. last:=hp;
  585. p_specific:=last;
  586. end
  587. else
  588. begin
  589. last^.left:=hp;
  590. last:=last^.left;
  591. end;
  592. { set the informations }
  593. last^.excepttype:=ot;
  594. last^.exceptsymtable:=exceptsymtable;
  595. last^.disposetyp:=dt_onn;
  596. { remove exception symtable }
  597. if assigned(exceptsymtable) then
  598. dellexlevel;
  599. if not try_to_consume(_SEMICOLON) then
  600. break;
  601. emptystats;
  602. until (token=_END) or(token=_ELSE);
  603. if token=_ELSE then
  604. { catch the other exceptions }
  605. begin
  606. consume(_ELSE);
  607. p_default:=statements_til_end;
  608. end
  609. else
  610. consume(_END);
  611. end
  612. else
  613. { catch all exceptions }
  614. begin
  615. p_default:=statements_til_end;
  616. end;
  617. dec(statement_level);
  618. block_type:=old_block_type;
  619. try_statement:=genloopnode(tryexceptn,p_try_block,p_specific,p_default,false);
  620. end;
  621. end;
  622. function exit_statement : ptree;
  623. var
  624. p : ptree;
  625. begin
  626. consume(_EXIT);
  627. if try_to_consume(_LKLAMMER) then
  628. begin
  629. p:=comp_expr(true);
  630. consume(_RKLAMMER);
  631. if (block_type=bt_except) then
  632. Message(parser_e_exit_with_argument_not__possible);
  633. if procinfo^.returntype.def=pdef(voiddef) then
  634. Message(parser_e_void_function);
  635. end
  636. else
  637. p:=nil;
  638. p:=gensinglenode(exitn,p);
  639. p^.resulttype:=procinfo^.returntype.def;
  640. exit_statement:=p;
  641. end;
  642. function _asm_statement : ptree;
  643. var
  644. asmstat : ptree;
  645. Marker : Pai;
  646. begin
  647. Inside_asm_statement:=true;
  648. case aktasmmode of
  649. asmmode_none : ; { just be there to allow to a compile without
  650. any assembler readers }
  651. {$ifdef i386}
  652. {$ifndef NoRA386Att}
  653. asmmode_i386_att:
  654. asmstat:=ra386att.assemble;
  655. {$endif NoRA386Att}
  656. {$ifndef NoRA386Int}
  657. asmmode_i386_intel:
  658. asmstat:=ra386int.assemble;
  659. {$endif NoRA386Int}
  660. {$ifndef NoRA386Dir}
  661. asmmode_i386_direct:
  662. begin
  663. if not target_asm.allowdirect then
  664. Message(parser_f_direct_assembler_not_allowed);
  665. if (pocall_inline in aktprocsym^.definition^.proccalloptions) then
  666. Begin
  667. Message1(parser_w_not_supported_for_inline,'direct asm');
  668. Message(parser_w_inlining_disabled);
  669. {$ifdef INCLUDEOK}
  670. exclude(aktprocsym^.definition^.proccalloptions,pocall_inline);
  671. {$else}
  672. aktprocsym^.definition^.proccalloptions:=aktprocsym^.definition^.proccalloptions-[pocall_inline];
  673. {$endif}
  674. End;
  675. asmstat:=ra386dir.assemble;
  676. end;
  677. {$endif NoRA386Dir}
  678. {$endif}
  679. {$ifdef m68k}
  680. {$ifndef NoRA68kMot}
  681. asmmode_m68k_mot:
  682. asmstat:=ra68kmot.assemble;
  683. {$endif NoRA68kMot}
  684. {$endif}
  685. else
  686. Message(parser_f_assembler_reader_not_supported);
  687. end;
  688. { Read first the _ASM statement }
  689. consume(_ASM);
  690. {$ifndef newcg}
  691. { END is read }
  692. if try_to_consume(_LECKKLAMMER) then
  693. begin
  694. { it's possible to specify the modified registers }
  695. asmstat^.object_preserved:=true;
  696. if token<>_RECKKLAMMER then
  697. repeat
  698. { uppercase, because it's a CSTRING }
  699. uppervar(pattern);
  700. {$ifdef i386}
  701. if pattern='EAX' then
  702. usedinproc:=usedinproc or ($80 shr byte(R_EAX))
  703. else if pattern='EBX' then
  704. usedinproc:=usedinproc or ($80 shr byte(R_EBX))
  705. else if pattern='ECX' then
  706. usedinproc:=usedinproc or ($80 shr byte(R_ECX))
  707. else if pattern='EDX' then
  708. usedinproc:=usedinproc or ($80 shr byte(R_EDX))
  709. else if pattern='ESI' then
  710. begin
  711. usedinproc:=usedinproc or ($80 shr byte(R_ESI));
  712. asmstat^.object_preserved:=false;
  713. end
  714. else if pattern='EDI' then
  715. usedinproc:=usedinproc or ($80 shr byte(R_EDI))
  716. {$endif i386}
  717. {$ifdef m68k}
  718. if pattern='D0' then
  719. usedinproc:=usedinproc or ($800 shr word(R_D0))
  720. else if pattern='D1' then
  721. usedinproc:=usedinproc or ($800 shr word(R_D1))
  722. else if pattern='D6' then
  723. usedinproc:=usedinproc or ($800 shr word(R_D6))
  724. else if pattern='A0' then
  725. usedinproc:=usedinproc or ($800 shr word(R_A0))
  726. else if pattern='A1' then
  727. usedinproc:=usedinproc or ($800 shr word(R_A1))
  728. {$endif m68k}
  729. else consume(_RECKKLAMMER);
  730. consume(_CSTRING);
  731. if not try_to_consume(_COMMA) then
  732. break;
  733. until false;
  734. consume(_RECKKLAMMER);
  735. end
  736. else usedinproc:=$ff;
  737. {$endif newcg}
  738. { mark the start and the end of the assembler block for the optimizer }
  739. If Assigned(AsmStat^.p_asm) Then
  740. Begin
  741. Marker := New(Pai_Marker, Init(AsmBlockStart));
  742. AsmStat^.p_asm^.Insert(Marker);
  743. Marker := New(Pai_Marker, Init(AsmBlockEnd));
  744. AsmStat^.p_asm^.Concat(Marker);
  745. End;
  746. Inside_asm_statement:=false;
  747. _asm_statement:=asmstat;
  748. end;
  749. function new_dispose_statement : ptree;
  750. var
  751. p,p2 : ptree;
  752. ht : ttoken;
  753. again : boolean; { dummy for do_proc_call }
  754. destructorname : stringid;
  755. sym : psym;
  756. classh : pobjectdef;
  757. pd,pd2 : pdef;
  758. destructorpos,storepos : tfileposinfo;
  759. tt : ttreetyp;
  760. begin
  761. ht:=token;
  762. if try_to_consume(_NEW) then
  763. tt:=hnewn
  764. else
  765. begin
  766. consume(_DISPOSE);
  767. tt:=hdisposen;
  768. end;
  769. consume(_LKLAMMER);
  770. p:=comp_expr(true);
  771. { calc return type }
  772. cleartempgen;
  773. do_firstpass(p);
  774. set_varstate(p,tt=hdisposen);
  775. {var o:Pobject;
  776. begin
  777. new(o,init); (*Also a valid new statement*)
  778. end;}
  779. if try_to_consume(_COMMA) then
  780. begin
  781. { extended syntax of new and dispose }
  782. { function styled new is handled in factor }
  783. { destructors have no parameters }
  784. destructorname:=pattern;
  785. destructorpos:=tokenpos;
  786. consume(_ID);
  787. pd:=p^.resulttype;
  788. if pd=nil then
  789. pd:=generrordef;
  790. pd2:=pd;
  791. if (pd^.deftype<>pointerdef) then
  792. begin
  793. Message1(type_e_pointer_type_expected,pd^.typename);
  794. p:=factor(false);
  795. consume(_RKLAMMER);
  796. new_dispose_statement:=genzeronode(errorn);
  797. exit;
  798. end;
  799. { first parameter must be an object or class }
  800. if ppointerdef(pd)^.pointertype.def^.deftype<>objectdef then
  801. begin
  802. Message(parser_e_pointer_to_class_expected);
  803. new_dispose_statement:=factor(false);
  804. consume_all_until(_RKLAMMER);
  805. consume(_RKLAMMER);
  806. exit;
  807. end;
  808. { check, if the first parameter is a pointer to a _class_ }
  809. classh:=pobjectdef(ppointerdef(pd)^.pointertype.def);
  810. if classh^.is_class then
  811. begin
  812. Message(parser_e_no_new_or_dispose_for_classes);
  813. new_dispose_statement:=factor(false);
  814. consume_all_until(_RKLAMMER);
  815. consume(_RKLAMMER);
  816. exit;
  817. end;
  818. { search cons-/destructor, also in parent classes }
  819. storepos:=tokenpos;
  820. tokenpos:=destructorpos;
  821. sym:=search_class_member(classh,destructorname);
  822. tokenpos:=storepos;
  823. { the second parameter of new/dispose must be a call }
  824. { to a cons-/destructor }
  825. if (not assigned(sym)) or (sym^.typ<>procsym) then
  826. begin
  827. if tt=hnewn then
  828. Message(parser_e_expr_have_to_be_constructor_call)
  829. else
  830. Message(parser_e_expr_have_to_be_destructor_call);
  831. new_dispose_statement:=genzeronode(errorn);
  832. end
  833. else
  834. begin
  835. p2:=gensinglenode(tt,p);
  836. if ht=_NEW then
  837. begin
  838. { Constructors can take parameters.}
  839. p2^.resulttype:=ppointerdef(pd)^.pointertype.def;
  840. do_member_read(false,sym,p2,pd,again);
  841. end
  842. else
  843. begin
  844. if (m_tp in aktmodeswitches) then
  845. begin
  846. { Constructors can take parameters.}
  847. p2^.resulttype:=ppointerdef(pd)^.pointertype.def;
  848. do_member_read(false,sym,p2,pd,again);
  849. end
  850. else
  851. begin
  852. p2:=genmethodcallnode(pprocsym(sym),srsymtable,p2);
  853. { support dispose(p,done()); }
  854. if try_to_consume(_LKLAMMER) then
  855. begin
  856. if not try_to_consume(_RKLAMMER) then
  857. begin
  858. Message(parser_e_no_paras_for_destructor);
  859. consume_all_until(_RKLAMMER);
  860. consume(_RKLAMMER);
  861. end;
  862. end;
  863. end;
  864. end;
  865. { we need the real called method }
  866. cleartempgen;
  867. do_firstpass(p2);
  868. if not codegenerror then
  869. begin
  870. if (ht=_NEW) and (p2^.procdefinition^.proctypeoption<>potype_constructor) then
  871. Message(parser_e_expr_have_to_be_constructor_call);
  872. if (ht=_DISPOSE) and (p2^.procdefinition^.proctypeoption<>potype_destructor) then
  873. Message(parser_e_expr_have_to_be_destructor_call);
  874. if ht=_NEW then
  875. begin
  876. p2:=gennode(assignn,getcopy(p),gensinglenode(newn,p2));
  877. p2^.right^.resulttype:=pd2;
  878. end;
  879. end;
  880. new_dispose_statement:=p2;
  881. end;
  882. end
  883. else
  884. begin
  885. if p^.resulttype=nil then
  886. p^.resulttype:=generrordef;
  887. if (p^.resulttype^.deftype<>pointerdef) then
  888. Begin
  889. Message1(type_e_pointer_type_expected,p^.resulttype^.typename);
  890. new_dispose_statement:=genzeronode(errorn);
  891. end
  892. else
  893. begin
  894. if (ppointerdef(p^.resulttype)^.pointertype.def^.deftype=objectdef) and
  895. (oo_has_vmt in pobjectdef(ppointerdef(p^.resulttype)^.pointertype.def)^.objectoptions) then
  896. Message(parser_w_use_extended_syntax_for_objects);
  897. if (ppointerdef(p^.resulttype)^.pointertype.def^.deftype=orddef) and
  898. (porddef(ppointerdef(p^.resulttype)^.pointertype.def)^.typ=uvoid) then
  899. if (m_tp in aktmodeswitches) or
  900. (m_delphi in aktmodeswitches) then
  901. Message(parser_w_no_new_dispose_on_void_pointers)
  902. else
  903. Message(parser_e_no_new_dispose_on_void_pointers);
  904. case ht of
  905. _NEW : new_dispose_statement:=gensinglenode(simplenewn,p);
  906. _DISPOSE : new_dispose_statement:=gensinglenode(simpledisposen,p);
  907. end;
  908. end;
  909. end;
  910. consume(_RKLAMMER);
  911. end;
  912. function statement_block(starttoken : ttoken) : ptree;
  913. var
  914. first,last : ptree;
  915. filepos : tfileposinfo;
  916. begin
  917. first:=nil;
  918. filepos:=tokenpos;
  919. consume(starttoken);
  920. inc(statement_level);
  921. while not(token in [_END,_FINALIZATION]) do
  922. begin
  923. if first=nil then
  924. begin
  925. last:=gennode(statementn,nil,statement);
  926. first:=last;
  927. end
  928. else
  929. begin
  930. last^.left:=gennode(statementn,nil,statement);
  931. last:=last^.left;
  932. end;
  933. if (token in [_END,_FINALIZATION]) then
  934. break
  935. else
  936. begin
  937. { if no semicolon, then error and go on }
  938. if token<>_SEMICOLON then
  939. begin
  940. consume(_SEMICOLON);
  941. consume_all_until(_SEMICOLON);
  942. end;
  943. consume(_SEMICOLON);
  944. end;
  945. emptystats;
  946. end;
  947. { don't consume the finalization token, it is consumed when
  948. reading the finalization block, but allow it only after
  949. an initalization ! }
  950. if (starttoken<>_INITIALIZATION) or (token<>_FINALIZATION) then
  951. consume(_END);
  952. dec(statement_level);
  953. last:=gensinglenode(blockn,first);
  954. set_tree_filepos(last,filepos);
  955. statement_block:=last;
  956. end;
  957. function statement : ptree;
  958. var
  959. p : ptree;
  960. code : ptree;
  961. labelnr : pasmlabel;
  962. filepos : tfileposinfo;
  963. sr : plabelsym;
  964. label
  965. ready;
  966. begin
  967. filepos:=tokenpos;
  968. case token of
  969. _GOTO : begin
  970. if not(cs_support_goto in aktmoduleswitches)then
  971. Message(sym_e_goto_and_label_not_supported);
  972. consume(_GOTO);
  973. if (token<>_INTCONST) and (token<>_ID) then
  974. begin
  975. Message(sym_e_label_not_found);
  976. code:=genzeronode(errorn);
  977. end
  978. else
  979. begin
  980. getsym(pattern,true);
  981. consume(token);
  982. if srsym^.typ<>labelsym then
  983. begin
  984. Message(sym_e_id_is_no_label_id);
  985. code:=genzeronode(errorn);
  986. end
  987. else
  988. begin
  989. code:=genlabelnode(goton,plabelsym(srsym)^.lab);
  990. code^.labsym:=plabelsym(srsym);
  991. { set flag that this label is used }
  992. plabelsym(srsym)^.used:=true;
  993. end;
  994. end;
  995. end;
  996. _BEGIN : code:=statement_block(_BEGIN);
  997. _IF : code:=if_statement;
  998. _CASE : code:=case_statement;
  999. _REPEAT : code:=repeat_statement;
  1000. _WHILE : code:=while_statement;
  1001. _FOR : code:=for_statement;
  1002. _NEW,_DISPOSE : code:=new_dispose_statement;
  1003. _WITH : code:=with_statement;
  1004. _TRY : code:=try_statement;
  1005. _RAISE : code:=raise_statement;
  1006. { semicolons,else until and end are ignored }
  1007. _SEMICOLON,
  1008. _ELSE,
  1009. _UNTIL,
  1010. _END:
  1011. code:=genzeronode(niln);
  1012. _FAIL : begin
  1013. { internalerror(100); }
  1014. if (aktprocsym^.definition^.proctypeoption<>potype_constructor) then
  1015. Message(parser_e_fail_only_in_constructor);
  1016. consume(_FAIL);
  1017. code:=genzeronode(failn);
  1018. end;
  1019. _EXIT : code:=exit_statement;
  1020. _ASM : begin
  1021. code:=_asm_statement;
  1022. end;
  1023. _EOF : begin
  1024. Message(scan_f_end_of_file);
  1025. end;
  1026. else
  1027. begin
  1028. if (token in [_INTCONST,_ID]) then
  1029. begin
  1030. getsym(pattern,true);
  1031. lastsymknown:=true;
  1032. lastsrsym:=srsym;
  1033. { it is NOT necessarily the owner
  1034. it can be a withsymtable !!! }
  1035. lastsrsymtable:=srsymtable;
  1036. if assigned(srsym) and (srsym^.typ=labelsym) then
  1037. begin
  1038. consume(token);
  1039. consume(_COLON);
  1040. { we must preserve srsym to set code later }
  1041. sr:=plabelsym(srsym);
  1042. if sr^.defined then
  1043. Message(sym_e_label_already_defined);
  1044. sr^.defined:=true;
  1045. { statement modifies srsym }
  1046. labelnr:=sr^.lab;
  1047. lastsymknown:=false;
  1048. { the pointer to the following instruction }
  1049. { isn't a very clean way }
  1050. code:=gensinglenode(labeln,statement{$ifndef tp}(){$endif});
  1051. code^.labelnr:=labelnr;
  1052. sr^.code:=code;
  1053. { sorry, but there is a jump the easiest way }
  1054. goto ready;
  1055. end;
  1056. end;
  1057. p:=expr;
  1058. if not(p^.treetype in [calln,assignn,breakn,inlinen,
  1059. continuen]) then
  1060. Message(cg_e_illegal_expression);
  1061. { specify that we don't use the value returned by the call }
  1062. { Question : can this be also improtant
  1063. for inlinen ??
  1064. it is used for :
  1065. - dispose of temp stack space
  1066. - dispose on FPU stack }
  1067. if p^.treetype=calln then
  1068. p^.return_value_used:=false;
  1069. code:=p;
  1070. end;
  1071. end;
  1072. ready:
  1073. if assigned(code) then
  1074. set_tree_filepos(code,filepos);
  1075. statement:=code;
  1076. end;
  1077. function block(islibrary : boolean) : ptree;
  1078. var
  1079. funcretsym : pfuncretsym;
  1080. storepos : tfileposinfo;
  1081. begin
  1082. { do we have an assembler block without the po_assembler?
  1083. we should allow this for Delphi compatibility (PFV) }
  1084. if (token=_ASM) and (m_delphi in aktmodeswitches) then
  1085. begin
  1086. include(aktprocsym^.definition^.procoptions,po_assembler);
  1087. block:=assembler_block;
  1088. exit;
  1089. end;
  1090. if procinfo^.returntype.def<>pdef(voiddef) then
  1091. begin
  1092. { if the current is a function aktprocsym is non nil }
  1093. { and there is a local symtable set }
  1094. storepos:=tokenpos;
  1095. tokenpos:=aktprocsym^.fileinfo;
  1096. funcretsym:=new(pfuncretsym,init(aktprocsym^.name,procinfo));
  1097. { insert in local symtable }
  1098. symtablestack^.insert(funcretsym);
  1099. tokenpos:=storepos;
  1100. if ret_in_acc(procinfo^.returntype.def) or (procinfo^.returntype.def^.deftype=floatdef) then
  1101. procinfo^.return_offset:=-funcretsym^.address;
  1102. procinfo^.funcretsym:=funcretsym;
  1103. { insert result also if support is on }
  1104. if (m_result in aktmodeswitches) then
  1105. begin
  1106. procinfo^.resultfuncretsym:=new(pfuncretsym,init('RESULT',procinfo));
  1107. symtablestack^.insert(procinfo^.resultfuncretsym);
  1108. end;
  1109. end;
  1110. read_declarations(islibrary);
  1111. { temporary space is set, while the BEGIN of the procedure }
  1112. if (symtablestack^.symtabletype=localsymtable) then
  1113. procinfo^.firsttemp_offset := -symtablestack^.datasize
  1114. else
  1115. procinfo^.firsttemp_offset := 0;
  1116. { space for the return value }
  1117. { !!!!! this means that we can not set the return value
  1118. in a subfunction !!!!! }
  1119. { because we don't know yet where the address is }
  1120. if procinfo^.returntype.def<>pdef(voiddef) then
  1121. begin
  1122. if ret_in_acc(procinfo^.returntype.def) or (procinfo^.returntype.def^.deftype=floatdef) then
  1123. { if (procinfo^.retdef^.deftype=orddef) or
  1124. (procinfo^.retdef^.deftype=pointerdef) or
  1125. (procinfo^.retdef^.deftype=enumdef) or
  1126. (procinfo^.retdef^.deftype=procvardef) or
  1127. (procinfo^.retdef^.deftype=floatdef) or
  1128. (
  1129. (procinfo^.retdef^.deftype=setdef) and
  1130. (psetdef(procinfo^.retdef)^.settype=smallset)
  1131. ) then }
  1132. begin
  1133. { the space has been set in the local symtable }
  1134. procinfo^.return_offset:=-funcretsym^.address;
  1135. if ((procinfo^.flags and pi_operator)<>0) and
  1136. assigned(opsym) then
  1137. {opsym^.address:=procinfo^.para_offset; is wrong PM }
  1138. opsym^.address:=-procinfo^.return_offset;
  1139. { eax is modified by a function }
  1140. {$ifndef newcg}
  1141. {$ifdef i386}
  1142. usedinproc:=usedinproc or ($80 shr byte(R_EAX));
  1143. if is_64bitint(procinfo^.returntype.def) then
  1144. usedinproc:=usedinproc or ($80 shr byte(R_EDX))
  1145. {$endif}
  1146. {$ifdef m68k}
  1147. usedinproc:=usedinproc or ($800 shr word(R_D0));
  1148. if is_64bitint(procinfo^.retdef) then
  1149. usedinproc:=usedinproc or ($800 shr byte(R_D1))
  1150. {$endif}
  1151. {$endif newcg}
  1152. end;
  1153. end;
  1154. {Unit initialization?.}
  1155. if (lexlevel=unit_init_level) and (current_module^.is_unit)
  1156. or islibrary then
  1157. begin
  1158. if (token=_END) then
  1159. begin
  1160. consume(_END);
  1161. { We need at least a node, else the entry/exit code is not
  1162. generated and thus no PASCALMAIN symbol which we need (PFV) }
  1163. if islibrary then
  1164. block:=genzeronode(nothingn)
  1165. else
  1166. block:=nil;
  1167. end
  1168. else
  1169. begin
  1170. if token=_INITIALIZATION then
  1171. begin
  1172. current_module^.flags:=current_module^.flags or uf_init;
  1173. block:=statement_block(_INITIALIZATION);
  1174. end
  1175. else if (token=_FINALIZATION) then
  1176. begin
  1177. if (current_module^.flags and uf_finalize)<>0 then
  1178. block:=statement_block(_FINALIZATION)
  1179. else
  1180. begin
  1181. { can we allow no INITIALIZATION for DLL ??
  1182. I think it should work PM }
  1183. block:=nil;
  1184. exit;
  1185. end;
  1186. end
  1187. else
  1188. begin
  1189. current_module^.flags:=current_module^.flags or uf_init;
  1190. block:=statement_block(_BEGIN);
  1191. end;
  1192. end;
  1193. end
  1194. else
  1195. block:=statement_block(_BEGIN);
  1196. end;
  1197. function assembler_block : ptree;
  1198. begin
  1199. read_declarations(false);
  1200. { temporary space is set, while the BEGIN of the procedure }
  1201. if symtablestack^.symtabletype=localsymtable then
  1202. procinfo^.firsttemp_offset := -symtablestack^.datasize
  1203. else
  1204. procinfo^.firsttemp_offset := 0;
  1205. { assembler code does not allocate }
  1206. { space for the return value }
  1207. if procinfo^.returntype.def<>pdef(voiddef) then
  1208. begin
  1209. if ret_in_acc(procinfo^.returntype.def) then
  1210. begin
  1211. { in assembler code the result should be directly in %eax
  1212. procinfo^.retoffset:=procinfo^.firsttemp-procinfo^.retdef^.size;
  1213. procinfo^.firsttemp:=procinfo^.retoffset; }
  1214. {$ifndef newcg}
  1215. {$ifdef i386}
  1216. usedinproc:=usedinproc or ($80 shr byte(R_EAX))
  1217. {$endif}
  1218. {$ifdef m68k}
  1219. usedinproc:=usedinproc or ($800 shr word(R_D0))
  1220. {$endif}
  1221. {$endif newcg}
  1222. end
  1223. {
  1224. else if not is_fpu(procinfo^.retdef) then
  1225. should we allow assembler functions of big elements ?
  1226. YES (FK)!!
  1227. Message(parser_e_asm_incomp_with_function_return);
  1228. }
  1229. end;
  1230. { set the framepointer to esp for assembler functions }
  1231. { but only if the are no local variables }
  1232. { added no parameter also (PM) }
  1233. { disable for methods, because self pointer is expected }
  1234. { at -8(%ebp) (JM) }
  1235. { why if se use %esp then self is still at the correct address PM }
  1236. if {not(assigned(procinfo^._class)) and}
  1237. (po_assembler in aktprocsym^.definition^.procoptions) and
  1238. (aktprocsym^.definition^.localst^.datasize=0) and
  1239. (aktprocsym^.definition^.parast^.datasize=0) and
  1240. not(ret_in_param(aktprocsym^.definition^.rettype.def)) then
  1241. begin
  1242. procinfo^.framepointer:=stack_pointer;
  1243. { set the right value for parameters }
  1244. dec(aktprocsym^.definition^.parast^.address_fixup,target_os.size_of_pointer);
  1245. dec(procinfo^.para_offset,target_os.size_of_pointer);
  1246. end;
  1247. { force the asm statement }
  1248. if token<>_ASM then
  1249. consume(_ASM);
  1250. procinfo^.Flags := procinfo^.Flags Or pi_is_assembler;
  1251. assembler_block:=_asm_statement;
  1252. { becuase the END is already read we need to get the
  1253. last_endtoken_filepos here (PFV) }
  1254. last_endtoken_filepos:=tokenpos;
  1255. end;
  1256. end.
  1257. {
  1258. $Log$
  1259. Revision 1.129 2000-04-29 12:50:14 peter
  1260. * support asm block without assembler directive for -Sd
  1261. Revision 1.128 2000/04/24 11:11:50 peter
  1262. * backtraces for exceptions are now only generated from the place of the
  1263. exception
  1264. * frame is also pushed for exceptions
  1265. * raise statement enhanced with [,<frame>]
  1266. Revision 1.127 2000/03/19 14:17:05 florian
  1267. * crash when using exception classes without sysutils unit fixed
  1268. Revision 1.126 2000/03/19 11:16:44 peter
  1269. * check for unknown id in on exception
  1270. Revision 1.125 2000/03/16 15:12:06 pierre
  1271. assembler method code does not need ebp framepointer
  1272. Revision 1.124 2000/03/14 16:37:25 pierre
  1273. * destructor can have args in TP mode only (bug825 and 839)
  1274. Revision 1.123 2000/02/29 23:59:47 pierre
  1275. Use $GOTO ON
  1276. Revision 1.122 2000/02/09 13:22:59 peter
  1277. * log truncated
  1278. Revision 1.121 2000/01/23 16:33:49 peter
  1279. * fixed destructor parsing with preprocessor things
  1280. * support dipsoe(p,done())
  1281. * fixed constructor message with dispose(p,<nonexist>)
  1282. Revision 1.120 2000/01/16 22:17:12 peter
  1283. * renamed call_offset to para_offset
  1284. Revision 1.119 2000/01/12 10:30:50 peter
  1285. * fixed library with only end.
  1286. Revision 1.118 2000/01/07 01:14:31 peter
  1287. * updated copyright to 2000
  1288. Revision 1.117 1999/12/22 01:01:52 peter
  1289. - removed freelabel()
  1290. * added undefined label detection in internal assembler, this prevents
  1291. a lot of ld crashes and wrong .o files
  1292. * .o files aren't written anymore if errors have occured
  1293. * inlining of assembler labels is now correct
  1294. Revision 1.116 1999/12/14 09:58:42 florian
  1295. + compiler checks now if a goto leaves an exception block
  1296. Revision 1.115 1999/12/01 22:43:17 peter
  1297. * fixed sigsegv with casedef=nil
  1298. Revision 1.114 1999/12/01 12:42:32 peter
  1299. * fixed bug 698
  1300. * removed some notes about unused vars
  1301. Revision 1.113 1999/11/30 10:40:45 peter
  1302. + ttype, tsymlist
  1303. Revision 1.112 1999/11/20 01:19:10 pierre
  1304. * DLL index used for win32 target with DEF file
  1305. + DLL initialization/finalization support
  1306. Revision 1.111 1999/11/18 15:34:48 pierre
  1307. * Notes/Hints for local syms changed to
  1308. Set_varstate function
  1309. Revision 1.110 1999/11/17 17:05:02 pierre
  1310. * Notes/hints changes
  1311. Revision 1.109 1999/11/15 22:00:48 peter
  1312. * labels used but not defined give error instead of warning, the warning
  1313. is now only with declared but not defined and not used.
  1314. Revision 1.108 1999/11/10 00:24:02 pierre
  1315. * more browser details
  1316. Revision 1.107 1999/11/09 13:02:46 peter
  1317. * fixed 'raise end;'
  1318. Revision 1.106 1999/11/06 14:34:23 peter
  1319. * truncated log to 20 revs
  1320. Revision 1.105 1999/10/22 10:39:35 peter
  1321. * split type reading from pdecl to ptype unit
  1322. * parameter_dec routine is now used for procedure and procvars
  1323. Revision 1.104 1999/10/14 14:57:54 florian
  1324. - removed the hcodegen use in the new cg, use cgbase instead
  1325. Revision 1.103 1999/09/27 23:44:56 peter
  1326. * procinfo is now a pointer
  1327. * support for result setting in sub procedure
  1328. Revision 1.102 1999/09/16 23:05:54 florian
  1329. * m68k compiler is again compilable (only gas writer, no assembler reader)
  1330. }