convtree.pas 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Converts the old tree nodes into the new OOP nodest
  5. This unit is necessary to interface the new code generator
  6. with the old parser
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ****************************************************************************
  19. }
  20. unit convtree;
  21. interface
  22. uses
  23. tree;
  24. function convtree2node(p : ptree) : pnode;
  25. implementation
  26. uses
  27. verbose,nstatmnt,nmem;
  28. function convtree2node(p : ptree) : pnode;
  29. function doconv(p : ptree) : pnode;
  30. var
  31. node : pnode;
  32. begin
  33. if assigned(p) then
  34. begin
  35. case p^.treetype of
  36. blockn:
  37. node:=new(pblocknode,init(doconv(p^.left)));
  38. assignn:
  39. node:=new(passignmentnode,init(doconv(p^.left),
  40. doconv(p^.right)));
  41. statementn:
  42. node:=new(pstatementnode,init(doconv(p^.left),
  43. doconv(p^.right)));
  44. loadn:
  45. node:=new(ploadnode,init(p^.symtableentry,p^.symtable));
  46. else internalerror(1209993);
  47. end;
  48. doconv:=node;
  49. end
  50. else
  51. doconv:=nil;
  52. end;
  53. begin
  54. convtree2node:=doconv(p);
  55. disposetree(p);
  56. end;
  57. end.
  58. {
  59. $Log$
  60. Revision 1.6 2000-01-07 01:14:53 peter
  61. * updated copyright to 2000
  62. Revision 1.5 1999/09/14 11:16:09 florian
  63. * only small updates to work with the current compiler
  64. Revision 1.4 1999/01/24 22:32:35 florian
  65. * well, more changes, especially parts of secondload ported
  66. Revision 1.3 1999/01/23 23:29:47 florian
  67. * first running version of the new code generator
  68. * when compiling exceptions under Linux fixed
  69. Revision 1.2 1999/01/19 10:19:04 florian
  70. * bug with mul. of dwords fixed, reported by Alexander Stohr
  71. * some changes to compile with TP
  72. + small enhancements for the new code generator
  73. Revision 1.1 1999/01/13 22:52:37 florian
  74. + YES, finally the new code generator is compilable, but it doesn't run yet :(
  75. }