-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpression.h
More file actions
907 lines (740 loc) · 22 KB
/
Copy pathExpression.h
File metadata and controls
907 lines (740 loc) · 22 KB
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
#ifndef BLANG_EXPRESSION_H_
#define BLANG_EXPRESSION_H_
#include <string>
#include <map>
#include <vector>
#include "RefCount.h"
#include "Type.h"
class Lexer;
namespace QLang
{
class SQLGen; // forward declaration for friend access
class Expression : public Statement
{
public:
static Expression *Parse( Lexer &l, Scope *scope, char terminal = ';' );
// Precedence-climbing expression parser (no terminal handling)
static Expression *ParseExpr( Lexer &l, Scope *scope, int minPrec = 0 );
static Expression *ParsePrimary( Lexer &l, Scope *scope );
// Typed AST (U3, design decision 3): the single authoritative record of
// this expression's resolved type. The semantic pass (Sema) fills it for
// expressions whose type is determinable from resolution; codegen reads
// it instead of re-deriving on the paths U3 migrates. nullptr means the
// type is not yet determined (a leaf a later unit will resolve/check) —
// never a fabricated default.
void setResolvedType( Type *t ) { mResolvedType = t; }
Type *getResolvedType() const
{
return const_cast<Type *>( static_cast<const Type *>( mResolvedType ) );
}
protected:
SmartPtr<Type> mResolvedType; // NEW U3 slot; default nullptr
};
class WhileStatement : public Statement
{
public:
static WhileStatement *Parse( Lexer &l, Scope *scope );
protected:
WhileStatement() {}
private:
SmartPtr<Expression> mLoopExpression;
SmartPtr<Statement> mLoopStatement;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ForStatement : public Statement
{
public:
static ForStatement *Parse( Lexer &l, Scope *scope );
protected:
ForStatement() {}
private:
SmartPtr<Expression> mInitialExpression;
SmartPtr<Expression> mTestExpression;
SmartPtr<Expression> mIterationExpression;
SmartPtr<Statement> mStatement;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ForInStatement : public Statement
{
public:
static ForInStatement *Parse( Lexer &l, Scope *scope );
protected:
ForInStatement() {}
private:
std::string mVariableName;
std::string mSecondVariableName; // for key, value iteration
SmartPtr<Expression> mIterableExpression; // nullptr for infinite loop
SmartPtr<Statement> mBody;
bool mIsInfinite = false;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class IfStatement : public Statement
{
public:
static IfStatement *Parse( Lexer &l, Scope *scope );
protected:
IfStatement() {}
private:
SmartPtr<Expression> mIfExpression;
SmartPtr<Statement> mStatement;
SmartPtr<Statement> mElseStatement;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ReturnStatement : public Statement
{
public:
static ReturnStatement *Parse( Lexer &l, Scope *scope );
protected:
ReturnStatement() {}
private:
SmartPtr<Expression> mExpression;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ConstExpression : public Expression
{
public:
static ConstExpression *Parse( Lexer &l, Scope *scope );
protected:
ConstExpression() {}
private:
SmartPtr<Type> mType;
};
class ConstInteger : public ConstExpression
{
public:
ConstInteger( int64_t value ) : mValue( value ) {}
private:
int64_t mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
class ConstFloat : public ConstExpression
{
public:
ConstFloat( double value ) : mValue( value ) {}
private:
double mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
class ConstString : public ConstExpression
{
public:
ConstString( std::string value ) : mValue( value ) {}
private:
std::string mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
class ConstChar : public ConstExpression
{
public:
ConstChar( const std::string &value ) : mValue( value ) {}
static ConstChar *Parse( Lexer &l, Scope *scope );
protected:
ConstChar() {}
private:
std::string mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class VariableDeclaration : public Statement
{
public:
static VariableDeclaration *Parse( Lexer &l, Scope *s );
private:
struct DeclData {
SmartPtr<VariableDefinition> mVaribale;
SmartPtr<Expression> mInitialValue;
};
std::vector<DeclData> mVariables;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class VariableExpression : public Expression
{
public:
VariableExpression( VariableDefinition *def ) : mVariable( def ) {}
static VariableExpression *Parse( Lexer &l, Scope *scope );
VariableDefinition *getVariable() { return mVariable; }
protected:
VariableExpression() {}
private:
SmartPtr<VariableDefinition> mVariable;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class CallExpression : public Expression
{
public:
CallExpression( FunctionDefinition *def ) : mFunction( def ) {}
static CallExpression *Parse( Lexer &l, Scope *scope );
void addParam( Expression *param ) { mParams.push_back( param ); }
void addTypeArg( Type *typeArg ) { mTypeArgs.push_back( typeArg ); }
// Override the LLVM function name for namespace-mangled calls (e.g. "sys__args")
void setMangledName( const std::string &name ) { mMangledName = name; }
const std::string &getMangledName() const { return mMangledName; }
FunctionDefinition *getFunction() { return mFunction; }
private:
SmartPtr<FunctionDefinition> mFunction;
std::vector<SmartPtr<Type>> mTypeArgs;
std::vector<SmartPtr<Expression> > mParams;
std::string mMangledName; // namespace-mangled name, empty if not mangled
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class Block : public Statement
{
public:
static Block *Parse( Lexer &l, Scope *block_scope );
private:
SmartPtr<Scope> mScope;
std::vector<SmartPtr<Statement> > mStatementList;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class AssignmentExpression : public Expression
{
public:
AssignmentExpression( std::string operation, VariableDefinition *var, Expression *value ) :
mOperation( operation ), mVariable( var ), mValue( value ) {}
private:
std::string mOperation;
SmartPtr<VariableDefinition> mVariable;
SmartPtr<Expression> mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class FieldAssignmentExpression : public Expression
{
public:
FieldAssignmentExpression( std::string operation, Expression *object,
const std::string &fieldName, Expression *value ) :
mOperation( operation ), mObject( object ), mFieldName( fieldName ), mValue( value ) {}
private:
std::string mOperation;
SmartPtr<Expression> mObject;
std::string mFieldName;
SmartPtr<Expression> mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class IndexAssignmentExpression : public Expression
{
public:
IndexAssignmentExpression( std::string operation, Expression *object,
Expression *index, Expression *value ) :
mOperation( operation ), mObject( object ), mIndex( index ), mValue( value ) {}
private:
std::string mOperation;
SmartPtr<Expression> mObject;
SmartPtr<Expression> mIndex;
SmartPtr<Expression> mValue;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class OperationsExpression : public Expression
{
public:
OperationsExpression( std::string operation, Expression *op1, Expression *op2 ) :
mOperation( operation ), mOp1( op1 ), mOp2( op2 ) {}
private:
std::string mOperation;
SmartPtr<Expression> mOp1;
SmartPtr<Expression> mOp2;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
class UnaryExpression : public Expression
{
public:
UnaryExpression( std::string operation, Expression *operand ) :
mOperation( operation ), mOperand( operand ) {}
private:
std::string mOperation;
SmartPtr<Expression> mOperand;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class BreakStatement : public Statement
{
public:
static BreakStatement *Parse( Lexer &l, Scope *scope );
protected:
BreakStatement() {}
private:
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ContinueStatement : public Statement
{
public:
static ContinueStatement *Parse( Lexer &l, Scope *scope );
protected:
ContinueStatement() {}
private:
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class SpawnStatement : public Expression
{
public:
static SpawnStatement *Parse( Lexer &l, Scope *scope );
protected:
SpawnStatement() {}
private:
SmartPtr<Block> mBody;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class WaitStatement : public Statement
{
public:
static WaitStatement *Parse( Lexer &l, Scope *scope );
protected:
WaitStatement() {}
private:
SmartPtr<Expression> mExpr; // the Task expression to wait on
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class WaitAllStatement : public Statement
{
public:
static WaitAllStatement *Parse( Lexer &l, Scope *scope );
protected:
WaitAllStatement() {}
private:
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class AssertStatement : public Statement
{
public:
static AssertStatement *Parse( Lexer &l, Scope *scope );
protected:
AssertStatement() {}
private:
SmartPtr<Expression> mExpression;
std::string mMessage; // optional assertion message
int mLine = 0; // source line of the assert (for failure reports)
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class EventHandler : public Statement
{
public:
static EventHandler *Parse( Lexer &l, Scope *scope );
protected:
EventHandler() {}
private:
SmartPtr<Expression> mEventExpression; // e.g., timer.every(1000)
SmartPtr<Block> mBody;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class FieldAccessExpression : public Expression
{
public:
FieldAccessExpression( Expression *object, const std::string &fieldName ) :
mObject( object ), mFieldName( fieldName ) {}
static FieldAccessExpression *Parse( Lexer &l, Scope *scope );
Expression *getObject() { return mObject; }
const std::string &getFieldName() const { return mFieldName; }
// The struct field this access resolved to (stamped by Sema; null when
// the base type is not a resolvable struct). Non-owning: the struct
// definition owns its fields.
VariableDefinition *getResolvedField() { return mResolvedField; }
private:
SmartPtr<Expression> mObject;
std::string mFieldName;
VariableDefinition *mResolvedField = nullptr;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class StructLiteralExpression : public Expression
{
public:
StructLiteralExpression( const std::string &typeName ) : mTypeName( typeName ) {}
void addField( const std::string &name, Expression *value )
{
mFieldNames.push_back( name );
mFieldValues.push_back( value );
}
void addTypeArg( Type *typeArg ) { mTypeArgs.push_back( typeArg ); }
static StructLiteralExpression *Parse( Lexer &l, Scope *scope, const std::string &typeName );
private:
std::string mTypeName;
std::vector<SmartPtr<Type>> mTypeArgs;
std::vector<std::string> mFieldNames;
std::vector<SmartPtr<Expression>> mFieldValues;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ArrayLiteralExpression : public Expression
{
public:
ArrayLiteralExpression() {}
void addElement( Expression *elem ) { mElements.push_back( elem ); }
static ArrayLiteralExpression *Parse( Lexer &l, Scope *scope );
private:
std::vector<SmartPtr<Expression>> mElements;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class IndexExpression : public Expression
{
public:
IndexExpression( Expression *object, Expression *index ) :
mObject( object ), mIndex( index ) {}
Expression *getObject() { return mObject; }
Expression *getIndex() { return mIndex; }
private:
SmartPtr<Expression> mObject;
SmartPtr<Expression> mIndex;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class MethodCallExpression : public Expression
{
public:
MethodCallExpression( Expression *object, const std::string &methodName ) :
mObject( object ), mMethodName( methodName ) {}
void addArg( Expression *arg ) { mArgs.push_back( arg ); }
Expression *getObject() { return mObject; }
const std::string &getMethodName() const { return mMethodName; }
// The struct method this call resolved to (stamped by Sema; null for
// builtin string/array methods, channel ops, and unresolvable bases).
// Non-owning: the struct definition owns its methods.
FunctionDefinition *getResolvedMethod() { return mResolvedMethod; }
private:
SmartPtr<Expression> mObject;
std::string mMethodName;
FunctionDefinition *mResolvedMethod = nullptr;
std::vector<SmartPtr<Expression>> mArgs;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class RangeExpression : public Expression
{
public:
RangeExpression( Expression *start, Expression *end ) :
mStart( start ), mEnd( end ) {}
private:
SmartPtr<Expression> mStart;
SmartPtr<Expression> mEnd;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class StringInterpolation : public Expression
{
public:
StringInterpolation() {}
void addPart( Expression *part ) { mParts.push_back( part ); }
static StringInterpolation *Parse( Lexer &l, Scope *scope, const std::string &rawString );
private:
std::vector<SmartPtr<Expression>> mParts;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class ConstructExpression : public Expression
{
public:
ConstructExpression( StructDefinition *structDef ) : mStructDef( structDef ) {}
void addArg( Expression *arg ) { mArgs.push_back( arg ); }
void addTypeArg( Type *typeArg ) { mTypeArgs.push_back( typeArg ); }
private:
SmartPtr<StructDefinition> mStructDef;
std::vector<SmartPtr<Type>> mTypeArgs;
std::vector<SmartPtr<Expression>> mArgs;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class EnumConstructExpression : public Expression
{
public:
EnumConstructExpression( EnumDefinition *enumDef, int variantIndex )
: mEnumDef( enumDef ), mVariantIndex( variantIndex ) {}
void addArg( Expression *arg ) { mArgs.push_back( arg ); }
private:
SmartPtr<EnumDefinition> mEnumDef;
int mVariantIndex;
std::vector<SmartPtr<Expression>> mArgs;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
struct MatchArm
{
std::string mPattern;
// Variables bound by destructuring, in payload order: ok(value) binds
// one, pair(a, b) binds two — one per variant associated type.
std::vector<std::string> mBindingNames;
SmartPtr<Block> mBody; // statement-form arm: pattern { statements... }
SmartPtr<Expression> mValue; // expression-form arm: pattern { expression }
SmartPtr<Scope> mScope; // expression-form arm scope (holds the binding)
bool mIsWildcard = false;
bool mPatternIsString = false; // pattern was a string literal ("start")
};
class MatchExpression : public Expression
{
public:
// exprMode: value-producing match (parsed from expression position) —
// each arm body is a single expression, and the match yields the
// selected arm's value. Statement position keeps block-bodied arms.
static MatchExpression *Parse( Lexer &l, Scope *scope, bool exprMode = false );
protected:
MatchExpression() {}
private:
SmartPtr<Expression> mSubject;
std::vector<MatchArm> mArms;
bool mExprMode = false;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class TryExpression : public Expression
{
public:
TryExpression( Expression *operand ) : mOperand( operand ) {}
private:
SmartPtr<Expression> mOperand;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class AwaitExpression : public Expression
{
public:
AwaitExpression( Expression *operand ) : mOperand( operand ) {}
private:
SmartPtr<Expression> mOperand;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class FunctionRefExpression : public Expression
{
public:
FunctionRefExpression( FunctionDefinition *func ) : mFunction( func ) {}
private:
SmartPtr<FunctionDefinition> mFunction;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class LambdaExpression : public Expression
{
public:
static LambdaExpression *Parse( Lexer &l, Scope *scope );
protected:
LambdaExpression() {}
private:
SmartPtr<Type> mReturnType; // nullptr = void
std::vector<SmartPtr<VariableDefinition>> mParameters;
SmartPtr<Block> mBody;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
class IndirectCallExpression : public Expression
{
public:
IndirectCallExpression( VariableDefinition *fnVar ) : mFnVariable( fnVar ) {}
void addParam( Expression *param ) { mParams.push_back( param ); }
private:
SmartPtr<VariableDefinition> mFnVariable;
std::vector<SmartPtr<Expression>> mParams;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
// Phase 3: Pipeline expression — a |> b desugars to b(a)
class PipelineExpression : public Expression
{
public:
PipelineExpression( Expression *input, Expression *transform ) :
mInput( input ), mTransform( transform ) {}
private:
SmartPtr<Expression> mInput;
SmartPtr<Expression> mTransform;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
// Phase 3: Query field reference — .field_name in query context
class QueryFieldExpression : public Expression
{
public:
QueryFieldExpression( const std::string &fieldName ) : mFieldName( fieldName ) {}
const std::string &getFieldName() const { return mFieldName; }
private:
std::string mFieldName;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
};
// Phase 3: Query pipeline step types
struct QueryPipelineStep
{
enum StepType { WHERE, ORDER_BY, LIMIT, JOIN, FIRST, SET };
StepType mType;
SmartPtr<Expression> mExpression; // predicate/sort key/limit count/join condition
std::string mJoinTable; // table name for join steps
std::vector<std::pair<std::string, SmartPtr<Expression>>> mSetFields; // for set steps
};
// Phase 3: Query expression — query T |> where { ... } |> order_by { ... } |> limit(n)
class QueryExpression : public Expression
{
public:
QueryExpression( const std::string &tableName ) : mTableName( tableName ) {}
static QueryExpression *Parse( Lexer &l, Scope *scope );
void addStep( const QueryPipelineStep &step ) { mSteps.push_back( step ); }
private:
std::string mTableName;
std::vector<QueryPipelineStep> mSteps;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
// Phase 3: Insert expression — insert T { field: value, ... }
class InsertExpression : public Expression
{
public:
InsertExpression( const std::string &tableName ) : mTableName( tableName ) {}
static InsertExpression *Parse( Lexer &l, Scope *scope );
void addField( const std::string &name, Expression *value )
{
mFieldNames.push_back( name );
mFieldValues.push_back( value );
}
private:
std::string mTableName;
std::vector<std::string> mFieldNames;
std::vector<SmartPtr<Expression>> mFieldValues;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
// Phase 3: Update expression — update T |> where { ... } |> set { ... }
class UpdateExpression : public Expression
{
public:
UpdateExpression( const std::string &tableName ) : mTableName( tableName ) {}
static UpdateExpression *Parse( Lexer &l, Scope *scope );
void addStep( const QueryPipelineStep &step ) { mSteps.push_back( step ); }
private:
std::string mTableName;
std::vector<QueryPipelineStep> mSteps;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
// Phase 3: Delete expression — delete T |> where { ... }
class DeleteExpression : public Expression
{
public:
DeleteExpression( const std::string &tableName ) : mTableName( tableName ) {}
static DeleteExpression *Parse( Lexer &l, Scope *scope );
void addStep( const QueryPipelineStep &step ) { mSteps.push_back( step ); }
private:
std::string mTableName;
std::vector<QueryPipelineStep> mSteps;
friend class CodeGen;
friend class LocationDumper;
friend class AstLocator;
friend class Sema;
friend class SQLGen;
};
};
#endif // BLANG_EXPRESSION_H_