ScriptStack 1.0.5
Loading...
Searching...
No Matches
ScriptStack.Runtime.Instruction Class Reference

An instruction in a virtual intermediate language. More...

Public Member Functions

 Instruction (OpCode opcode, Operand first, Operand second)
 Instruction (OpCode opcode, Operand operand0)
 Instruction (OpCode opcode)
override string ToString ()

Properties

uint Address [get, set]
OpCode OpCode [get, set]
Operand First [get, set]
Operand Second [get, set]

Private Member Functions

string ToLiteral (string input)

Private Attributes

uint address
OpCode opcode
Operand first
Operand second

Detailed Description

An instruction in a virtual intermediate language.

Definition at line 11 of file Instruction.cs.

Constructor & Destructor Documentation

◆ Instruction() [1/3]

ScriptStack.Runtime.Instruction.Instruction ( OpCode opcode,
Operand first,
Operand second )

Definition at line 65 of file Instruction.cs.

66 {
67 address = 0;
68 this.opcode = opcode;
69 this.first = first;
70 this.second = second;
71 }

References address, first, OpCode, opcode, and second.

◆ Instruction() [2/3]

ScriptStack.Runtime.Instruction.Instruction ( OpCode opcode,
Operand operand0 )

Definition at line 73 of file Instruction.cs.

74 : this(opcode, operand0, null)
75 {
76 }

References OpCode, and opcode.

◆ Instruction() [3/3]

ScriptStack.Runtime.Instruction.Instruction ( OpCode opcode)

Definition at line 78 of file Instruction.cs.

79 : this(opcode, null, null)
80 {
81 }

References OpCode, and opcode.

Member Function Documentation

◆ ToLiteral()

string ScriptStack.Runtime.Instruction.ToLiteral ( string input)
private

Definition at line 25 of file Instruction.cs.

26 {
27 var literal = new StringBuilder(input.Length + 2);
28 //literal.Append("\"");
29 foreach (var c in input)
30 {
31 switch (c)
32 {
33 case '\'': literal.Append(@"\'"); break;
34 case '\"': literal.Append("\\\""); break;
35 case '\\': literal.Append(@"\\"); break;
36 case '\0': literal.Append(@"\0"); break;
37 case '\a': literal.Append(@"\a"); break;
38 case '\b': literal.Append(@"\b"); break;
39 case '\f': literal.Append(@"\f"); break;
40 case '\n': literal.Append(@"\n"); break;
41 case '\r': literal.Append(@"\r"); break;
42 case '\t': literal.Append(@"\t"); break;
43 case '\v': literal.Append(@"\v"); break;
44 default:
45 if (Char.GetUnicodeCategory(c) != System.Globalization.UnicodeCategory.Control)
46 {
47 literal.Append(c);
48 }
49 else
50 {
51 literal.Append(@"\u");
52 literal.Append(((ushort)c).ToString("x4"));
53 }
54 break;
55 }
56 }
57 //literal.Append("\"");
58 return literal.ToString();
59 }

References ToString().

◆ ToString()

override string ScriptStack.Runtime.Instruction.ToString ( )

Definition at line 83 of file Instruction.cs.

84 {
85
86 if (opcode == OpCode.DBG)
87 {
88
89 int lineNumber = (int)first.Value;
90 return "Verarbeite Zeile: " + lineNumber + "\n" + second.Value;
91
92 }
93
94 StringBuilder stringBuilder = new StringBuilder();
95
96 stringBuilder.Append("["+string.Format(address.ToString("X8"))+"]");
97 stringBuilder.Append(" ");
98
99 stringBuilder.Append(opcode.ToString());
100 int iOpcodeLength = opcode.ToString().Length;
101 if (iOpcodeLength == 2)
102 stringBuilder.Append(" ");
103 if (iOpcodeLength == 3)
104 stringBuilder.Append(" ");
105
106 if (first != null)
107 {
108 stringBuilder.Append(" ");
109 stringBuilder.Append(first.ToString());
110 }
111
112 if (second != null)
113 {
114 stringBuilder.Append(", ");
115 stringBuilder.Append(second.ToString());
116 }
117
118 return stringBuilder.ToString();
119 }

References address, first, OpCode, opcode, and second.

Referenced by ToLiteral().

Member Data Documentation

◆ address

uint ScriptStack.Runtime.Instruction.address
private

Definition at line 16 of file Instruction.cs.

Referenced by Instruction(), and ToString().

◆ first

Operand ScriptStack.Runtime.Instruction.first
private

Definition at line 18 of file Instruction.cs.

Referenced by Instruction(), and ToString().

◆ opcode

OpCode ScriptStack.Runtime.Instruction.opcode
private

Definition at line 17 of file Instruction.cs.

Referenced by Instruction(), Instruction(), Instruction(), and ToString().

◆ second

Operand ScriptStack.Runtime.Instruction.second
private

Definition at line 19 of file Instruction.cs.

Referenced by Instruction(), and ToString().

Property Documentation

◆ Address

uint ScriptStack.Runtime.Instruction.Address
getset

Definition at line 125 of file Instruction.cs.

126 {
127 get { return address; }
128 set { address = value; }
129 }

Referenced by ScriptStack.Runtime.Executable.Clean(), ScriptStack.Runtime.Interpreter.JZ(), and ScriptStack.Runtime.Operand.ToString().

◆ First

Operand ScriptStack.Runtime.Instruction.First
getset

Definition at line 137 of file Instruction.cs.

138 {
139 get { return first; }
140 set { first = value; }
141 }

◆ OpCode

OpCode ScriptStack.Runtime.Instruction.OpCode
getset

Definition at line 131 of file Instruction.cs.

132 {
133 get { return opcode; }
134 set { opcode = value; }
135 }

Referenced by ScriptStack.Runtime.Executable.Clean(), Instruction(), Instruction(), Instruction(), and ToString().

◆ Second

Operand ScriptStack.Runtime.Instruction.Second
getset

Definition at line 143 of file Instruction.cs.

144 {
145 get { return second; }
146 set { second = value; }
147 }

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