-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSCall.cpp
182 lines (152 loc) · 5.19 KB
/
DSCall.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/****************************************************************************
* Modul: $RCSfile: DSCall.cpp,v $
*
* $Author: md $
* $Date: 1998/01/13 12:48:22 $
* $Revision: 1.3 $
*
* Aufgabe: Dieser Modul ermoeglicht die Abspeicherung bzw. Ruecklieferung
* des Parameters (Statenamens), der in Verbindung mit einem
* Nextstate-Befehl angegeben ist
*
* Funktionen: GetProcedureRef(): liefert Zeiger auf die aufzurufende Proc
* GetParameterList(): liefert die Aufruf-Parameterliste
* SetProcedureRef(): speichert Proc-Zeiger
* SetParameterList(): speichert Parameterliste
* Save(): Abspeicherung in eine Datei
****************************************************************************/
#ifdef USE_PRAGMA
#pragma interface
#endif
/****************************************************************************
* Konstanten
****************************************************************************/
/****************************************************************************
* Include-Anweisungen
****************************************************************************/
#include "DSCall.h"
#include "DSProcedure.h"
#include "DSExpression.h"
#ifdef DEBUG
#include <dmalloc.h>
#endif
/****************************************************************************
* Externe Variablen
****************************************************************************/
/****************************************************************************
* Globale Variablen
****************************************************************************/
/****************************************************************************
* Konstruktoren
****************************************************************************/
DSCall::DSCall (DSObject *father,
DSString *label_name,
DSProcedureRef proc,
DSActualParamList *act_par_list) :
DSAction(father, DS_CALL, label_name),
DSActualParamComponent(NULL, act_par_list),
procedure_ref(proc)
{
DSActualParamComponent::SetComponentParent(this);
}
DSCall::DSCall (DSObject *father,
DSString& label_name,
DSProcedureRef proc,
DSActualParamList *act_par_list) :
DSAction (father, DS_CALL, &label_name),
DSActualParamComponent(NULL, act_par_list),
procedure_ref(proc)
{
DSActualParamComponent::SetComponentParent(this);
}
DSCall::DSCall (DSObject *father,
const char *label_name,
DSProcedureRef proc,
DSActualParamList *act_par_list) :
DSAction (father, DS_CALL, label_name),
DSActualParamComponent(NULL, act_par_list),
procedure_ref(proc)
{
DSActualParamComponent::SetComponentParent(this);
}
/****************************************************************************
* Destruktor
****************************************************************************/
DSCall::~DSCall(void)
{
}
/****************************************************************************
* GetProcedureRef(): Liefert den Zeiger auf die aufgerufene Prozedur zurueck
* Ergebnis: Zeiger auf eine Prozedur
* Seiteneffekte: keine
****************************************************************************/
DSProcedureRef DSCall::GetProcedureRef(void) const
{
return procedure_ref;
}
/****************************************************************************
* SetProcedureRef(): Speichert den uebergebenen Zeiger
* -> proc_ref: Zeiger auf eine Prozedur
* Ergebnis: DS_OK
* Seiteneffekte: keine
****************************************************************************/
DSResult DSCall::SetProcedureRef(DSProcedureRef proc_ref)
{
procedure_ref = proc_ref;
return DS_OK;
}
DSObject *DSCall::Clone(DSObject *father, DSObject *fill_this) const
{
DSCall *new_call;
if (fill_this == NULL)
{
new_call = (DSCall *)New(father);
assert(new_call);
}
else
{
assert(fill_this->GetType() == DS_ACTION);
assert(((DSAction *)fill_this)->GetTag() == DS_CALL);
new_call = (DSCall *)fill_this;
}
// Basisklassen clonen:
DSAction::Clone(father, new_call);
if (GetActualParamList())
{
new_call->SetActualParamList(GetActualParamList()->Clone((DSObject *)new_call));
}
new_call->SetProcedureRef(GetProcedureRef());
return new_call;
}
DSResult DSCall::Write(DSWriter *writer, DSCardinal what) const
{
assert(writer);
if (procedure_ref) procedure_ref->Write(writer, what);
Run(writer, DS_ACTUALPARAM, what);
return DS_OK;
}
DSResult DSCall::Run(DSWriter *writer, DSType object_type,
DSCardinal what) const
{
DSResult result;
DSActualParam *actual_param;
switch(object_type)
{
case DS_ACTUALPARAM:
for (actual_param = GetFirstActualParam();
actual_param;
actual_param = GetNextActualParam())
{
result = actual_param->Write(writer, what);
if (result != DS_OK)
{
return DS_ERROR;
}
}
break;
default:
assert(DS_FALSE);
break;
}
return DS_OK;
}