njvmset.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. Copyright (c) 2011 by Jonas Maebe
  3. Generate JVM bytecode for in set/case nodes
  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 njvmset;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. node,nset,ncgset;
  23. type
  24. tjvmcasenode = class(tcgcasenode)
  25. function pass_1: tnode; override;
  26. end;
  27. implementation
  28. uses
  29. symconst,symdef,
  30. pass_1,
  31. ncnv;
  32. {*****************************************************************************
  33. TJVMCASENODE
  34. *****************************************************************************}
  35. function tjvmcasenode.pass_1: tnode;
  36. begin
  37. { convert case expression to an integer in case it's an enum, since
  38. enums are class instances in the JVM. All labels are stored as
  39. ordinal values, so it doesn't matter that we change the type }
  40. if left.resultdef.typ=enumdef then
  41. inserttypeconv_explicit(left,s32inttype);
  42. result:=inherited pass_1;
  43. end;
  44. begin
  45. ccasenode:=tjvmcasenode;
  46. end.