ScriptStack 1.0.0
A .NET scripting language
Lade ...
Suche ...
Keine Treffer
ScriptStack.Runtime.Operand Klassenreferenz

Öffentliche Methoden

override string ToString ()
 

Öffentliche, statische Methoden

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)
 

Propertys

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]
 

Private Methoden

 Operand (OperandType operandType, object objectValue, object objectIndex)
 
string ToString (object objectValue)
 
string ToLiteral (string input)
 

Private Attribute

OperandType m_operandType
 
object m_objectValue
 
object m_objectIndex
 

Beschreibung der Konstruktoren und Destruktoren

◆ Operand()

Dokumentation der Elementfunktionen

◆ AllocateFunctionPointer()

static Operand ScriptStack.Runtime.Operand.AllocateFunctionPointer ( Function function)
static
80 {
81 return new Operand(OperandType.FunctionPointer, function, null);
82 }
Operand(OperandType operandType, object objectValue, object objectIndex)
Definition Operand.cs:35
OperandType
Definition Operand.cs:12

Benutzt ScriptStack.Runtime.Operand.Operand().

Wird benutzt von ScriptStack.Compiler.Parser.FunctionCall().

◆ AllocateInstructionPointer()

◆ AllocateRoutinePointer()

static Operand ScriptStack.Runtime.Operand.AllocateRoutinePointer ( Routine routine)
static
85 {
86 return new Operand(OperandType.RoutinePointer, routine, null);
87 }

Benutzt ScriptStack.Runtime.Operand.Operand().

Wird benutzt von ScriptStack.Compiler.Parser.RoutineCall().

◆ CreatePointer()

◆ Literal()

◆ MemberVariable()

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

◆ ToLiteral()

string ScriptStack.Runtime.Operand.ToLiteral ( string input)
private
94 {
95
96 var literal = new StringBuilder(input.Length + 2);
97
98 foreach (var c in input)
99 {
100
101 switch (c)
102 {
103
104 case '\"':
105 literal.Append("\\\"");
106 break;
107
108 case '\a':
109 literal.Append("\\a");
110 break;
111
112 case '\b':
113 literal.Append("\\b");
114 break;
115
116 case '\n':
117 literal.Append("\\n");
118 break;
119
120 case '\r':
121 literal.Append("\\r");
122 break;
123
124 case '\t':
125 literal.Append("\\t");
126 break;
127
128 default:
129 if (char.GetUnicodeCategory(c) != System.Globalization.UnicodeCategory.Control)
130 literal.Append(c);
131 else
132 {
133 literal.Append(@"\u");
134 literal.Append(((ushort)c).ToString("x4"));
135 }
136 break;
137
138 }
139
140 }
141
142 return literal.ToString();
143
144 }
override string ToString()
Definition Operand.cs:146

Benutzt ScriptStack.Runtime.Operand.ToString().

Wird benutzt von ScriptStack.Runtime.Operand.ToString().

◆ ToString() [1/2]

override string ScriptStack.Runtime.Operand.ToString ( )
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 }
A function, forward declared in a script.
Definition Function.cs:15
Instruction EntryPoint
Definition Function.cs:87
An instruction in a virtual intermediate language.
Definition Instruction.cs:12
uint Address
Definition Instruction.cs:126
string ToLiteral(string input)
Definition Operand.cs:93

Benutzt ScriptStack.Runtime.Instruction.Address, ScriptStack.Runtime.Function.EntryPoint, ScriptStack.Compiler.Function, ScriptStack.Runtime.Operand.m_objectIndex, ScriptStack.Runtime.Operand.m_objectValue, ScriptStack.Runtime.Operand.m_operandType, ScriptStack.Runtime.Operand.ToLiteral() und ScriptStack.Runtime.Operand.ToString().

Wird benutzt von ScriptStack.Runtime.Operand.ToLiteral() und ScriptStack.Runtime.Operand.ToString().

◆ ToString() [2/2]

string ScriptStack.Runtime.Operand.ToString ( object objectValue)
private
43 {
44 if (objectValue.GetType() == typeof(string))
45 return "\"" + objectValue + "\"";
46 else
47 return objectValue.ToString();
48 }

Wird benutzt von ScriptStack.Runtime.Interpreter.Arithmetic(), ScriptStack.Runtime.Interpreter.Assignment() und ScriptStack.Runtime.Instruction.ToString().

◆ Variable()

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

Benutzt ScriptStack.Runtime.Operand.Operand().

Wird benutzt von ScriptStack.Compiler.Parser.AllocateVariable(), ScriptStack.Compiler.Parser.And(), ScriptStack.Runtime.Interpreter.ANDB(), ScriptStack.Compiler.Parser.Arithmetic(), ScriptStack.Compiler.Parser.ArrayAssignment(), ScriptStack.Compiler.Parser.Atom(), ScriptStack.Compiler.Parser.BinaryAnd(), ScriptStack.Compiler.Parser.BinaryNot(), ScriptStack.Compiler.Parser.BinaryNotAssign(), ScriptStack.Compiler.Parser.BinaryOr(), ScriptStack.Compiler.Parser.BraceArray(), ScriptStack.Compiler.Parser.BracketArray(), ScriptStack.Runtime.Interpreter.DCO(), ScriptStack.Compiler.Parser.EnumDeclaration(), ScriptStack.Compiler.Parser.For(), ScriptStack.Compiler.Parser.ForEach(), ScriptStack.Compiler.Parser.FunctionCall(), ScriptStack.Compiler.Parser.FunctionDeclaration(), ScriptStack.Compiler.Parser.If(), ScriptStack.Compiler.Parser.LockedStatementList(), ScriptStack.Compiler.Parser.Member(), ScriptStack.Compiler.Parser.MemberAssignment(), ScriptStack.Compiler.Parser.Not(), ScriptStack.Runtime.Interpreter.NOTB(), ScriptStack.Compiler.Parser.Notify(), ScriptStack.Compiler.Parser.Or(), ScriptStack.Runtime.Interpreter.ORB(), ScriptStack.Compiler.Parser.Pointer(), ScriptStack.Runtime.Interpreter.POP(), ScriptStack.Compiler.Parser.PostDecrement(), ScriptStack.Compiler.Parser.PostIncrement(), ScriptStack.Compiler.Parser.PreDecrement(), ScriptStack.Compiler.Parser.PreIncrement(), ScriptStack.Compiler.Parser.Relation(), ScriptStack.Compiler.Parser.Return(), ScriptStack.Compiler.Parser.RoutineCall(), ScriptStack.Compiler.Parser.ShiftLeft(), ScriptStack.Compiler.Parser.ShiftRight(), ScriptStack.Runtime.Interpreter.SHL(), ScriptStack.Runtime.Interpreter.SHR(), ScriptStack.Compiler.Parser.StructDeclaration(), ScriptStack.Compiler.Parser.Switch(), ScriptStack.Compiler.Parser.Term(), ScriptStack.Compiler.Parser.VariableAssignment(), ScriptStack.Compiler.Parser.VariableDeclaration(), ScriptStack.Compiler.Parser.Wait(), ScriptStack.Compiler.Parser.While(), ScriptStack.Compiler.Parser.Xor() und ScriptStack.Runtime.Interpreter.XOR().

Dokumentation der Datenelemente

◆ m_objectIndex

object ScriptStack.Runtime.Operand.m_objectIndex
private

◆ m_objectValue

object ScriptStack.Runtime.Operand.m_objectValue
private

◆ m_operandType

OperandType ScriptStack.Runtime.Operand.m_operandType
private

Dokumentation der Propertys

◆ FunctionPointer

Function ScriptStack.Runtime.Operand.FunctionPointer
getset
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 }
Definition ParserException.cs:11

Wird benutzt von ScriptStack.Runtime.Interpreter.CALL() und ScriptStack.Runtime.Interpreter.RUN().

◆ InstructionPointer

Instruction ScriptStack.Runtime.Operand.InstructionPointer
getset
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 }

Wird benutzt von ScriptStack.Runtime.Executable.Clean(), ScriptStack.Runtime.Interpreter.JMP(), ScriptStack.Runtime.Interpreter.JNZ() und ScriptStack.Runtime.Interpreter.JZ().

◆ Member

object ScriptStack.Runtime.Operand.Member
getset
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 }
Definition ExecutionException.cs:10

Wird benutzt von ScriptStack.Runtime.Interpreter.Assignment(), ScriptStack.Runtime.Interpreter.Evaluate() und ScriptStack.Runtime.Interpreter.POP().

◆ Pointer

string ScriptStack.Runtime.Operand.Pointer
getset
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 }

Wird benutzt von ScriptStack.Runtime.Interpreter.Assignment(), ScriptStack.Runtime.Interpreter.Evaluate() und ScriptStack.Runtime.Interpreter.POP().

◆ RoutinePointer

Routine ScriptStack.Runtime.Operand.RoutinePointer
getset
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 }
A Routine is an abstract representation of a method.
Definition Routine.cs:70

Wird benutzt von ScriptStack.Runtime.Interpreter.INV().

◆ Type

◆ Value


Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: