pstatmnt.pas 52 KB

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