symnot.pas 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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,symbase,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.2 2002-12-31 09:55:58 daniel
  51. + Notification implementation complete
  52. + Add for loop code optimization using notifications
  53. results in 1.5-1.9% speed improvement in nestloop benchmark
  54. Optimization incomplete, compiler does not cycle yet with
  55. notifications enabled.
  56. Revision 1.1 2002/09/01 08:04:42 daniel
  57. + Added read/write notifications of variables. These will be usefull
  58. for providing information for several optimizations. For example
  59. the value of the loop variable of a for loop does matter is the
  60. variable is read after the for loop, but if it's no longer used
  61. or written, it doesn't matter and this can be used to optimize
  62. the loop code generation.
  63. }