Convert math functions

Converts the following functions from build/make/common/math.mk:
 - math_max
 - math_min
 - math_gt_or_eq
 - math_gt
 - math_lt

Fixes: 213497955
Test: go test
Change-Id: I8c4e8fee321f03b813428fa10038fa8f06188cef
This commit is contained in:
Cole Faust
2022-01-06 15:22:05 -08:00
parent fe306aba98
commit b1103e2578
3 changed files with 178 additions and 0 deletions

View File

@@ -728,6 +728,36 @@ func (f *foreachExpr) transform(transformer func(expr starlarkExpr) starlarkExpr
}
}
type binaryOpExpr struct {
left, right starlarkExpr
op string
returnType starlarkType
}
func (b *binaryOpExpr) emit(gctx *generationContext) {
b.left.emit(gctx)
gctx.write(" " + b.op + " ")
b.right.emit(gctx)
}
func (b *binaryOpExpr) typ() starlarkType {
return b.returnType
}
func (b *binaryOpExpr) emitListVarCopy(gctx *generationContext) {
b.emit(gctx)
}
func (b *binaryOpExpr) transform(transformer func(expr starlarkExpr) starlarkExpr) starlarkExpr {
b.left = b.left.transform(transformer)
b.right = b.right.transform(transformer)
if replacement := transformer(b); replacement != nil {
return replacement
} else {
return b
}
}
type badExpr struct {
errorLocation ErrorLocation
message string