Open KaranaLJX opened 1 year ago
case parser.OpEqual:
right := v.stack[v.sp-1]
left := v.stack[v.sp-2]
v.sp -= 2
if left.Equals(right) { //here use Equals func
v.stack[v.sp] = TrueValue
} else {
v.stack[v.sp] = FalseValue
}
v.sp++
case parser.OpBinaryOp:
v.ip++
right := v.stack[v.sp-1]
left := v.stack[v.sp-2]
tok := token.Token(v.curInsts[v.ip])
res, e := left.BinaryOp(tok, right) //here use binaryop func
if e != nil {
v.sp -= 2
if e == ErrInvalidOperator {
v.err = fmt.Errorf("invalid operation: %s %s %s",
left.TypeName(), tok.String(), right.TypeName())
return
}
v.err = e
return
}
v.allocs--
if v.allocs == 0 {
v.err = ErrObjectAllocLimit
return
}
v.stack[v.sp-2] = res
v.sp--
for int and float type,Why is binaryop compatible with both int and float fields, but not with equal function?