Skip to content

Commit 71c8946

Browse files
committed
- Adicionado recurso de zoom ao editor de código fonte.
- Atualizado a versão do componente AvalonEdit para a mais recente. - Realizada algumas refatorações automáticas de código.
1 parent 27f3d11 commit 71c8946

32 files changed

+595
-555
lines changed

Asm/Assembler.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ public Assembler()
5151
writer = new BinaryWriter(output);
5252
constantOut = new MemoryStream();
5353
constantWritter = new BinaryWriter(constantOut);
54-
issuedLabels = new List<Label>();
55-
bindedLabels = new List<Label>();
56-
externalFunctions = new List<(string, int)>();
57-
sourceCodeLines = new List<(string, int, int)>();
58-
sourceCodeLineMap = new Dictionary<(string, int), int>();
59-
globalVariables = new List<GlobalVariable>();
60-
localVariables = new List<LocalVariable>();
61-
functions = new List<Function>();
54+
issuedLabels = [];
55+
bindedLabels = [];
56+
externalFunctions = [];
57+
sourceCodeLines = [];
58+
sourceCodeLineMap = [];
59+
globalVariables = [];
60+
localVariables = [];
61+
functions = [];
6262
}
6363

6464
public void AddExternalFunctionNames((string, int)[] entries)
@@ -348,7 +348,7 @@ public void Emit(Assembler other)
348348

349349
for (int i = 0; i < other.issuedLabels.Count; i++)
350350
{
351-
Label label = other.issuedLabels[i];
351+
var label = other.issuedLabels[i];
352352

353353
for (int j = 0; j < label.references.Count; j++)
354354
{
@@ -360,7 +360,7 @@ public void Emit(Assembler other)
360360
issuedLabels.Add(label);
361361
}
362362

363-
foreach (Label label in other.bindedLabels)
363+
foreach (var label in other.bindedLabels)
364364
{
365365
label.bindedAssembler = this;
366366
label.bindedIP += (int) startPosition;

Asm/Label.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ internal Label()
2121
bindedAssembler = null;
2222
bindedIP = -1;
2323

24-
references = new List<(Assembler, int)>();
24+
references = [];
2525
}
2626

2727
private void UpdateReference(Assembler assembler, int index)
2828
{
29-
(Assembler, int) reference = references[index];
30-
Assembler referenceAssembler = reference.Item1;
29+
var reference = references[index];
30+
var referenceAssembler = reference.Item1;
3131
if (assembler != referenceAssembler)
3232
return;
3333

Comp/CompilationUnity.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ internal CompilationUnity(Compiler compiler, string name, string fileName, bool
9595
FileName = fileName;
9696
IsUnity = isUnity;
9797

98-
imports = new();
99-
importTable = new();
100-
globals = new();
101-
globalTable = new();
102-
fieldAggregations = new();
103-
fieldAggregationTable = new();
104-
typeSets = new();
105-
typeSetTable = new();
106-
functions = new();
107-
functionTable = new();
108-
stringTable = new();
109-
undeclaredTypes = new();
110-
undeclaredTypeTable = new();
98+
imports = [];
99+
importTable = [];
100+
globals = [];
101+
globalTable = [];
102+
fieldAggregations = [];
103+
fieldAggregationTable = [];
104+
typeSets = [];
105+
typeSetTable = [];
106+
functions = [];
107+
functionTable = [];
108+
stringTable = [];
109+
undeclaredTypes = [];
110+
undeclaredTypeTable = [];
111111

112112
GlobalVariableSize = 0;
113113
EntryPoint = null;
@@ -117,7 +117,7 @@ internal CompilationUnity(Compiler compiler, string name, string fileName, bool
117117

118118
internal ImportResult AddImport(string unityName, out CompilationUnity result)
119119
{
120-
CompilationUnity unity = Compiler.OpenUnity(unityName);
120+
var unity = Compiler.OpenUnity(unityName);
121121
if (unity == null)
122122
{
123123
result = null;
@@ -153,7 +153,7 @@ public CompilationUnity GetImport(int index)
153153

154154
public CompilationUnity GetImport(string name)
155155
{
156-
return importTable.TryGetValue(name, out CompilationUnity result) ? result : null;
156+
return importTable.TryGetValue(name, out var result) ? result : null;
157157
}
158158

159159
public int GetStringOffset(string value)
@@ -170,12 +170,12 @@ public int GetStringOffset(string value)
170170

171171
public GlobalVariable FindGlobalVariable(string name, bool searchInImports = true)
172172
{
173-
if (globalTable.TryGetValue(name, out GlobalVariable result))
173+
if (globalTable.TryGetValue(name, out var result))
174174
return result;
175175

176176
if (searchInImports)
177177
{
178-
foreach (CompilationUnity unity in imports)
178+
foreach (var unity in imports)
179179
{
180180
result = unity.FindGlobalVariable(name, false);
181181
if (result != null)
@@ -193,7 +193,7 @@ public GlobalVariable GetGlobalVariable(int index)
193193

194194
internal GlobalVariable DeclareGlobalVariable(string name, AbstractType type, SourceInterval interval)
195195
{
196-
GlobalVariable result = FindGlobalVariable(name);
196+
var result = FindGlobalVariable(name);
197197
if (result != null)
198198
return null;
199199

@@ -205,7 +205,7 @@ internal GlobalVariable DeclareGlobalVariable(string name, AbstractType type, So
205205

206206
internal GlobalVariable DeclareGlobalVariable(string name, AbstractType type, SourceInterval interval, object initialValue)
207207
{
208-
GlobalVariable result = FindGlobalVariable(name);
208+
var result = FindGlobalVariable(name);
209209
if (result != null)
210210
return null;
211211

@@ -218,12 +218,12 @@ internal GlobalVariable DeclareGlobalVariable(string name, AbstractType type, So
218218

219219
public FieldAggregationType FindFieldAggregation(string name, bool searchInImports = true)
220220
{
221-
if (fieldAggregationTable.TryGetValue(name, out FieldAggregationType result))
221+
if (fieldAggregationTable.TryGetValue(name, out var result))
222222
return result;
223223

224224
if (searchInImports)
225225
{
226-
foreach (CompilationUnity unity in imports)
226+
foreach (var unity in imports)
227227
{
228228
result = unity.FindFieldAggregation(name, false);
229229
if (result != null)
@@ -241,7 +241,7 @@ public FieldAggregationType GeFieldAggregation(int index)
241241

242242
internal StructType DeclareStruct(string name, SourceInterval interval)
243243
{
244-
NamedType nt = FindNamedType(name);
244+
var nt = FindNamedType(name);
245245
if (nt != null)
246246
return null;
247247

@@ -253,7 +253,7 @@ internal StructType DeclareStruct(string name, SourceInterval interval)
253253

254254
internal ClassType DeclareClass(string name, SourceInterval interval)
255255
{
256-
NamedType nt = FindNamedType(name);
256+
var nt = FindNamedType(name);
257257
if (nt != null)
258258
return null;
259259

@@ -265,12 +265,12 @@ internal ClassType DeclareClass(string name, SourceInterval interval)
265265

266266
public TypeSetType FindTypeSet(string name, bool searchInImports = true)
267267
{
268-
if (typeSetTable.TryGetValue(name, out TypeSetType result))
268+
if (typeSetTable.TryGetValue(name, out var result))
269269
return result;
270270

271271
if (searchInImports)
272272
{
273-
foreach (CompilationUnity unity in imports)
273+
foreach (var unity in imports)
274274
{
275275
result = unity.FindTypeSet(name, false);
276276
if (result != null)
@@ -288,7 +288,7 @@ public TypeSetType GetTypeSet(int index)
288288

289289
internal TypeSetType DeclareTypeSet(string name, AbstractType type, SourceInterval interval)
290290
{
291-
NamedType nt = FindNamedType(name);
291+
var nt = FindNamedType(name);
292292
if (nt != null)
293293
return null;
294294

@@ -300,18 +300,18 @@ internal TypeSetType DeclareTypeSet(string name, AbstractType type, SourceInterv
300300

301301
public NamedType FindNamedType(string name)
302302
{
303-
FieldAggregationType st = FindFieldAggregation(name);
303+
var st = FindFieldAggregation(name);
304304
return st != null ? st : FindTypeSet(name);
305305
}
306306

307307
public Function FindFunction(string name, bool searchInImports = true)
308308
{
309-
if (functionTable.TryGetValue(name, out Function result))
309+
if (functionTable.TryGetValue(name, out var result))
310310
return result;
311311

312312
if (searchInImports)
313313
{
314-
foreach (CompilationUnity unity in imports)
314+
foreach (var unity in imports)
315315
{
316316
result = unity.FindFunction(name, false);
317317
if (result != null)
@@ -324,7 +324,7 @@ public Function FindFunction(string name, bool searchInImports = true)
324324

325325
internal Function DeclareFunction(FieldAggregationType declaringType, string name, SourceInterval interval, bool isExtern)
326326
{
327-
Function result = FindFunction(name);
327+
var result = FindFunction(name);
328328
if (result != null)
329329
return null;
330330

@@ -336,12 +336,12 @@ internal Function DeclareFunction(FieldAggregationType declaringType, string nam
336336

337337
internal UnresolvedType FindUndeclaredType(string name)
338338
{
339-
return undeclaredTypeTable.TryGetValue(name, out UnresolvedType result) ? result : null;
339+
return undeclaredTypeTable.TryGetValue(name, out var result) ? result : null;
340340
}
341341

342342
internal UnresolvedType AddUndeclaredType(string name, SourceInterval interval)
343343
{
344-
UnresolvedType result = FindUndeclaredType(name);
344+
var result = FindUndeclaredType(name);
345345
if (result != null)
346346
return result;
347347

@@ -384,28 +384,28 @@ internal void WriteConstants(Assembler assembler)
384384

385385
internal void Resolve()
386386
{
387-
foreach (UnresolvedType type in undeclaredTypes)
387+
foreach (var type in undeclaredTypes)
388388
{
389-
FieldAggregationType st = FindFieldAggregation(type.Name);
389+
var st = FindFieldAggregation(type.Name);
390390

391391
type.ReferencedType = st ?? throw new CompilerException(type.Interval, $"Tipo não declarado: '{type.Name}'.");
392392
}
393393

394-
foreach (FieldAggregationType st in fieldAggregations)
394+
foreach (var st in fieldAggregations)
395395
st.Resolve();
396396

397-
foreach (TypeSetType ts in typeSets)
397+
foreach (var ts in typeSets)
398398
ts.Resolve();
399399

400400
GlobalVariableSize = 0;
401-
foreach (GlobalVariable global in globals)
401+
foreach (var global in globals)
402402
{
403403
global.Resolve();
404404
global.Offset = GlobalVariableSize;
405405
GlobalVariableSize += Compiler.GetAlignedSize(global.Type.Size);
406406
}
407407

408-
foreach (Function function in functions)
408+
foreach (var function in functions)
409409
function.Resolve();
410410

411411
undeclaredTypes.Clear();
@@ -417,8 +417,8 @@ internal void EmitStringRelease(Assembler assembler)
417417
Context context = new(this, Interval);
418418
for (int i = 0; i < globals.Count; i++)
419419
{
420-
GlobalVariable g = globals[i];
421-
AbstractType type = g.Type;
420+
var g = globals[i];
421+
var type = g.Type;
422422
type.EmitStringRelease(context, Compiler, assembler, GlobalStartOffset + g.Offset, AbstractType.ReleaseType.GLOBAL);
423423
}
424424
}

0 commit comments

Comments
 (0)