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

Method expressionToRegisterOrConstant

code.go:710–732  ·  view source on GitHub ↗
(e exprDesc)

Source from the content-addressed store, hash-verified

708}
709
710func (f *function) expressionToRegisterOrConstant(e exprDesc) (exprDesc, int) {
711 switch e = f.ExpressionToValue(e); e.kind {
712 case kindTrue, kindFalse:
713 if len(f.f.constants) <= maxIndexRK {
714 e.info, e.kind = f.booleanConstant(e.kind == kindTrue), kindConstant
715 return e, asConstant(e.info)
716 }
717 case kindNil:
718 if len(f.f.constants) <= maxIndexRK {
719 e.info, e.kind = f.nilConstant(), kindConstant
720 return e, asConstant(e.info)
721 }
722 case kindNumber:
723 e.info, e.kind = f.NumberConstant(e.value), kindConstant
724 fallthrough
725 case kindConstant:
726 if e.info <= maxIndexRK {
727 return e, asConstant(e.info)
728 }
729 }
730 e = f.ExpressionToAnyRegister(e)
731 return e, e.info
732}
733
734func (f *function) StoreVariable(v, e exprDesc) {
735 switch v.kind {

Callers 7

StoreVariableMethod · 0.95
SelfMethod · 0.95
IndexedMethod · 0.95
encodeArithmeticMethod · 0.95
InfixMethod · 0.95
encodeComparisonMethod · 0.95

Calls 6

ExpressionToValueMethod · 0.95
booleanConstantMethod · 0.95
nilConstantMethod · 0.95
NumberConstantMethod · 0.95
asConstantFunction · 0.85

Tested by

no test coverage detected