-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.go
2280 lines (1881 loc) · 49.5 KB
/
ast.go
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
package main
// WACC Group 34
//
// ast.go: the structures for the AST the functions that parse the syntax tree
//
// Types, statements, expressions in the WACC language
// Functions to parse the WACC syntax tree into the AST
import (
"bytes"
"errors"
"fmt"
"reflect"
"strconv"
"sync"
)
// Type is an interface for WACC type
type Type interface {
aststring(indent string) string
Match(Type) bool
String() string
MangleSymbol() string
}
// InvalidType is a WACC type for invalid constructs
type InvalidType struct{}
// Prints invalid Types. Format:
// "<invalid>"
func (m InvalidType) String() string {
return "<invalid>"
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m InvalidType) MangleSymbol() string {
panic(fmt.Errorf("Trying to mangle void type"))
}
// VoidType is a WACC type for cases where the type is not known
type VoidType struct{}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m VoidType) MangleSymbol() string {
return "unknown"
}
// Prints void Types. Format:
// "<void>"
func (m VoidType) String() string {
return "<void>"
}
// IntType is the WACC type for integers
type IntType struct{}
// Prints integer Types. Format:
// "int"
func (i IntType) String() string {
return "int"
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m IntType) MangleSymbol() string {
return m.String()
}
// EnumType is the WACC type for booleans
type EnumType struct {
TokenBase
ident string
values map[string]int
}
// Prints enum Types. Format:
// "enum + *name*"
func (e EnumType) String() string {
return fmt.Sprintf("enum %v", e.ident)
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (e EnumType) MangleSymbol() string {
return fmt.Sprintf("enum_%v", e.ident)
}
// BoolType is the WACC type for booleans
type BoolType struct{}
// Prints boolean Types. Format:
// "bool"
func (b BoolType) String() string {
return "bool"
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m BoolType) MangleSymbol() string {
return m.String()
}
// CharType is the WACC type for characters
type CharType struct{}
// Prints char Types. Format:
// "char"
func (c CharType) String() string {
return "char"
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m CharType) MangleSymbol() string {
return m.String()
}
// PairType is the WACC type for pairs
type PairType struct {
first Type
second Type
}
// Prints pair Types. Format:
// "pair([fst], [snd])"
// Recurses on fst and snd.
func (p PairType) String() string {
var first = fmt.Sprintf("%v", p.first)
var second = fmt.Sprintf("%v", p.second)
if p.first == nil {
first = "pair"
}
if p.second == nil {
second = "pair"
}
return fmt.Sprintf("pair(%v, %v)", first, second)
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m PairType) MangleSymbol() string {
return fmt.Sprintf(
"p_f_%s_s_%s_e",
m.first.MangleSymbol(),
m.second.MangleSymbol(),
)
}
// ArrayType is the WACC type for arrays
type ArrayType struct {
base Type
}
// Prints array Types. Format:
// "[arr][]"
// Recurses on arr.
func (a ArrayType) String() string {
return fmt.Sprintf("%v[]", a.base)
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m ArrayType) MangleSymbol() string {
return fmt.Sprintf(
"a_%s_e",
m.base.MangleSymbol(),
)
}
// ClassMember holds class member data
type ClassMember struct {
TokenBase
ident string
wtype Type
get bool
set bool
}
// ClassType represents a class in WACC
type ClassType struct {
TokenBase
name string
members []*ClassMember
methods []*FunctionDef
}
// Prints class Types. Format:
// [classname]
func (m *ClassType) String() string {
return m.name
}
// MangleSymbol returns the type in a form that is ready to be included in
// the mangled function symbol
func (m *ClassType) MangleSymbol() string {
return fmt.Sprintf("class_%v", m.name)
}
// Expression is the interface for WACC expressions
type Expression interface {
aststring(indent string) string
TypeCheck(*Scope, chan<- error)
Type() Type
Token() *token32
SetToken(*token32)
CodeGen(*FunctionContext, Reg, chan<- Instr)
Weight() int
Optimise(*OptimisationContext) Expression
}
// Statement is the interface for WACC statements
type Statement interface {
GetNext() Statement
SetNext(Statement)
istring(level int) string
aststring(indent string) string
TypeCheck(*Scope, chan<- error)
Token() *token32
SetToken(*token32)
CodeGen(*FunctionContext, chan<- Instr)
Optimise(*OptimisationContext) Statement
}
// TokenBase is the base structure that contains the token reference
type TokenBase struct {
token *token32
}
// Token returns the token in TokenBase
func (m *TokenBase) Token() *token32 {
return m.token
}
// SetToken sets the current token in TokenBase
func (m *TokenBase) SetToken(token *token32) {
m.token = token
}
// BaseStatement contains the pointer to the next statement
type BaseStatement struct {
TokenBase
next Statement
}
// GetNext returns the next statment in BaseStatment
func (m *BaseStatement) GetNext() Statement {
return m.next
}
// SetNext sets the next statment in BaseStatment
func (m *BaseStatement) SetNext(next Statement) {
m.next = next
}
// SkipStatement is the struct for WACC skip statement
type SkipStatement struct {
BaseStatement
}
// Continue Statement is the struct for WACC continue statement
type ContinueStatement struct {
BaseStatement
}
// BreakStatement is the struct for WACC break statement
type BreakStatement struct {
BaseStatement
}
// BlockStatement is the struct for creating new block scope
type BlockStatement struct {
BaseStatement
body Statement
}
// DeclareAssignStatement declares a new variable and assigns the right hand
// side expression to it
type DeclareAssignStatement struct {
BaseStatement
wtype Type
ident string
rhs RHS
}
// LHS is the interface for the left hand side of an assignment
type LHS interface {
aststring(indent string) string
TypeCheck(*Scope, chan<- error)
Type() Type
Token() *token32
SetToken(*token32)
CodeGen(*FunctionContext, Reg, chan<- Instr)
Optimise(*OptimisationContext) LHS
}
// PairElemLHS is the struct for a pair on the lhs of an assignment
type PairElemLHS struct {
TokenBase
wtype Type
snd bool
expr Expression
}
// Type returns the Type of the LHS
func (m *PairElemLHS) Type() Type {
return m.wtype
}
// ArrayLHS is the struct for an array on the lhs of an assignment
type ArrayLHS struct {
TokenBase
wtype Type
ident string
index []Expression
}
// Type returns the Type of the LHS
func (m *ArrayLHS) Type() Type {
return m.wtype
}
// VarLHS is the struct for a variable on the lhs of an assignment
type VarLHS struct {
TokenBase
wtype Type
ident string
}
// Type returns the Type of the LHS
func (m *VarLHS) Type() Type {
return m.wtype
}
// RHS is the interface for the right hand side of an assignment
type RHS interface {
aststring(indent string) string
TypeCheck(*Scope, chan<- error)
Type() Type
Token() *token32
SetToken(*token32)
CodeGen(*FunctionContext, Reg, chan<- Instr)
Optimise(*OptimisationContext) RHS
}
// PairLiterRHS is the struct for pair literals on the rhs of an assignment
type PairLiterRHS struct {
TokenBase
PairLiteral
}
// Type returns the deduced type of the right hand side assignment source.
func (m *PairLiterRHS) Type() Type {
fstT := m.fst.Type()
sndT := m.snd.Type()
return PairType{first: fstT, second: sndT}
}
// ArrayLiterRHS is the struct for array literals on the rhs of an assignment
type ArrayLiterRHS struct {
TokenBase
elements []Expression
}
// Type returns the deduced type of the right hand side assignment source.
func (m *ArrayLiterRHS) Type() Type {
if len(m.elements) == 0 {
return ArrayType{base: VoidType{}}
}
t := m.elements[0].Type()
return ArrayType{t}
}
// PairElemRHS is the struct for pair elements on the rhs of an assignment
type PairElemRHS struct {
TokenBase
snd bool
expr Expression
}
// Type returns the deduced type of the right hand side assignment source.
func (m *PairElemRHS) Type() Type {
switch t := m.expr.Type().(type) {
case PairType:
if !m.snd {
return t.first
}
return t.second
default:
return InvalidType{}
}
}
// FunctionCall is the base struct for function calls
type FunctionCall struct {
obj string
ident string
mangledIdent string
args []Expression
wtype Type
}
// FunctionCall is the struct for function calls not being assigned to a var
type FunctionCallStat struct {
BaseStatement
FunctionCall
}
// FunctionCallRHS is the struct for function calls on the rhs of an assignment
type FunctionCallRHS struct {
TokenBase
FunctionCall
}
// Type returns the deduced type of the right hand side assignment source.
func (m *FunctionCallRHS) Type() Type {
return m.wtype
}
// ExpressionRHS is the struct for expressions on the rhs of an assignment
type ExpressionRHS struct {
TokenBase
expr Expression
}
// Type returns the deduced type of the right hand side assignment source.
func (m *ExpressionRHS) Type() Type {
return m.expr.Type()
}
// NewInstanceRHS is the for new class instance on the rhs of an assignment
type NewInstanceRHS struct {
TokenBase
constr string
wtype Type
args []Expression
}
// Type returns the deduced type of the right hand side assignment source.
func (m *NewInstanceRHS) Type() Type {
return m.wtype
}
// AssignStatement is the struct for an assignment statement
type AssignStatement struct {
BaseStatement
target LHS
rhs RHS
}
// ReadStatement is the struct for a read statement
type ReadStatement struct {
BaseStatement
target LHS
}
// FreeStatement is the struct for a free statement
type FreeStatement struct {
BaseStatement
expr Expression
}
// ReturnStatement is the struct for a return statement
type ReturnStatement struct {
BaseStatement
expr Expression
}
// ExitStatement is the struct for an exit statement
type ExitStatement struct {
BaseStatement
expr Expression
}
// PrintLnStatement is the struct for a println statement
type PrintLnStatement struct {
BaseStatement
expr Expression
}
// PrintStatement is the struct for a print statement
type PrintStatement struct {
BaseStatement
expr Expression
}
// IfStatement is the struct for a if-else statement
type IfStatement struct {
BaseStatement
cond Expression
trueStat Statement
falseStat Statement
}
// WhileStatement is the struct for a while statement
type WhileStatement struct {
BaseStatement
cond Expression
body Statement
}
// SwitchStatement is the struct for a while statement
type SwitchStatement struct {
BaseStatement
cond Expression
cases []Expression
fts []bool
bodies []Statement
defaultCase Statement
}
// DoWhileStatement is the struct for a doWhile statement
type DoWhileStatement struct {
BaseStatement
cond Expression
body Statement
}
//ForStatement is the struct for a for statement
type ForStatement struct {
BaseStatement
init Statement
cond Expression
after Statement
body Statement
}
// FunctionParam is the struct for a function parameter
type FunctionParam struct {
TokenBase
name string
wtype Type
}
// FunctionDef is the struct for a function definition
type FunctionDef struct {
TokenBase
ident string
class *ClassType
returnType Type
params []*FunctionParam
body Statement
}
// Symbol returns the mangled symbol of the function to distinguish overloaded
// variants
func (m *FunctionDef) Symbol() string {
var buffer bytes.Buffer
buffer.WriteString(m.ident)
if m.class != nil {
buffer.WriteString(fmt.Sprintf("__class_%s_", m.class.name))
}
if len(m.params) > 0 {
buffer.WriteString("__ol_")
}
for _, param := range m.params {
buffer.WriteString(
fmt.Sprintf("_%s", param.wtype.MangleSymbol()),
)
}
return buffer.String()
}
// AST is the main struct that represents the abstract syntax tree
type AST struct {
main Statement
functions []*FunctionDef
includes []string
classes []*ClassType
enums []*EnumType
}
// nodeRange given a node returns a channel from which all nodes at the same
// level can be read
func nodeRange(node *node32) <-chan *node32 {
out := make(chan *node32)
go func() {
for ; node != nil; node = node.next {
out <- node
}
close(out)
}()
return out
}
// nextNode given a node and a peg rule returns the first node in the chain
// that was created from that peg rule
func nextNode(node *node32, rule pegRule) *node32 {
for cnode := range nodeRange(node) {
if cnode.pegRule == rule {
return cnode
}
}
return nil
}
// parse array element access inside an expression
func parseArrayElem(node *node32) (Expression, error) {
arrElem := &ArrayElem{}
arrElem.ident = node.match
// read and add all the indexer expressions
for enode := nextNode(node, ruleEXPR); enode != nil; enode = nextNode(enode.next, ruleEXPR) {
var exp Expression
var err error
if exp, err = parseExpr(enode.up); err != nil {
return nil, err
}
arrElem.indexes = append(arrElem.indexes, exp)
}
return arrElem, nil
}
// Ident is the struct to represent an identifier
type Ident struct {
TokenBase
wtype Type
ident string
}
// Type returns the Type of the expression
func (m *Ident) Type() Type {
return m.wtype
}
// IntLiteral is the struct to represent an integer literal
type IntLiteral struct {
TokenBase
value int
}
// Type returns the Type of the expression
func (m *IntLiteral) Type() Type {
return IntType{}
}
// EnumLiteral is the struct to represent an integer literal
type EnumLiteral struct {
TokenBase
wtype Type
ident string
field string
value int
}
// Type returns the Type of the expression
func (m *EnumLiteral) Type() Type {
return m.wtype
}
// BoolLiteralTrue is the struct to represent a true boolean literal
type BoolLiteralTrue struct {
TokenBase
}
// Type returns the Type of the expression
func (m *BoolLiteralTrue) Type() Type {
return BoolType{}
}
// BoolLiteralFalse is the struct to represent a false boolean literal
type BoolLiteralFalse struct {
TokenBase
}
// Type returns the Type of the expression
func (m *BoolLiteralFalse) Type() Type {
return BoolType{}
}
// CharLiteral is the struct to represent a character literal
type CharLiteral struct {
TokenBase
char string
}
// Type returns the Type of the expression
func (m *CharLiteral) Type() Type {
return CharType{}
}
// StringLiteral is the struct to represent a string literal
type StringLiteral struct {
TokenBase
str string
}
// Type returns the Type of the expression
func (m *StringLiteral) Type() Type {
return ArrayType{CharType{}}
}
// PairLiteral is the struct to represent a pair literal
type PairLiteral struct {
TokenBase
weightCache int
fst Expression
snd Expression
}
// Type returns the Type of the expression
func (m *PairLiteral) Type() Type {
return PairType{first: m.fst.Type(), second: m.snd.Type()}
}
// NullPair is the struct to represent a null pair
type NullPair struct {
TokenBase
}
// Type returns the Type of the expression
func (m *NullPair) Type() Type {
return PairType{first: VoidType{}, second: VoidType{}}
}
// ArrayElem is the struct to represent an array element
type ArrayElem struct {
TokenBase
weightCache int
ident string
wtype Type
indexes []Expression
}
// Type returns the Type of the expression
func (m *ArrayElem) Type() Type {
return m.wtype
}
// UnaryOperator is the struct to represent the unary operators
type UnaryOperator interface {
Expression
GetExpression() Expression
SetExpression(Expression)
}
// UnaryOperatorBase is the struct to represent the expression having the unary
// operator
type UnaryOperatorBase struct {
TokenBase
weightCache int
expr Expression
}
// GetExpression returns the expression associated with UnaryOperator
func (m *UnaryOperatorBase) GetExpression() Expression {
return m.expr
}
// SetExpression sets the expression associated with UnaryOperator
func (m *UnaryOperatorBase) SetExpression(exp Expression) {
m.expr = exp
}
// UnaryOperatorNot represents '!'
type UnaryOperatorNot struct {
UnaryOperatorBase
}
// Type returns the Type of the expression
func (m *UnaryOperatorNot) Type() Type {
return BoolType{}
}
// UnaryOperatorNegate represents '-'
type UnaryOperatorNegate struct {
UnaryOperatorBase
}
// Type returns the Type of the expression
func (m *UnaryOperatorNegate) Type() Type {
return IntType{}
}
// UnaryOperatorLen represents 'len'
type UnaryOperatorLen struct {
UnaryOperatorBase
}
// Type returns the Type of the expression
func (m *UnaryOperatorLen) Type() Type {
return IntType{}
}
// UnaryOperatorOrd represents 'ord'
type UnaryOperatorOrd struct {
UnaryOperatorBase
}
// Type returns the Type of the expression
func (m *UnaryOperatorOrd) Type() Type {
return IntType{}
}
// UnaryOperatorChr represents 'chr'
type UnaryOperatorChr struct {
UnaryOperatorBase
}
// Type returns the Type of the expression
func (m *UnaryOperatorChr) Type() Type {
return CharType{}
}
// BinaryOperator represents a generic binaryOperator which might be an expr.
type BinaryOperator interface {
Expression
GetRHS() Expression
SetRHS(Expression)
GetLHS() Expression
SetLHS(Expression)
}
// BinaryOperatorBase represents the base of a binary operator.
type BinaryOperatorBase struct {
TokenBase
weightCache int
lhs Expression
rhs Expression
}
// GetLHS returns the left-hand-side associated with a BinaryOperatorBase.
func (m *BinaryOperatorBase) GetLHS() Expression {
return m.lhs
}
// SetLHS sets the left-hand-side associated with a BinaryOperatorBase.
func (m *BinaryOperatorBase) SetLHS(exp Expression) {
m.lhs = exp
}
// GetRHS returns the right-hand-side associated with a BinaryOperatorBase.
func (m *BinaryOperatorBase) GetRHS() Expression {
return m.rhs
}
// SetRHS sets the right-hand-side associated with a BinaryOperatorBase.
func (m *BinaryOperatorBase) SetRHS(exp Expression) {
m.rhs = exp
}
// BinaryOperatorMult represents '*'
type BinaryOperatorMult struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorMult) Type() Type {
return IntType{}
}
// BinaryOperatorDiv represents '/'
type BinaryOperatorDiv struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorDiv) Type() Type {
return IntType{}
}
// BinaryOperatorMod represents '%'
type BinaryOperatorMod struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorMod) Type() Type {
return IntType{}
}
// BinaryOperatorAdd represents '+'
type BinaryOperatorAdd struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorAdd) Type() Type {
return IntType{}
}
// BinaryOperatorSub represents '-'
type BinaryOperatorSub struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorSub) Type() Type {
return IntType{}
}
// BinaryOperatorGreaterThan represents '>'
type BinaryOperatorGreaterThan struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorGreaterThan) Type() Type {
return BoolType{}
}
// BinaryOperatorGreaterEqual represents '>='
type BinaryOperatorGreaterEqual struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorGreaterEqual) Type() Type {
return BoolType{}
}
// BinaryOperatorLessThan represents '<'
type BinaryOperatorLessThan struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorLessThan) Type() Type {
return BoolType{}
}
// BinaryOperatorLessEqual represents '<='
type BinaryOperatorLessEqual struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorLessEqual) Type() Type {
return BoolType{}
}
// BinaryOperatorEqual represents '=='
type BinaryOperatorEqual struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorEqual) Type() Type {
return BoolType{}
}
// BinaryOperatorNotEqual represents '!='
type BinaryOperatorNotEqual struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorNotEqual) Type() Type {
return BoolType{}
}
// BinaryOperatorAnd represents '&&'
type BinaryOperatorAnd struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorAnd) Type() Type {
return BoolType{}
}
// BinaryOperatorOr represents '||'
type BinaryOperatorOr struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorOr) Type() Type {
return BoolType{}
}
// BinaryOperatorBitAnd represents '&'
type BinaryOperatorBitAnd struct {
BinaryOperatorBase
}
// Type returns the Type of the expression
func (m *BinaryOperatorBitAnd) Type() Type {
return IntType{}
}
// BinaryOperatorBitOr represents '|'
type BinaryOperatorBitOr struct {
BinaryOperatorBase
}