symnot.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Daniel Mantione
  4. This unit contains support routines for the variable access
  5. notifier.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit symnot;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses cclasses,symtype;
  23. type Tnotification_flag=(vn_onread,vn_onwrite,vn_unknown);
  24. Tnotification_flags=set of Tnotification_flag;
  25. Tnotification_callback=procedure(not_type:Tnotification_flag;
  26. symbol:Tsym) of object;
  27. Tnotification=class(Tlinkedlistitem)
  28. flags:Tnotification_flags;
  29. callback:Tnotification_callback;
  30. id:cardinal;
  31. constructor create(Aflags:Tnotification_flags;
  32. Acallback:Tnotification_callback);
  33. end;
  34. implementation
  35. var notification_counter:cardinal;
  36. constructor Tnotification.create(Aflags:Tnotification_flags;
  37. Acallback:Tnotification_callback);
  38. begin
  39. inherited create;
  40. flags:=Aflags;
  41. callback:=Acallback;
  42. id:=notification_counter;
  43. inc(notification_counter);
  44. end;
  45. begin
  46. notification_counter:=0;
  47. end.
  48. {
  49. $Log$
  50. Revision 1.3 2003-10-22 15:22:33 peter
  51. * fixed unitsym-globalsymtable relation so the uses of a unit
  52. is counted correctly
  53. Revision 1.2 2002/12/31 09:55:58 daniel
  54. + Notification implementation complete
  55. + Add for loop code optimization using notifications
  56. results in 1.5-1.9% speed improvement in nestloop benchmark
  57. Optimization incomplete, compiler does not cycle yet with
  58. notifications enabled.
  59. Revision 1.1 2002/09/01 08:04:42 daniel
  60. + Added read/write notifications of variables. These will be usefull
  61. for providing information for several optimizations. For example
  62. the value of the loop variable of a for loop does matter is the
  63. variable is read after the for loop, but if it's no longer used
  64. or written, it doesn't matter and this can be used to optimize
  65. the loop code generation.
  66. }