-
Notifications
You must be signed in to change notification settings - Fork 5
/
CGOxygeneCodeGenerator.swift
748 lines (667 loc) · 22.5 KB
/
CGOxygeneCodeGenerator.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
public enum CGOxygeneCodeGeneratorStyle {
case Standard
case Unified
}
public enum CGOxygeneStringQuoteStyle {
case Single
case Double
case SmartSingle
case SmartDouble
case CodeDomSafe
}
public class CGOxygeneCodeGenerator : CGPascalCodeGenerator {
public init() {
super.init()
// current as of Elements 8.1
keywords = ["abstract", "add", "and", "array", "as", "asc", "aspect", "assembly", "async", "autoreleasepool", "await",
"begin", "block", "break", "by",
"case", "class", "const", "constructor", "continue",
"default", "delegate", "deprecated", "desc", "distinct", "div", "do", "downto", "dynamic",
"each", "else", "empty", "end", "ensure", "enum", "equals", "event", "except", "exit", "extension", "external",
"false", "finalizer", "finally", "flags", "for", "from", "function",
"global", "goto", "group",
"has",
"if", "implementation", "implements", "implies", "in", "index", "inherited", "inline", "interface", "invariants", "is", "iterator",
"join",
"lazy", "lifetimestrategy", "locked", "locking", "loop",
"mapped", "matching", "method", "mod", "module", "namespace",
"nested", "new", "nil", "not", "notify", "nullable",
"of", "old", "on", "operator", "optional", "or", "order", "out", "override",
"parallel", "param", "params", "partial", "pinned", "private", "procedure", "property", "protected", "public", "published",
"queryable", "raise", "raises", "read", "readonly", "record", "reintroduce", "remove", "repeat", "require", "result", "reverse", "sealed",
"select", "selector -", "self", "sequence", "set", "shl", "shr", "skip", "soft", "static", "step", "strong",
"take", "then", "to", "true", "try", "type",
"union", "unit", "unretained", "unsafe", "until", "uses", "using",
"var", "virtual",
"weak", "where", "while", "with", "write",
"xor",
"yield"].ToList() as! List<String>
}
public var Style: CGOxygeneCodeGeneratorStyle = .Standard
public var QuoteStyle: CGOxygeneStringQuoteStyle = .SmartSingle
override var isUnified: Boolean { return Style == .Unified }
override var supportsInterfaceVisibilities: Boolean { return true }
public convenience init(style: CGOxygeneCodeGeneratorStyle) {
init()
Style = style
}
public convenience init(style: CGOxygeneCodeGeneratorStyle, quoteStyle: CGOxygeneStringQuoteStyle) {
init()
Style = style
QuoteStyle = quoteStyle
}
override func generateHeader() {
Append("namespace")
if let namespace = currentUnit.Namespace {
Append(" ")
generateIdentifier(namespace.Name, alwaysEmitNamespace: true)
}
AppendLine(";")
AppendLine()
super.generateHeader()
}
override func generateGlobals() {
if let globals = currentUnit.Globals, globals.Count > 0{
AppendLine("{$GLOBALS ON}")
AppendLine()
}
super.generateGlobals()
}
//
// Types
//
override func pascalGenerateImplementedInterface(_ member: CGMemberDefinition) {
if let implementsInterface = member.ImplementsInterface {
Append(" implements ")
generateTypeReference(implementsInterface)
if let implementsInterfaceMember = member.ImplementsInterfaceMember {
Append(".")
generateIdentifier(implementsInterfaceMember)
}
Append(";")
}
}
//
// Statements
//
override func generateInfiniteLoopStatement(_ statement: CGInfiniteLoopStatement) {
Append("loop")
generateStatementIndentedOrTrailingIfItsABeginEndBlock(statement.NestedStatement)
}
override func generateLockingStatement(_ statement: CGLockingStatement) {
Append("locking ")
generateExpression(statement.Expression)
Append(" do")
generateStatementIndentedOrTrailingIfItsABeginEndBlock(statement.NestedStatement)
}
override func generateUsingStatement(_ statement: CGUsingStatement) {
Append("using ")
if let name = statement.Name {
generateIdentifier(name)
if let type = statement.`Type` {
Append(": ")
generateTypeReference(type)
}
Append(" := ")
}
generateExpression(statement.Value)
Append(" do")
generateStatementIndentedOrTrailingIfItsABeginEndBlock(statement.NestedStatement)
}
override func generateAutoReleasePoolStatement(_ statement: CGAutoReleasePoolStatement) {
Append("using autoreleasepool do")
generateStatementIndentedOrTrailingIfItsABeginEndBlock(statement.NestedStatement)
}
override func generateReturnStatement(_ statement: CGReturnStatement) {
if let value = statement.Value {
Append("exit ")
generateExpression(value)
AppendLine(";")
} else {
AppendLine("exit;")
}
}
override func generateYieldExpression(_ statement: CGYieldExpression) {
Append("yield ")
generateExpression(statement.Value)
}
override func generateVariableDeclarationStatement(_ statement: CGVariableDeclarationStatement) {
Append("var ");
generateIdentifier(statement.Name)
if let type = statement.`Type` {
Append(": ")
generateTypeReference(type)
}
if let value = statement.Value {
Append(" := ")
generateExpression(value)
}
if (statement.ReadOnly) {
Append("; readonly");
}
AppendLine(";")
}
override func generateConstructorCallStatement(_ statement: CGConstructorCallStatement) {
if let callSite = statement.CallSite {
if callSite is CGInheritedExpression {
generateExpression(callSite)
Append(" ")
} else if callSite is CGSelfExpression {
// no-op
} else {
assert(false, "Unsupported call site for constructor call.")
}
}
Append("constructor")
if let name = statement.ConstructorName {
Append(" ")
Append(name)
}
Append("(")
pascalGenerateCallParameters(statement.Parameters)
AppendLine(");")
}
override func generateLocalMethodStatement(_ method: CGLocalMethodStatement) {
Append("method ")
generateIdentifier(method.Name)
if method.Parameters.Count > 0 {
Append("(")
pascalGenerateDefinitionParameters(method.Parameters, implementation: false)
Append(")")
}
if let returnType = method.ReturnType, !returnType.IsVoid {
Append(": ")
returnType.startLocation = currentLocation
generateTypeReference(returnType)
returnType.endLocation = currentLocation
}
AppendLine(";")
AppendLine("begin")
incIndent()
generateStatements(variables: method.LocalVariables)
generateStatements(method.Statements)
decIndent()
AppendLine("end;")
}
//
// Expressions
//
override func generateSelectorExpression(_ expression: CGSelectorExpression) {
Append("selector(\(expression.Name))")
}
override func generateAwaitExpression(_ expression: CGAwaitExpression) {
Append("await ")
generateExpression(expression.Expression)
}
override func generateAnonymousTypeExpression(_ type: CGAnonymousTypeExpression) {
Append("new class ")
if let ancestor = type.Ancestor {
generateTypeReference(ancestor, ignoreNullability: true)
Append(" ")
}
Append("(")
helpGenerateCommaSeparatedList(type.Members) { m in
self.generateIdentifier(m.Name)
self.Append(" := ")
if let member = m as? CGAnonymousPropertyMemberDefinition {
self.generateExpression(member.Value)
} else if let member = m as? CGAnonymousMethodMemberDefinition {
self.Append("method ")
if member.Parameters.Count > 0 {
self.Append("(")
self.pascalGenerateDefinitionParameters(member.Parameters, implementation: false)
self.Append(")")
}
if let returnType = member.ReturnType {
self.Append(": ")
self.generateTypeReference(returnType)
}
self.AppendLine(" begin")
self.incIndent()
self.generateStatements(member.Statements)
self.decIndent()
self.Append("end")
}
}
Append(")")
}
override func generateUnaryOperatorExpression(_ expression: CGUnaryOperatorExpression) {
if let `operator` = expression.Operator, `operator` == .ForceUnwrapNullable {
generateExpression(expression.Value)
Append(" as not nullable")
} else {
super.generateUnaryOperatorExpression(expression)
}
}
override func generateBinaryOperator(_ `operator`: CGBinaryOperatorKind) {
switch (`operator`) {
case .NotEquals: Append("≠")
case .LessThanOrEquals: Append("≤")
case .GreatThanOrEqual: Append("≥")
case .Implies: Append("implies")
case .IsNot: Append("is not")
case .NotIn: Append("not in")
case .AddEvent: Append("+=")
case .RemoveEvent: Append("-=")
default: super.generateBinaryOperator(`operator`)
}
}
override func generateIfThenElseExpression(_ expression: CGIfThenElseExpression) {
Append("(if ")
generateExpression(expression.Condition)
Append(" then (")
generateExpression(expression.IfExpression)
Append(")")
if let elseExpression = expression.ElseExpression {
Append(" else (")
generateExpression(elseExpression)
Append(")")
}
Append(")")
}
override func pascalGenerateCallParameters(_ parameters: List<CGCallParameter>) {
for p in 0 ..< parameters.Count {
let param = parameters[p]
if p > 0 {
if let name = param.Name {
Append(") ")
generateIdentifier(name)
Append("(")
} else {
Append(", ")
}
}
switch param.Modifier {
case .Out: Append("out ")
case .Var: Append("var ")
default:
}
generateExpression(param.Value)
}
}
override func generateParameterDefinition(_ param: CGParameterDefinition) {
switch param.Modifier {
case .Var: Append("var ")
case .Const: Append("const ")
case .Out: Append("out ")
case .Params: Append("params ")
default:
}
generateIdentifier(param.Name)
if let type = param.`Type` {
Append(": ")
generateTypeReference(type)
}
if let defaultValue = param.DefaultValue {
Append(" := ")
generateExpression(defaultValue)
}
}
override func pascalGenerateDefinitionParameters(_ parameters: List<CGParameterDefinition>, implementation: Boolean) {
for p in 0 ..< parameters.Count {
let param = parameters[p]
if p > 0 {
if let name = param.ExternalName {
Append(") ")
param.startLocation = currentLocation
generateIdentifier(name)
Append("(")
} else {
Append("; ")
param.startLocation = currentLocation
}
} else {
param.startLocation = currentLocation
}
if !implementation {
self.generateAttributes(param.Attributes, inline: true)
}
generateParameterDefinition(param)
param.endLocation = currentLocation
}
}
override func generateNewInstanceExpression(_ expression: CGNewInstanceExpression) {
Append("new ")
generateExpression(expression.`Type`, ignoreNullability: true)
if let bounds = expression.ArrayBounds, bounds.Count > 0 {
Append("[")
helpGenerateCommaSeparatedList(bounds) { boundExpression in
self.generateExpression(boundExpression)
}
Append("]")
} else {
if let name = expression.ConstructorName {
Append(" ")
generateIdentifier(name)
}
generateGenericArguments(expression.GenericArguments)
Append("(")
pascalGenerateCallParameters(expression.Parameters)
if let propertyInitializers = expression.PropertyInitializers, propertyInitializers.Count > 0 {
if expression.Parameters.Count > 0 {
Append(", ")
}
helpGenerateCommaSeparatedList(propertyInitializers) { param in
self.Append(param.Name)
self.Append(" := ")
self.generateExpression(param.Value)
}
}
Append(")")
}
}
override func generateStringLiteralExpression(_ expression: CGStringLiteralExpression) {
generateStringLiteralExpression(expression, style: QuoteStyle)
}
public func generateStringLiteralExpression(_ expression: CGStringLiteralExpression, style quoteStyle: CGOxygeneStringQuoteStyle) {
let SINGLE: Char = "'"
let DOUBLE: Char = "\""
let quoteChar: Char
switch quoteStyle {
case .Single: quoteChar = SINGLE
case .Double: quoteChar = DOUBLE
case .CodeDomSafe: fallthrough
case .SmartSingle: quoteChar = expression.Value.Contains(SINGLE) && !expression.Value.Contains(DOUBLE) ? DOUBLE : SINGLE
case .SmartDouble: quoteChar = expression.Value.Contains(DOUBLE) && !expression.Value.Contains(SINGLE) ? SINGLE : DOUBLE
}
if quoteStyle == .CodeDomSafe && length(expression.Value) == 1 {
let ch = expression.Value[0]
switch ord(ch) {
case 34:
Append("\"\"\"\"")
return
case 32...127:
break //process as normal, below
default:
Append("\"\"#\(ord(ch))")
return
}
}
AppendPascalEscapeCharactersInStringLiteral(expression.Value, quoteChar: quoteChar)
}
//
// Type Definitions
//
override func pascalGenerateTypeVisibilityPrefix(_ visibility: CGTypeVisibilityKind) {
if let currentNestedType = currentNestedType {
pascalGenerateMemberVisibilityKeyword(currentNestedType.Visibility)
Append(" ")
} else {
switch visibility {
case .Unspecified: break /* no-op */
case .Unit: Append("unit ")
case .Assembly: Append("assembly ")
case .Public: Append("public ")
}
}
}
override func pascalGenerateMemberVisibilityKeyword(_ visibility: CGMemberVisibilityKind) {
switch visibility {
case .Unspecified: break /* no-op */
case .Private: Append("private")
case .Unit: Append("unit")
case .UnitOrProtected: Append("unit or protected")
case .UnitAndProtected: Append("unit and protected")
case .Assembly: Append("assembly")
case .AssemblyAndProtected: Append("assembly and protected")
case .AssemblyOrProtected: Append("assembly or protected")
case .Protected: Append("protected")
case .Published: Append("published");
case .Public: Append("public")
}
}
override func generateBlockType(_ type: CGBlockTypeDefinition) {
pascalGenerateTypeName(type)
pascalGenerateGenericParameters(type.GenericParameters)
Append(" = ")
pascalGenerateTypeVisibilityPrefix(type.Visibility)
pascalGenerateInlineBlockType(type)
AppendLine(";")
}
func pascalGenerateInlineBlockType(_ block: CGBlockTypeDefinition) {
if block.IsPlainFunctionPointer {
Append("method(")
} else {
Append("block(")
}
if let parameters = block.Parameters, parameters.Count > 0 {
pascalGenerateDefinitionParameters(parameters, implementation: false)
}
Append(")")
if let returnType = block.ReturnType, !returnType.IsVoid {
Append(": ")
generateTypeReference(returnType)
}
}
override func generateExtensionTypeStart(_ type: CGExtensionTypeDefinition) {
pascalGenerateTypeName(type)
pascalGenerateGenericParameters(type.GenericParameters)
Append(" = ")
pascalGenerateTypeVisibilityPrefix(type.Visibility)
pascalGenerateStaticPrefix(type.Static)
Append("extension class")
pascalGenerateAncestorList(type)
pascalGenerateGenericConstraints(type.GenericParameters, needSemicolon: true)
AppendLine()
incIndent()
}
override func generateMappedTypeStart(_ type: CGMappedTypeDefinition) {
pascalGenerateTypeName(type)
pascalGenerateGenericParameters(type.GenericParameters)
Append(" = ")
pascalGenerateTypeVisibilityPrefix(type.Visibility)
pascalGenerateStaticPrefix(type.Static)
Append("class")
pascalGenerateAncestorList(type)
Append(" mapped to ")
generateTypeReference(type.mappedType)
pascalGenerateGenericConstraints(type.GenericParameters, needSemicolon: true)
AppendLine()
incIndent()
}
//
// Type Members
//
override func pascalKeywordForMethod(_ method: CGMethodDefinition) -> String {
return "method"
}
override func pascalGenerateVirtualityModifiders(_ member: CGMemberDefinition) {
switch member.Virtuality {
//case .None
case .Virtual: Append(" virtual;")
case .Abstract: Append(" abstract;")
case .Override: Append(" override;")
case .Final: Append(" final;")
default:
}
if member.Reintroduced {
Append(" reintroduce;")
}
}
override func pascalGenerateConstructorHeader(_ ctor: CGMethodLikeMemberDefinition, type: CGTypeDefinition, methodKeyword: String, implementation: Boolean, includeVisibility: Boolean = false) {
if ctor.Static {
Append("class ")
}
Append("constructor")
if implementation {
Append(" ")
Append(type.Name)
}
if length(ctor.Name) > 0 {
Append(" ")
Append(ctor.Name)
}
pascalGenerateSecondHalfOfMethodHeader(ctor, implementation: implementation, includeVisibility: includeVisibility)
}
internal func pascalGenerateFinalizerHeader(_ method: CGMethodLikeMemberDefinition, type: CGTypeDefinition, implementation: Boolean) {
Append("finalizer")
if implementation {
Append(" ")
pascalGenerateTypeNameForImplementation(type)
}
pascalGenerateSecondHalfOfMethodHeader(method, implementation: implementation)
}
//override func generateDestructorDefinition(_ dtor: CGDestructorDefinition, type: CGTypeDefinition) {
//assert(false, "generateDestructorDefinition is not supported in Oxygene")
//}
override func pascalGenerateDestructorImplementation(_ dtor: CGDestructorDefinition, type: CGTypeDefinition) {
assert(false, "pascalGenerateDestructorImplementation is not supported in Oxygene")
}
override func generateFinalizerDefinition(_ finalizer: CGFinalizerDefinition, type: CGTypeDefinition) {
pascalGenerateFinalizerHeader(finalizer, type: type, implementation: false)
if isUnified && !definitionOnly {
pascalGenerateMethodBody(finalizer, type: type)
}
}
override func pascalGenerateFinalizerImplementation(_ finalizer: CGFinalizerDefinition, type: CGTypeDefinition) {
pascalGenerateFinalizerHeader(finalizer, type: type, implementation: true)
pascalGenerateMethodBody(finalizer, type: type)
}
override func generateEventDefinition(_ event: CGEventDefinition, type: CGTypeDefinition) {
if event.Static {
Append("class ")
}
Append("event ")
Append(event.Name)
if let type = event.`Type` {
Append(": ")
generateTypeReference(type)
}
Append(";")
if !definitionOnly {
//todo: add/remove/raise
}
if isUnified {
Append(" ")
pascalGenerateMemberVisibilityKeyword(event.Visibility)
Append(";")
}
pascalGenerateImplementedInterface(event)
pascalGenerateVirtualityModifiders(event)
AppendLine()
}
override func pascalGenerateEventAccessorDefinition(_ event: CGEventDefinition, type: CGTypeDefinition) {
if !definitionOnly {
if let addStatements = event.AddStatements {
generateMethodDefinition(event.AddMethodDefinition()!, type: type)
}
if let removeStatements = event.RemoveStatements {
generateMethodDefinition(event.RemoveMethodDefinition()!, type: type)
}
}
/*if let raiseStatements = event.RaiseStatements {
generateMethodDefinition(event.RaiseMethodDefinition, type: ttpe)
}*/
}
override func pascalGenerateEventImplementation(_ event: CGEventDefinition, type: CGTypeDefinition) {
if let addStatements = event.AddStatements {
pascalGenerateMethodImplementation(event.AddMethodDefinition()!, type: type)
}
if let removeStatements = event.RemoveStatements {
pascalGenerateMethodImplementation(event.RemoveMethodDefinition()!, type: type)
}
/*if let raiseStatements = event.RaiseStatements {
pascalGenerateMethodImplementation(event.RaiseMethodDefinition, type: ttpe)
}*/
}
//
// Type References
//
func pascalGeneratePrefixForNullability(_ type: CGTypeReference) {
if (type.Nullability == CGTypeNullabilityKind.NullableUnwrapped && (type.DefaultNullability == CGTypeNullabilityKind.NotNullable || type.DefaultNullability == CGTypeNullabilityKind.Unknown)) || type.Nullability == CGTypeNullabilityKind.NullableNotUnwrapped {
Append("nullable ")
} else if type.Nullability == CGTypeNullabilityKind.NotNullable && (type.DefaultNullability == CGTypeNullabilityKind.NullableUnwrapped || type.DefaultNullability == CGTypeNullabilityKind.NullableNotUnwrapped || type.DefaultNullability == CGTypeNullabilityKind.Unknown) {
Append("not nullable ")
}
}
override func generateNamedTypeReference(_ type: CGNamedTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(type)
}
super.generateNamedTypeReference(type, ignoreNullability: ignoreNullability)
}
override func generatePredefinedTypeReference(_ type: CGPredefinedTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(type)
}
switch (type.Kind) {
case .Int: Append("NativeInt")
case .UInt: Append("NativeUInt")
case .Int8: Append("SByte")
case .UInt8: Append("Byte")
case .Int16: Append("Int16")
case .UInt16: Append("UInt16")
case .Int32: Append("Integer")
case .UInt32: Append("UInt32")
case .Int64: Append("Int64")
case .UInt64: Append("UInt64")
case .IntPtr: Append("IntPrt")
case .UIntPtr: Append("UIntPtr")
case .Single: Append("Single")
case .Double: Append("Double")
case .Boolean: Append("Boolean")
case .String: Append("String")
case .AnsiChar: Append("AnsiChar")
case .UTF16Char: Append("Char")
case .UTF32Char: Append("UInt32") // tood?
case .Dynamic: Append("dynamic")
case .InstanceType: Append("InstanceType")
case .Void: Append("Void")
case .Object: Append("Object")
case .Class: generateIdentifier("Class") // todo: make platform-specific
}
}
override func generateInlineBlockTypeReference(_ type: CGInlineBlockTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(type)
}
pascalGenerateInlineBlockType(type.Block)
}
override func generatePointerTypeReference(_ type: CGPointerTypeReference) {
//74809: Silver: compiler doesn't see enum member when using shortcut syntax
if (type.`Type` as? CGPredefinedTypeReference)?.Kind == CGPredefinedTypeKind.Void {
Append("^Void")
} else {
Append("^")
generateTypeReference(type.`Type`)
}
}
override func generateKindOfTypeReference(_ type: CGKindOfTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(type)
}
Append("dynamic<")
generateTypeReference(type.`Type`)
Append(">")
}
override func generateTupleTypeReference(_ type: CGTupleTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(type)
}
Append("tuple of (")
for m in 0 ..< type.Members.Count {
if m > 0 {
Append(", ")
}
generateTypeReference(type.Members[m])
}
Append(")")
}
override func generateSequenceTypeReference(_ sequence: CGSequenceTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(sequence)
}
Append("sequence of ")
generateTypeReference(sequence.`Type`)
}
override func generateDictionaryTypeReference(_ type: CGDictionaryTypeReference, ignoreNullability: Boolean = false) {
if !ignoreNullability {
pascalGeneratePrefixForNullability(type)
}
super.generateDictionaryTypeReference(type, ignoreNullability: ignoreNullability)
}
override internal func generateMetaTypeReference(_ type: CGMetaTypeReference, ignoreNullability: Boolean = false) {
Append("class of ")
generateTypeReference(type.Type)
}
}