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

Public Member Functions

override string ToString ()

Static Public Member Functions

static Operand Literal (object val)
static Operand Variable (string identifier)
static Operand MemberVariable (string identifier, object val)
static Operand CreatePointer (string identifier, string pointer)
static Operand AllocateInstructionPointer (Instruction instruction)
static Operand AllocateFunctionPointer (Function function)
static Operand AllocateRoutinePointer (Routine routine)

Properties

OperandType Type [get, set]
object Value [get]
object Member [get, set]
string Pointer [get, set]
Instruction InstructionPointer [get, set]
Function FunctionPointer [get, set]
Routine RoutinePointer [get, set]

Detailed Description

Definition at line 22 of file Operand.cs.

Member Function Documentation

◆ AllocateFunctionPointer()

Operand ScriptStack.Runtime.Operand.AllocateFunctionPointer ( Function function)
static

Definition at line 79 of file Operand.cs.

80 {
81 return new Operand(OperandType.FunctionPointer, function, null);
82 }

◆ AllocateInstructionPointer()

Operand ScriptStack.Runtime.Operand.AllocateInstructionPointer ( Instruction instruction)
static

Definition at line 74 of file Operand.cs.

75 {
76 return new Operand(OperandType.InstructionPointer, instruction, null);
77 }

◆ AllocateRoutinePointer()

Operand ScriptStack.Runtime.Operand.AllocateRoutinePointer ( Routine routine)
static

Definition at line 84 of file Operand.cs.

85 {
86 return new Operand(OperandType.RoutinePointer, routine, null);
87 }

◆ CreatePointer()

Operand ScriptStack.Runtime.Operand.CreatePointer ( string identifier,
string pointer )
static

Definition at line 69 of file Operand.cs.

70 {
71 return new Operand(OperandType.Pointer, identifier, pointer);
72 }

◆ Literal()

Operand ScriptStack.Runtime.Operand.Literal ( object val)
static

Definition at line 54 of file Operand.cs.

55 {
56 return new Operand(OperandType.Literal, val, null);
57 }

◆ MemberVariable()

Operand ScriptStack.Runtime.Operand.MemberVariable ( string identifier,
object val )
static

Definition at line 64 of file Operand.cs.

65 {
66 return new Operand(OperandType.Member, identifier, val);
67 }

◆ ToString()

override string ScriptStack.Runtime.Operand.ToString ( )

Definition at line 146 of file Operand.cs.

147 {
148
149 switch (m_operandType)
150 {
151
152 case OperandType.Literal:
153 {
154
155 // \todo improve
156 if (m_objectValue.GetType().ToString() == "System.String")
157 return ToLiteral((string)m_objectValue);
158
159 else if (m_objectValue.GetType().ToString() == "System.Char")
160 return ToLiteral("" + (char)m_objectValue);
161
162 else
163 return ToString(m_objectValue);
164
165 }
166
167 case OperandType.Variable:
168 return m_objectValue.ToString();
169
170 case OperandType.Member:
171 return m_objectValue + "[" + ToString(m_objectIndex) + "]";
172
173 case OperandType.Pointer:
174 return m_objectValue + "[" + m_objectIndex + "]";
175
176 case OperandType.InstructionPointer:
177 return "[" + ((Instruction) m_objectValue).Address.ToString("X8") + "]";
178
179 case OperandType.FunctionPointer:
180 {
181 Function scriptFunction = (Function)m_objectValue;
182 return "<" + scriptFunction.Name + "@" + scriptFunction.EntryPoint.Address.ToString("X8") + ">";
183 }
184
185 case OperandType.RoutinePointer:
186 return m_objectValue.ToString();
187
188 default:
189 return ToLiteral(m_operandType.ToString());
190
191 }
192 }

References ScriptStack.Runtime.Instruction.Address, ScriptStack.Runtime.Function.EntryPoint, and ToString().

Referenced by ToString().

◆ Variable()

Operand ScriptStack.Runtime.Operand.Variable ( string identifier)
static

Definition at line 59 of file Operand.cs.

60 {
61 return new Operand(OperandType.Variable, identifier, null);
62 }

Property Documentation

◆ FunctionPointer

Function ScriptStack.Runtime.Operand.FunctionPointer
getset

Definition at line 259 of file Operand.cs.

260 {
261 get
262 {
263 if (m_operandType != OperandType.FunctionPointer)
264 throw new ParserException("Error in function call.");
265
266 return (Function)m_objectValue;
267 }
268 set
269 {
270 if (m_operandType != OperandType.FunctionPointer)
271 throw new ParserException("Error in function call.");
272
273 m_objectValue = value;
274 }
275 }

◆ InstructionPointer

Instruction ScriptStack.Runtime.Operand.InstructionPointer
getset

Definition at line 241 of file Operand.cs.

242 {
243 get
244 {
245 if (m_operandType != OperandType.InstructionPointer)
246 throw new ParserException("Error in instruction access.");
247
248 return (Instruction) m_objectValue;
249 }
250 set
251 {
252 if (m_operandType != OperandType.InstructionPointer)
253 throw new ParserException("Error in instruction access.");
254
255 m_objectValue = value;
256 }
257 }

◆ Member

object ScriptStack.Runtime.Operand.Member
getset

Definition at line 209 of file Operand.cs.

210 {
211 get
212 {
213 if (m_operandType != OperandType.Member)
214 throw new ExecutionException("Error in member access.");
215 return m_objectIndex;
216 }
217 set
218 {
219 if (m_operandType != OperandType.Member)
220 throw new ExecutionException("Error in member access.");
221 m_objectIndex = value;
222 }
223 }

◆ Pointer

string ScriptStack.Runtime.Operand.Pointer
getset

Definition at line 225 of file Operand.cs.

226 {
227 get
228 {
229 if (m_operandType != OperandType.Pointer)
230 throw new ExecutionException("Error in array access.");
231 return (string) m_objectIndex;
232 }
233 set
234 {
235 if (m_operandType != OperandType.Pointer)
236 throw new ExecutionException("Error in array access.");
237 m_objectIndex = value;
238 }
239 }

◆ RoutinePointer

Routine ScriptStack.Runtime.Operand.RoutinePointer
getset

Definition at line 277 of file Operand.cs.

278 {
279
280 get
281 {
282 if (m_operandType != OperandType.RoutinePointer)
283 throw new ParserException("Error in routine access.");
284
285 return (Routine)m_objectValue;
286 }
287 set
288 {
289 if (m_operandType != OperandType.RoutinePointer)
290 throw new ParserException("Error in routine access.");
291
292 m_objectValue = value;
293 }
294
295 }

◆ Type

OperandType ScriptStack.Runtime.Operand.Type
getset

Definition at line 198 of file Operand.cs.

199 {
200 get { return m_operandType; }
201 set { m_operandType = value; }
202 }

◆ Value

object ScriptStack.Runtime.Operand.Value
get

Definition at line 204 of file Operand.cs.

205 {
206 get { return m_objectValue; }
207 }

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