This commit is contained in:
parent
36f76170f5
commit
7a8cb43e9f
6 changed files with 66 additions and 6 deletions
|
@ -211,6 +211,32 @@ func (f *Function) Evaluate(expr *expression.Expression) (ssa.Value, error) {
|
|||
return nil, errors.New(&UnknownIdentifier{Name: label}, f.File, left.Token.Position)
|
||||
|
||||
default:
|
||||
if expr.Token.IsOperator() {
|
||||
left := expr.Children[0]
|
||||
right := expr.Children[1]
|
||||
|
||||
leftValue, err := f.Evaluate(left)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rightValue, err := f.Evaluate(right)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v := f.Append(&ssa.BinaryOp{
|
||||
Left: leftValue,
|
||||
Right: rightValue,
|
||||
Op: expr.Token.Kind,
|
||||
Source: ssa.Source(expr.Source),
|
||||
})
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
panic("not implemented")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue