Simplified constant folding

This commit is contained in:
Eduard Urbach 2025-02-26 20:02:53 +01:00
parent 818477f5c3
commit f87cda97e2
Signed by: eduard
GPG key ID: 49226B848C78F6C8
5 changed files with 51 additions and 25 deletions

View file

@ -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
}

View 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
}