MCPcopy Create free account
hub / github.com/Snapchat/Valdi / tsn_binary_arith_slow

Function tsn_binary_arith_slow

tsn/src/tsn/tsn.cpp:611–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609}
610
611static inline tsn_value tsn_binary_arith_slow(tsn_vm* ctx,
612 tsn_binary_arith_slow_op op,
613 tsn_value_const op1,
614 tsn_value_const op2) {
615 double d1;
616 double d2;
617 double r;
618
619 if (unlikely(JS_ToFloat64(ctx, &d1, op1) != 0)) {
620 JS_FreeValue(ctx, op2);
621 return JS_EXCEPTION;
622 }
623 if (unlikely(JS_ToFloat64(ctx, &d2, op2) != 0)) {
624 return JS_EXCEPTION;
625 }
626 switch (op) {
627 case tsn_binary_arith_slow_op::sub:
628 r = d1 - d2;
629 break;
630 case tsn_binary_arith_slow_op::mul:
631 r = d1 * d2;
632 break;
633 case tsn_binary_arith_slow_op::div:
634 r = d1 / d2;
635 break;
636 case tsn_binary_arith_slow_op::mod:
637 r = fmod(d1, d2);
638 break;
639 case tsn_binary_arith_slow_op::pow:
640 r = tsn_pow(d1, d2);
641 break;
642 default:
643 abort();
644 }
645 return JS_NewFloat64(ctx, r);
646}
647
648js_force_inline tsn_value tsn_add_slow_numbers(tsn_vm* ctx, tsn_value op1, tsn_value op2) {
649 double d1;

Callers 3

tsn_op_divFunction · 0.85
tsn_op_multFunction · 0.85
tsn_op_subFunction · 0.85

Calls 3

JS_FreeValueFunction · 0.85
tsn_powFunction · 0.85
JS_NewFloat64Function · 0.85

Tested by

no test coverage detected