ScriptStack 1.0.4
Loading...
Searching...
No Matches
ScriptStack.Runtime.Memory Class Reference

Public Member Functions

void Clear ()
bool Exists (string identifier)
void Remove (string identifier)
Scope Find (string identifier)

Static Public Member Functions

static Memory AllocateSharedMemory ()
static Memory AllocateScriptMemory (Memory sharedMemory)
static Memory AllocateLocalMemory (Memory scriptMemory)

Properties

ReadOnlyCollection< string > Identifiers [get]
object this[string identifier] [get, set]
Scope Scope [get]

Detailed Description

Definition at line 15 of file Memory.cs.

Member Function Documentation

◆ AllocateLocalMemory()

Memory ScriptStack.Runtime.Memory.AllocateLocalMemory ( Memory scriptMemory)
static

Definition at line 65 of file Memory.cs.

66 {
67 return new Memory(
68 Scope.Local, scriptMemory.sharedMemory, scriptMemory);
69 }

References Scope.

Referenced by ScriptStack.Runtime.Interpreter.Reset().

◆ AllocateScriptMemory()

Memory ScriptStack.Runtime.Memory.AllocateScriptMemory ( Memory sharedMemory)
static

Definition at line 60 of file Memory.cs.

61 {
62 return new Memory(Scope.Script, sharedMemory, null);
63 }

References Scope.

Referenced by ScriptStack.Runtime.Executable.Executable().

◆ AllocateSharedMemory()

Memory ScriptStack.Runtime.Memory.AllocateSharedMemory ( )
static

Definition at line 55 of file Memory.cs.

56 {
57 return new Memory(Scope.Shared, null, null);
58 }

References Scope.

Referenced by ScriptStack.Manager.Manager().

◆ Clear()

void ScriptStack.Runtime.Memory.Clear ( )

Definition at line 71 of file Memory.cs.

72 {
73 variables.Clear();
74 tempVariables.Clear();
75 }

◆ Exists()

bool ScriptStack.Runtime.Memory.Exists ( string identifier)

Definition at line 77 of file Memory.cs.

78 {
79
80 switch (scope)
81 {
82
83 case Scope.Shared:
84 return variables.ContainsKey(identifier);
85
86 case Scope.Script:
87 if (variables.ContainsKey(identifier))
88 return true;
89 else
90 return sharedMemory.Exists(identifier);
91
92 case Scope.Local:
93 if (variables.ContainsKey(identifier))
94 return true;
95 else
96 return scriptMemory.Exists(identifier);
97
98 default:
99 throw new ExecutionException("Der Scope '" + scope + "' ist unkelannt.");
100
101 }
102
103 }

References Scope.

◆ Find()

Scope ScriptStack.Runtime.Memory.Find ( string identifier)

Definition at line 110 of file Memory.cs.

111 {
112 switch (scope)
113 {
114
115 case Scope.Shared:
116 if (variables.ContainsKey(identifier))
117 return scope;
118 else
119 throw new ExecutionException("Variable '" + identifier + "' undefined.");
120
121 case Scope.Script:
122 if (variables.ContainsKey(identifier))
123 return scope;
124 else
125 return sharedMemory.Find(identifier);
126
127 case Scope.Local:
128 if (variables.ContainsKey(identifier))
129 return scope;
130 else
131 return scriptMemory.Find(identifier);
132
133 default:
134 throw new ExecutionException("Unknown scope: " + scope);
135
136 }
137
138 }

References Scope.

◆ Remove()

void ScriptStack.Runtime.Memory.Remove ( string identifier)

Definition at line 105 of file Memory.cs.

106 {
107 variables.Remove(identifier);
108 }

Referenced by ScriptStack.Runtime.Interpreter.Reset().

Property Documentation

◆ Identifiers

ReadOnlyCollection<string> ScriptStack.Runtime.Memory.Identifiers
get

Definition at line 140 of file Memory.cs.

141 {
142 get
143 {
144 List<String> listIdentifiers
145 = new List<String>(variables.Keys);
146 return listIdentifiers.AsReadOnly();
147 }
148 }

◆ Scope

Scope ScriptStack.Runtime.Memory.Scope
get

Definition at line 202 of file Memory.cs.

203 {
204 get { return scope; }
205 }

Referenced by AllocateLocalMemory(), AllocateScriptMemory(), AllocateSharedMemory(), Exists(), and Find().

◆ this[string identifier]

object ScriptStack.Runtime.Memory.this[string identifier]
getset

Definition at line 150 of file Memory.cs.

151 {
152 get
153 {
154 switch (scope)
155 {
156 case Scope.Shared:
157 if (!variables.ContainsKey(identifier))
158 throw new ExecutionException( "Globale Variable '" + identifier + "' wurde nicht deklariert.");
159 return variables[identifier];
160 case Scope.Script:
161 if (variables.ContainsKey(identifier))
162 return variables[identifier];
163 else
164 return sharedMemory[identifier];
165 case Scope.Local:
166 if (variables.ContainsKey(identifier))
167 return variables[identifier];
168 else
169 return scriptMemory[identifier];
170 default:
171 throw new ExecutionException("Der Scope '" + scope + "' int unbekannt.");
172 }
173 }
174 set
175 {
176 if (!Exists(identifier))
177 variables[identifier] = value;
178 else
179 {
180 switch (scope)
181 {
182 case Scope.Shared:
183 variables[identifier] = value;
184 break;
185 case Scope.Script:
186 if (sharedMemory.Exists(identifier))
187 sharedMemory[identifier] = value;
188 else
189 variables[identifier] = value;
190 break;
191 case Scope.Local:
192 if (scriptMemory.Exists(identifier))
193 scriptMemory[identifier] = value;
194 else
195 variables[identifier] = value;
196 break;
197 }
198 }
199 }
200 }

The documentation for this class was generated from the following file: