|
|
@@ -602,32 +602,32 @@ FrameResult VM__run_top_frame(VM* self) {
|
|
|
DISPATCH();
|
|
|
}
|
|
|
/*****************************/
|
|
|
-#define CASE_BINARY_OP(label, op, rop)\
|
|
|
- case label: {\
|
|
|
- if(!pk_stack_binaryop(self, op, rop)) goto __ERROR;\
|
|
|
- POP();\
|
|
|
- *TOP() = self->last_retval;\
|
|
|
- DISPATCH();\
|
|
|
- }
|
|
|
- CASE_BINARY_OP(OP_BINARY_ADD, __add__, __radd__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_SUB, __sub__, __rsub__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_MUL, __mul__, __rmul__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_TRUEDIV, __truediv__, __rtruediv__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_FLOORDIV, __floordiv__, __rfloordiv__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_MOD, __mod__, __rmod__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_POW, __pow__, __rpow__)
|
|
|
- CASE_BINARY_OP(OP_BINARY_LSHIFT, __lshift__, 0)
|
|
|
- CASE_BINARY_OP(OP_BINARY_RSHIFT, __rshift__, 0)
|
|
|
- CASE_BINARY_OP(OP_BINARY_AND, __and__, 0)
|
|
|
- CASE_BINARY_OP(OP_BINARY_OR, __or__, 0)
|
|
|
- CASE_BINARY_OP(OP_BINARY_XOR, __xor__, 0)
|
|
|
- CASE_BINARY_OP(OP_BINARY_MATMUL, __matmul__, 0)
|
|
|
- CASE_BINARY_OP(OP_COMPARE_LT, __lt__, __gt__)
|
|
|
- CASE_BINARY_OP(OP_COMPARE_LE, __le__, __ge__)
|
|
|
- CASE_BINARY_OP(OP_COMPARE_EQ, __eq__, __eq__)
|
|
|
- CASE_BINARY_OP(OP_COMPARE_NE, __ne__, __ne__)
|
|
|
- CASE_BINARY_OP(OP_COMPARE_GT, __gt__, __lt__)
|
|
|
- CASE_BINARY_OP(OP_COMPARE_GE, __ge__, __le__)
|
|
|
+#define CASE_BINARY_OP(label, op, rop) \
|
|
|
+ case label: { \
|
|
|
+ if(!pk_stack_binaryop(self, op, rop)) goto __ERROR; \
|
|
|
+ POP(); \
|
|
|
+ *TOP() = self->last_retval; \
|
|
|
+ DISPATCH(); \
|
|
|
+ }
|
|
|
+ CASE_BINARY_OP(OP_BINARY_ADD, __add__, __radd__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_SUB, __sub__, __rsub__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_MUL, __mul__, __rmul__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_TRUEDIV, __truediv__, __rtruediv__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_FLOORDIV, __floordiv__, __rfloordiv__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_MOD, __mod__, __rmod__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_POW, __pow__, __rpow__)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_LSHIFT, __lshift__, 0)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_RSHIFT, __rshift__, 0)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_AND, __and__, 0)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_OR, __or__, 0)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_XOR, __xor__, 0)
|
|
|
+ CASE_BINARY_OP(OP_BINARY_MATMUL, __matmul__, 0)
|
|
|
+ CASE_BINARY_OP(OP_COMPARE_LT, __lt__, __gt__)
|
|
|
+ CASE_BINARY_OP(OP_COMPARE_LE, __le__, __ge__)
|
|
|
+ CASE_BINARY_OP(OP_COMPARE_EQ, __eq__, __eq__)
|
|
|
+ CASE_BINARY_OP(OP_COMPARE_NE, __ne__, __ne__)
|
|
|
+ CASE_BINARY_OP(OP_COMPARE_GT, __gt__, __lt__)
|
|
|
+ CASE_BINARY_OP(OP_COMPARE_GE, __ge__, __le__)
|
|
|
#undef CASE_BINARY_OP
|
|
|
case OP_IS_OP: {
|
|
|
bool res = py_isidentical(SECOND(), TOP());
|
|
|
@@ -1319,17 +1319,11 @@ bool py_binaryop(py_Ref lhs, py_Ref rhs, py_Name op, py_Name rop) {
|
|
|
return ok;
|
|
|
}
|
|
|
|
|
|
-bool py_binaryadd(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __add__, __radd__);
|
|
|
-}
|
|
|
+bool py_binaryadd(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __add__, __radd__); }
|
|
|
|
|
|
-bool py_binarysub(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __sub__, __rsub__);
|
|
|
-}
|
|
|
+bool py_binarysub(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __sub__, __rsub__); }
|
|
|
|
|
|
-bool py_binarymul(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __mul__, __rmul__);
|
|
|
-}
|
|
|
+bool py_binarymul(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __mul__, __rmul__); }
|
|
|
|
|
|
bool py_binarytruediv(py_Ref lhs, py_Ref rhs) {
|
|
|
return py_binaryop(lhs, rhs, __truediv__, __rtruediv__);
|
|
|
@@ -1339,37 +1333,33 @@ bool py_binaryfloordiv(py_Ref lhs, py_Ref rhs) {
|
|
|
return py_binaryop(lhs, rhs, __floordiv__, __rfloordiv__);
|
|
|
}
|
|
|
|
|
|
-bool py_binarymod(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __mod__, __rmod__);
|
|
|
-}
|
|
|
+bool py_binarymod(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __mod__, __rmod__); }
|
|
|
|
|
|
-bool py_binarypow(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __pow__, __rpow__);
|
|
|
-}
|
|
|
+bool py_binarypow(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __pow__, __rpow__); }
|
|
|
|
|
|
-bool py_binarylshift(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __lshift__, 0);
|
|
|
-}
|
|
|
+bool py_binarylshift(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __lshift__, 0); }
|
|
|
|
|
|
-bool py_binaryrshift(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __rshift__, 0);
|
|
|
-}
|
|
|
+bool py_binaryrshift(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __rshift__, 0); }
|
|
|
|
|
|
-bool py_binaryand(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __and__, 0);
|
|
|
-}
|
|
|
+bool py_binaryand(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __and__, 0); }
|
|
|
|
|
|
-bool py_binaryor(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __or__, 0);
|
|
|
-}
|
|
|
+bool py_binaryor(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __or__, 0); }
|
|
|
|
|
|
-bool py_binaryxor(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __xor__, 0);
|
|
|
-}
|
|
|
+bool py_binaryxor(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __xor__, 0); }
|
|
|
|
|
|
-bool py_binarymatmul(py_Ref lhs, py_Ref rhs) {
|
|
|
- return py_binaryop(lhs, rhs, __matmul__, 0);
|
|
|
-}
|
|
|
+bool py_binarymatmul(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __matmul__, 0); }
|
|
|
+
|
|
|
+bool py_eq(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __eq__, __eq__); }
|
|
|
+
|
|
|
+bool py_ne(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __ne__, __ne__); }
|
|
|
+
|
|
|
+bool py_lt(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __lt__, __gt__); }
|
|
|
+
|
|
|
+bool py_le(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __le__, __ge__); }
|
|
|
+
|
|
|
+bool py_gt(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __gt__, __lt__); }
|
|
|
+
|
|
|
+bool py_ge(py_Ref lhs, py_Ref rhs) { return py_binaryop(lhs, rhs, __ge__, __le__); }
|
|
|
|
|
|
static bool stack_format_object(VM* self, c11_sv spec) {
|
|
|
// format TOS via `spec` inplace
|