njvmutil.pas 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {
  2. Copyright (c) 20011 by Jonas Maebe
  3. JVM version of some node tree helper routines
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit njvmutil;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,
  22. ngenutil;
  23. type
  24. tjvmnodeutils = class(tnodeutils)
  25. class function initialize_data_node(p:tnode):tnode; override;
  26. class function finalize_data_node(p:tnode):tnode; override;
  27. end;
  28. implementation
  29. uses
  30. verbose,constexp,
  31. symconst,symtype,symdef,symsym,symbase,symtable,defutil,
  32. nbas,ncnv,ncon,nld,
  33. pass_1;
  34. class function tjvmnodeutils.initialize_data_node(p:tnode):tnode;
  35. begin
  36. if not assigned(p.resultdef) then
  37. typecheckpass(p);
  38. if ((p.resultdef.typ=stringdef) and
  39. not is_shortstring(p.resultdef) and
  40. not is_longstring(p.resultdef)) or
  41. is_dynamic_array(p.resultdef) then
  42. begin
  43. result:=cassignmentnode.create(
  44. ctypeconvnode.create_internal(p,voidpointertype),
  45. cnilnode.create
  46. );
  47. end
  48. else
  49. { records/arrays/... are automatically initialised }
  50. result:=cnothingnode.create;
  51. end;
  52. class function tjvmnodeutils.finalize_data_node(p:tnode):tnode;
  53. begin
  54. // do nothing
  55. result:=cnothingnode.create;
  56. end;
  57. begin
  58. cnodeutils:=tjvmnodeutils;
  59. end.