Simplified constant folding
This commit is contained in:
parent
818477f5c3
commit
f87cda97e2
5 changed files with 51 additions and 25 deletions
|
@ -11,9 +11,8 @@ type Expression struct {
|
|||
Parent *Expression
|
||||
Children []*Expression
|
||||
Token token.Token
|
||||
Value int
|
||||
Precedence int8
|
||||
IsFolded bool
|
||||
Foldable
|
||||
}
|
||||
|
||||
// New creates a new expression.
|
||||
|
@ -62,8 +61,8 @@ func (expr *Expression) Reset() {
|
|||
}
|
||||
|
||||
expr.Token.Reset()
|
||||
expr.Value = 0
|
||||
expr.Precedence = 0
|
||||
expr.Value = 0
|
||||
expr.IsFolded = false
|
||||
}
|
||||
|
||||
|
|
7
src/expression/Foldable.go
Normal file
7
src/expression/Foldable.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package expression
|
||||
|
||||
// Foldable has optional fields that are used for constant folding later.
|
||||
type Foldable struct {
|
||||
Value int
|
||||
IsFolded bool
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue