~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to compiler/nstate.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    $Id: nstate.pas,v 1.3 2002/09/07 15:25:05 peter Exp $
3
 
    Copyright (c) 1998-2002 by Daniel Mantione
4
 
 
5
 
    This unit contains support routines for the state tracker
6
 
 
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
 
 
12
 
    This program is distributed in the hope that it will be useful,
13
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
    GNU General Public License for more details.
16
 
 
17
 
    You should have received a copy of the GNU General Public License
18
 
    along with this program; if not, write to the Free Software
19
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
 
21
 
 ****************************************************************************
22
 
}
23
 
 
24
 
unit nstate;
25
 
 
26
 
{$i fpcdefs.inc}
27
 
 
28
 
interface
29
 
 
30
 
uses    cclasses,node;
31
 
 
32
 
type    Tstate_entry=class(Tlinkedlistitem)
33
 
            what:Tnode;
34
 
            value:Tnode;
35
 
            constructor create(w,v:Tnode);
36
 
        end;
37
 
 
38
 
        Tstate_storage=class
39
 
            storage:Tlinkedlist;
40
 
            constructor create;
41
 
            procedure store_fact(w,v:Tnode);
42
 
            function find_fact(what:Tnode):Tnode;
43
 
            procedure delete_fact(what:Tnode);
44
 
        end;
45
 
 
46
 
var     aktstate:Tstate_storage;
47
 
 
48
 
implementation
49
 
 
50
 
constructor Tstate_entry.create(w,v:Tnode);
51
 
 
52
 
begin
53
 
    inherited create;
54
 
    what:=w;
55
 
    value:=v;
56
 
end;
57
 
 
58
 
constructor Tstate_storage.create;
59
 
 
60
 
begin
61
 
    storage:=Tlinkedlist.create;
62
 
end;
63
 
 
64
 
procedure Tstate_storage.store_fact(w,v:Tnode);
65
 
 
66
 
var se:Tstate_entry;
67
 
 
68
 
begin
69
 
{    writeln('fact:');
70
 
    writenode(w);
71
 
    writeln('=');
72
 
    writenode(v);}
73
 
    se:=Tstate_entry(storage.first);
74
 
    while assigned(se) do
75
 
        begin
76
 
            if se.what.isequal(w) then
77
 
                begin
78
 
                    storage.remove(se);
79
 
                    se.destroy;
80
 
                    break;
81
 
                end;
82
 
            se:=Tstate_entry(se.next);
83
 
        end;
84
 
    se:=Tstate_entry.create(w,v);
85
 
    storage.concat(se);
86
 
end;
87
 
 
88
 
function Tstate_storage.find_fact(what:Tnode):Tnode;
89
 
 
90
 
var se:Tstate_entry;
91
 
 
92
 
begin
93
 
    find_fact:=nil;
94
 
    se:=storage.first as Tstate_entry;
95
 
    while assigned(se) do
96
 
        begin
97
 
            if se.what.isequal(what) then
98
 
                begin
99
 
                    find_fact:=se.value;
100
 
                    break;
101
 
                end;
102
 
            se:=se.next as Tstate_entry;
103
 
        end;
104
 
end;
105
 
 
106
 
procedure Tstate_storage.delete_fact(what:Tnode);
107
 
 
108
 
var se:Tstate_entry;
109
 
 
110
 
begin
111
 
    se:=storage.first as Tstate_entry;
112
 
    while assigned(se) do
113
 
        begin
114
 
            if se.what.isequal(what) then
115
 
                begin
116
 
                    storage.remove(se);
117
 
                    se.destroy;
118
 
                    break;
119
 
                end;
120
 
            se:=se.next as Tstate_entry;
121
 
        end;
122
 
end;
123
 
 
124
 
end.
125
 
 
126
 
{
127
 
  $Log: nstate.pas,v $
128
 
  Revision 1.3  2002/09/07 15:25:05  peter
129
 
    * old logs removed and tabs fixed
130
 
 
131
 
  Revision 1.2  2002/07/15 18:03:15  florian
132
 
    * readded removed changes
133
 
 
134
 
  Revision 1.1  2002/07/14 18:00:44  daniel
135
 
  + Added the beginning of a state tracker. This will track the values of
136
 
    variables through procedures and optimize things away.
137
 
}