-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathlibfut.hpp
3038 lines (2923 loc) · 116 KB
/
libfut.hpp
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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Generated automatically with "fut". Do not edit.
#pragma once
#include <array>
#include <cstdint>
#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define FU_ENUM_FLAG_OPERATORS(T) \
inline constexpr T operator~(T a) { return static_cast<T>(~static_cast<std::underlying_type_t<T>>(a)); } \
inline constexpr T operator&(T a, T b) { return static_cast<T>(static_cast<std::underlying_type_t<T>>(a) & static_cast<std::underlying_type_t<T>>(b)); } \
inline constexpr T operator|(T a, T b) { return static_cast<T>(static_cast<std::underlying_type_t<T>>(a) | static_cast<std::underlying_type_t<T>>(b)); } \
inline constexpr T operator^(T a, T b) { return static_cast<T>(static_cast<std::underlying_type_t<T>>(a) ^ static_cast<std::underlying_type_t<T>>(b)); } \
inline constexpr T &operator&=(T &a, T b) { return (a = a & b); } \
inline constexpr T &operator|=(T &a, T b) { return (a = a | b); } \
inline constexpr T &operator^=(T &a, T b) { return (a = a ^ b); }
enum class RegexOptions
{
none = 0,
ignoreCase = 1,
multiline = 2,
singleline = 16
};
FU_ENUM_FLAG_OPERATORS(RegexOptions)
class FuParserHost;
enum class FuToken
{
endOfFile,
id,
literalLong,
literalDouble,
literalChar,
literalString,
interpolatedString,
semicolon,
dot,
comma,
leftParenthesis,
rightParenthesis,
leftBracket,
rightBracket,
leftBrace,
rightBrace,
plus,
minus,
asterisk,
slash,
mod,
and_,
or_,
xor_,
tilde,
shiftLeft,
shiftRight,
equal,
notEqual,
less,
lessOrEqual,
greater,
greaterOrEqual,
rightAngle,
condAnd,
condOr,
exclamationMark,
hash,
assign,
addAssign,
subAssign,
mulAssign,
divAssign,
modAssign,
andAssign,
orAssign,
xorAssign,
shiftLeftAssign,
shiftRightAssign,
increment,
decrement,
questionMark,
colon,
fatArrow,
range,
docRegular,
docBullet,
docBlank,
abstract,
assert,
break_,
case_,
class_,
const_,
continue_,
default_,
do_,
else_,
enum_,
false_,
for_,
foreach,
if_,
in,
internal,
is,
lock_,
native,
new_,
null,
override_,
protected_,
public_,
resource,
return_,
sealed,
static_,
switch_,
throw_,
throws,
true_,
virtual_,
void_,
when,
while_,
endOfLine,
preUnknown,
preIf,
preElIf,
preElse,
preEndIf
};
enum class FuPreState
{
notYet,
already,
alreadyElse
};
class FuLexer;
enum class FuVisibility
{
private_,
internal,
protected_,
public_,
numericElementType,
finalValueType
};
enum class FuCallType
{
static_,
normal,
abstract,
virtual_,
override_,
sealed
};
enum class FuPriority
{
statement,
argument,
assign,
select,
selectCond,
condOr,
condAnd,
or_,
xor_,
and_,
equality,
rel,
shift,
add,
mul,
primary
};
enum class FuId
{
none,
voidType,
nullType,
basePtr,
typeParam0,
typeParam0NotFinal,
typeParam0Predicate,
sByteRange,
byteRange,
shortRange,
uShortRange,
intType,
nIntType,
longType,
floatType,
doubleType,
floatIntType,
floatingType,
numericType,
boolType,
stringClass,
stringPtrType,
stringStorageType,
mainArgsType,
arrayPtrClass,
arrayStorageClass,
exceptionClass,
listClass,
queueClass,
stackClass,
priorityQueueClass,
hashSetClass,
sortedSetClass,
dictionaryClass,
sortedDictionaryClass,
orderedDictionaryClass,
textWriterClass,
stringWriterClass,
regexOptionsEnum,
regexClass,
matchClass,
jsonElementClass,
lockClass,
stringLength,
arrayLength,
consoleError,
main,
classToString,
matchStart,
matchEnd,
matchLength,
matchValue,
mathNaN,
mathNegativeInfinity,
mathPositiveInfinity,
enumFromInt,
enumHasFlag,
intTryParse,
nIntTryParse,
longTryParse,
doubleTryParse,
stringContains,
stringEndsWith,
stringIndexOf,
stringLastIndexOf,
stringReplace,
stringStartsWith,
stringSubstring,
stringToLower,
stringToUpper,
arrayBinarySearchAll,
arrayBinarySearchPart,
arrayContains,
arrayCopyTo,
arrayFillAll,
arrayFillPart,
arraySortAll,
arraySortPart,
listAdd,
listAddRange,
listAll,
listAny,
listClear,
listContains,
listCopyTo,
listCount,
listIndexOf,
listInsert,
listLast,
listRemoveAt,
listRemoveRange,
listSortAll,
listSortPart,
queueClear,
queueCount,
queueDequeue,
queueEnqueue,
queuePeek,
stackClear,
stackCount,
stackPeek,
stackPush,
stackPop,
priorityQueueClear,
priorityQueueCount,
priorityQueueDequeue,
priorityQueueEnqueue,
priorityQueuePeek,
hashSetAdd,
hashSetClear,
hashSetContains,
hashSetCount,
hashSetRemove,
sortedSetAdd,
sortedSetClear,
sortedSetContains,
sortedSetCount,
sortedSetRemove,
dictionaryAdd,
dictionaryClear,
dictionaryContainsKey,
dictionaryCount,
dictionaryRemove,
sortedDictionaryClear,
sortedDictionaryContainsKey,
sortedDictionaryCount,
sortedDictionaryRemove,
orderedDictionaryClear,
orderedDictionaryContainsKey,
orderedDictionaryCount,
orderedDictionaryRemove,
textWriterWrite,
textWriterWriteChar,
textWriterWriteCodePoint,
textWriterWriteLine,
consoleWrite,
consoleWriteLine,
stringWriterClear,
stringWriterToString,
convertToBase64String,
uTF8GetByteCount,
uTF8GetBytes,
uTF8GetString,
environmentGetEnvironmentVariable,
regexCompile,
regexEscape,
regexIsMatchStr,
regexIsMatchRegex,
matchFindStr,
matchFindRegex,
matchGetCapture,
jsonElementParse,
jsonElementIsObject,
jsonElementIsArray,
jsonElementIsString,
jsonElementIsNumber,
jsonElementIsBoolean,
jsonElementIsNull,
jsonElementGetObject,
jsonElementGetArray,
jsonElementGetString,
jsonElementGetDouble,
jsonElementGetBoolean,
mathMethod,
mathAbs,
mathCeiling,
mathClamp,
mathFusedMultiplyAdd,
mathIsFinite,
mathIsInfinity,
mathIsNaN,
mathLog2,
mathMax,
mathMin,
mathRound,
mathTruncate
};
class FuDocInline;
class FuDocText;
class FuDocCode;
class FuDocLine;
class FuDocBlock;
class FuDocPara;
class FuDocList;
class FuCodeDoc;
class FuVisitor;
class FuStatement;
class FuExpr;
class FuName;
class FuSymbol;
class FuScope;
class FuAggregateInitializer;
class FuLiteral;
class FuLiteralNull;
class FuLiteralFalse;
class FuLiteralTrue;
class FuLiteralLong;
class FuLiteralChar;
class FuLiteralDouble;
class FuLiteralString;
class FuInterpolatedPart;
class FuInterpolatedString;
class FuImplicitEnumValue;
class FuSymbolReference;
class FuUnaryExpr;
class FuPrefixExpr;
class FuPostfixExpr;
class FuBinaryExpr;
class FuSelectExpr;
class FuCallExpr;
class FuLambdaExpr;
class FuCondCompletionStatement;
class FuBlock;
class FuAssert;
class FuLoop;
class FuBreak;
class FuContinue;
class FuDoWhile;
class FuFor;
class FuForeach;
class FuIf;
class FuLock;
class FuNative;
class FuReturn;
class FuCase;
class FuSwitch;
class FuThrow;
class FuWhile;
class FuParameters;
class FuType;
class FuNumericType;
class FuIntegerType;
class FuRangeType;
class FuFloatingType;
class FuNamedValue;
class FuMember;
class FuVar;
enum class FuVisitStatus
{
notYet,
inProgress,
done
};
class FuConst;
class FuField;
class FuProperty;
class FuStaticProperty;
class FuThrowsDeclaration;
class FuMethodBase;
class FuMethod;
class FuMethodGroup;
class FuContainerType;
class FuEnum;
class FuEnumFlags;
class FuClass;
class FuClassType;
class FuReadWriteClassType;
class FuOwningType;
class FuStorageType;
class FuDynamicPtrType;
class FuArrayStorageType;
class FuStringType;
class FuStringStorageType;
class FuPrintableType;
class FuSystem;
class FuSourceFile;
class FuProgram;
class FuParser;
class FuConsoleHost;
class FuSemaHost;
class FuSema;
class GenHost;
class GenBase;
class GenTyped;
class GenCCppD;
class GenCCpp;
class GenC;
class GenCl;
class GenCpp;
class GenCs;
class GenD;
class GenJava;
class GenJsNoModule;
class GenJs;
class GenTs;
class GenPySwift;
class GenSwift;
class GenPy;
class FuParserHost
{
public:
virtual ~FuParserHost() = default;
virtual void reportError(std::string_view filename, int line, int startUtf16Column, int endUtf16Column, std::string_view message) = 0;
protected:
FuParserHost() = default;
public:
FuProgram * program;
void reportStatementError(const FuStatement * statement, std::string_view message);
};
class FuLexer
{
public:
virtual ~FuLexer() = default;
void setHost(FuParserHost * host);
void addPreSymbol(std::string_view symbol);
protected:
FuLexer() = default;
uint8_t const * input;
int charOffset;
FuParserHost * host;
int loc = 0;
int tokenLoc;
int lexemeOffset;
FuToken currentToken;
int64_t longValue;
std::string stringValue;
bool parsingTypeArg = false;
void open(std::string_view filename, uint8_t const * input, int inputLength);
void reportError(std::string_view message) const;
int peekChar() const;
int readChar();
FuToken readString(bool interpolated);
std::string getLexeme() const;
bool see(FuToken token) const;
bool check(FuToken expected) const;
FuToken nextToken();
bool eat(FuToken token);
bool expect(FuToken expected);
void expectOrSkip(FuToken expected);
public:
static bool isLetterOrDigit(int c);
static int getEscapedChar(int c);
static std::string_view tokenToString(FuToken token);
private:
int inputLength;
int nextOffset;
int nextChar;
std::unordered_set<std::string> preSymbols;
bool atLineStart = true;
bool lineMode = false;
bool skippingUnmet = false;
std::stack<bool> preElseStack;
int readByte();
static constexpr int replacementChar = 65533;
int readContinuationByte(int hi);
void fillNextChar();
bool eatChar(int c);
void skipWhitespace();
FuToken readIntegerLiteral(int bits);
FuToken readFloatLiteral(bool needDigit);
FuToken readNumberLiteral(int64_t i);
int readCharLiteral();
bool endWord(int c);
FuToken readPreToken();
void nextPreToken();
bool eatPre(FuToken token);
bool parsePrePrimary();
bool parsePreEquality();
bool parsePreAnd();
bool parsePreOr();
bool parsePreExpr();
void expectEndOfLine(std::string_view directive);
bool popPreElse(std::string_view directive);
void skipUnmet(FuPreState state);
FuToken readToken();
};
class FuDocInline
{
public:
virtual ~FuDocInline() = default;
protected:
FuDocInline() = default;
};
class FuDocText : public FuDocInline
{
public:
FuDocText() = default;
public:
std::string text;
};
class FuDocCode : public FuDocInline
{
public:
FuDocCode() = default;
public:
std::string text;
};
class FuDocLine : public FuDocInline
{
public:
FuDocLine() = default;
};
class FuDocBlock
{
public:
virtual ~FuDocBlock() = default;
protected:
FuDocBlock() = default;
};
class FuDocPara : public FuDocBlock
{
public:
FuDocPara() = default;
public:
std::vector<std::shared_ptr<FuDocInline>> children;
};
class FuDocList : public FuDocBlock
{
public:
FuDocList() = default;
public:
std::vector<FuDocPara> items;
};
class FuCodeDoc
{
public:
FuCodeDoc() = default;
public:
FuDocPara summary;
std::vector<std::shared_ptr<FuDocBlock>> details;
};
class FuVisitor
{
public:
virtual ~FuVisitor() = default;
protected:
FuVisitor() = default;
void visitOptionalStatement(const FuStatement * statement);
public:
virtual void visitConst(const FuConst * statement) = 0;
virtual void visitExpr(const FuExpr * statement) = 0;
virtual void visitBlock(const FuBlock * statement) = 0;
virtual void visitAssert(const FuAssert * statement) = 0;
virtual void visitBreak(const FuBreak * statement) = 0;
virtual void visitContinue(const FuContinue * statement) = 0;
virtual void visitDoWhile(const FuDoWhile * statement) = 0;
virtual void visitFor(const FuFor * statement) = 0;
virtual void visitForeach(const FuForeach * statement) = 0;
virtual void visitIf(const FuIf * statement) = 0;
virtual void visitLock(const FuLock * statement) = 0;
virtual void visitNative(const FuNative * statement) = 0;
virtual void visitReturn(const FuReturn * statement) = 0;
virtual void visitSwitch(const FuSwitch * statement) = 0;
virtual void visitThrow(const FuThrow * statement) = 0;
virtual void visitWhile(const FuWhile * statement) = 0;
virtual void visitEnumValue(const FuConst * konst, const FuConst * previous) = 0;
virtual void visitLiteralNull() = 0;
virtual void visitLiteralFalse() = 0;
virtual void visitLiteralTrue() = 0;
virtual void visitLiteralLong(int64_t value) = 0;
virtual void visitLiteralChar(int value) = 0;
virtual void visitLiteralDouble(double value) = 0;
virtual void visitLiteralString(std::string_view value) = 0;
virtual void visitAggregateInitializer(const FuAggregateInitializer * expr) = 0;
virtual void visitInterpolatedString(const FuInterpolatedString * expr, FuPriority parent) = 0;
virtual void visitSymbolReference(const FuSymbolReference * expr, FuPriority parent) = 0;
virtual void visitPrefixExpr(const FuPrefixExpr * expr, FuPriority parent) = 0;
virtual void visitPostfixExpr(const FuPostfixExpr * expr, FuPriority parent) = 0;
virtual void visitBinaryExpr(const FuBinaryExpr * expr, FuPriority parent) = 0;
virtual void visitSelectExpr(const FuSelectExpr * expr, FuPriority parent) = 0;
virtual void visitCallExpr(const FuCallExpr * expr, FuPriority parent) = 0;
virtual void visitLambdaExpr(const FuLambdaExpr * expr) = 0;
virtual void visitVar(const FuVar * expr) = 0;
};
class FuStatement
{
public:
virtual ~FuStatement() = default;
virtual int getLocLength() const;
virtual bool completesNormally() const = 0;
virtual void acceptStatement(FuVisitor * visitor) const = 0;
protected:
FuStatement() = default;
public:
int loc = 0;
};
class FuExpr : public FuStatement
{
public:
virtual ~FuExpr() = default;
bool completesNormally() const override;
virtual std::string toString() const;
virtual bool isIndexing() const;
virtual bool isLiteralZero() const;
virtual bool isConstEnum() const;
virtual int intValue() const;
virtual void accept(FuVisitor * visitor, FuPriority parent) const;
void acceptStatement(FuVisitor * visitor) const override;
virtual bool isReferenceTo(const FuSymbol * symbol) const;
virtual bool isNewString(bool substringOffset) const;
virtual bool isUnique() const;
virtual void setShared() const;
protected:
FuExpr() = default;
public:
std::shared_ptr<FuType> type;
};
class FuName : public FuExpr
{
public:
virtual ~FuName() = default;
int getLocLength() const override;
virtual const FuSymbol * getSymbol() const = 0;
protected:
FuName() = default;
public:
std::string name{""};
};
class FuSymbol : public FuName
{
public:
virtual ~FuSymbol() = default;
const FuSymbol * getSymbol() const override;
std::string toString() const override;
protected:
FuSymbol() = default;
public:
FuId id = FuId::none;
FuSymbol * next;
FuScope * parent;
std::shared_ptr<FuCodeDoc> documentation = nullptr;
};
class FuScope : public FuSymbol
{
public:
virtual ~FuScope() = default;
int count() const;
bool contains(const FuSymbol * symbol) const;
std::shared_ptr<FuSymbol> tryLookup(std::string_view name, bool global) const;
void add(std::shared_ptr<FuSymbol> symbol);
bool encloses(const FuSymbol * symbol) const;
protected:
FuScope() = default;
std::unordered_map<std::string_view, std::shared_ptr<FuSymbol>> dict;
void addToList(std::shared_ptr<FuSymbol> symbol);
public:
FuSymbol * first = nullptr;
FuSymbol * last = nullptr;
};
class FuAggregateInitializer : public FuExpr
{
public:
FuAggregateInitializer() = default;
void accept(FuVisitor * visitor, FuPriority parent) const override;
public:
std::vector<std::shared_ptr<FuExpr>> items;
};
class FuLiteral : public FuExpr
{
public:
virtual ~FuLiteral() = default;
virtual bool isDefaultValue() const = 0;
virtual std::string getLiteralString() const;
protected:
FuLiteral() = default;
};
class FuLiteralNull : public FuLiteral
{
public:
FuLiteralNull() = default;
int getLocLength() const override;
bool isDefaultValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isUnique() const override;
std::string toString() const override;
};
class FuLiteralFalse : public FuLiteral
{
public:
FuLiteralFalse() = default;
int getLocLength() const override;
bool isDefaultValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
std::string toString() const override;
};
class FuLiteralTrue : public FuLiteral
{
public:
FuLiteralTrue() = default;
int getLocLength() const override;
bool isDefaultValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
std::string toString() const override;
};
class FuLiteralLong : public FuLiteral
{
public:
FuLiteralLong() = default;
virtual ~FuLiteralLong() = default;
bool isLiteralZero() const override;
int intValue() const override;
bool isDefaultValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
std::string getLiteralString() const override;
std::string toString() const override;
public:
int64_t value;
};
class FuLiteralChar : public FuLiteralLong
{
public:
FuLiteralChar() = default;
static std::shared_ptr<FuLiteralChar> new_(int value, int loc);
int getLocLength() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
};
class FuLiteralDouble : public FuLiteral
{
public:
FuLiteralDouble() = default;
bool isDefaultValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
std::string getLiteralString() const override;
std::string toString() const override;
public:
double value;
};
class FuLiteralString : public FuLiteral
{
public:
FuLiteralString() = default;
bool isDefaultValue() const override;
int getLocLength() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
std::string getLiteralString() const override;
std::string toString() const override;
int getAsciiLength() const;
int getAsciiAt(int i) const;
int getOneAscii() const;
public:
std::string value;
};
class FuInterpolatedPart
{
public:
FuInterpolatedPart() = default;
public:
std::string prefix;
std::shared_ptr<FuExpr> argument;
std::shared_ptr<FuExpr> widthExpr;
int width;
int format;
int precision;
};
class FuInterpolatedString : public FuExpr
{
public:
FuInterpolatedString() = default;
void addPart(std::string_view prefix, std::shared_ptr<FuExpr> arg, std::shared_ptr<FuExpr> widthExpr = nullptr, int format = ' ', int precision = -1);
int getLocLength() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isNewString(bool substringOffset) const override;
public:
std::vector<FuInterpolatedPart> parts;
std::string suffix;
};
class FuImplicitEnumValue : public FuExpr
{
public:
FuImplicitEnumValue() = default;
int intValue() const override;
public:
int value;
};
class FuSymbolReference : public FuName
{
public:
FuSymbolReference() = default;
virtual ~FuSymbolReference() = default;
bool isConstEnum() const override;
int intValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isReferenceTo(const FuSymbol * symbol) const override;
bool isNewString(bool substringOffset) const override;
void setShared() const override;
const FuSymbol * getSymbol() const override;
std::string toString() const override;
public:
std::shared_ptr<FuExpr> left = nullptr;
FuSymbol * symbol;
};
class FuUnaryExpr : public FuExpr
{
public:
virtual ~FuUnaryExpr() = default;
int getLocLength() const override;
protected:
FuUnaryExpr() = default;
public:
FuToken op;
std::shared_ptr<FuExpr> inner;
};
class FuPrefixExpr : public FuUnaryExpr
{
public:
FuPrefixExpr() = default;
bool isConstEnum() const override;
int intValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isUnique() const override;
};
class FuPostfixExpr : public FuUnaryExpr
{
public:
FuPostfixExpr() = default;
void accept(FuVisitor * visitor, FuPriority parent) const override;
};
class FuBinaryExpr : public FuExpr
{
public:
FuBinaryExpr() = default;
int getLocLength() const override;
bool isIndexing() const override;
bool isConstEnum() const override;
int intValue() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isNewString(bool substringOffset) const override;
bool isRel() const;
bool isAssign() const;
std::string_view getOpString() const;
std::string toString() const override;
public:
std::shared_ptr<FuExpr> left;
FuToken op;
std::shared_ptr<FuExpr> right;
};
class FuSelectExpr : public FuExpr
{
public:
FuSelectExpr() = default;
int getLocLength() const override;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isUnique() const override;
void setShared() const override;
std::string toString() const override;
public:
std::shared_ptr<FuExpr> cond;
std::shared_ptr<FuExpr> onTrue;
std::shared_ptr<FuExpr> onFalse;
};
class FuCallExpr : public FuExpr
{
public:
FuCallExpr() = default;
void accept(FuVisitor * visitor, FuPriority parent) const override;
bool isNewString(bool substringOffset) const override;
std::string toString() const override;
public:
std::shared_ptr<FuSymbolReference> method;
std::vector<std::shared_ptr<FuExpr>> arguments;
};
class FuLambdaExpr : public FuScope
{
public:
FuLambdaExpr() = default;
void accept(FuVisitor * visitor, FuPriority parent) const override;
public:
std::shared_ptr<FuExpr> body;
};
class FuCondCompletionStatement : public FuScope
{
public:
virtual ~FuCondCompletionStatement() = default;
bool completesNormally() const override;
void setCompletesNormally(bool value);
protected:
FuCondCompletionStatement() = default;
private:
bool completesNormallyValue;
};
class FuBlock : public FuCondCompletionStatement