MCPcopy Index your code
hub / github.com/Shopify/go-lua / foldConstants

Function foldConstants

code.go:853–861  ·  view source on GitHub ↗
(op opCode, e1, e2 exprDesc)

Source from the content-addressed store, hash-verified

851}
852
853func foldConstants(op opCode, e1, e2 exprDesc) (exprDesc, bool) {
854 if !e1.isNumeral() || !e2.isNumeral() {
855 return e1, false
856 } else if (op == opDiv || op == opMod) && e2.value == 0.0 {
857 return e1, false
858 }
859 e1.value = arith(Operator(op-opAdd)+OpAdd, e1.value, e2.value)
860 return e1, true
861}
862
863func (f *function) encodeArithmetic(op opCode, e1, e2 exprDesc, line int) exprDesc {
864 if e, folded := foldConstants(op, e1, e2); folded {

Callers 1

encodeArithmeticMethod · 0.85

Calls 3

arithFunction · 0.85
OperatorTypeAlias · 0.85
isNumeralMethod · 0.80

Tested by

no test coverage detected