reduce mcode
This commit is contained in:
@@ -1112,7 +1112,10 @@ static JSValue reg_vm_binop(JSContext *ctx, int op, JSValue a, JSValue b) {
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
/* Different types: EQ→false, NEQ→true, others→false */
|
||||
/* Different types for ordering comparisons: disrupt */
|
||||
if (op >= MACH_LT && op <= MACH_GE)
|
||||
return JS_RaiseDisrupt(ctx, "cannot compare: operands must be same type");
|
||||
/* EQ/NEQ with different types: false/true */
|
||||
if (op == MACH_NEQ) return JS_NewBool(ctx, 1);
|
||||
return JS_NewBool(ctx, 0);
|
||||
}
|
||||
@@ -3045,6 +3048,13 @@ static MachCode *mcode_lower_func(cJSON *fobj, const char *filename) {
|
||||
else if (strcmp(op, "ceiling") == 0) { ABC3(MACH_CEILING); }
|
||||
else if (strcmp(op, "round") == 0) { ABC3(MACH_ROUND); }
|
||||
else if (strcmp(op, "trunc") == 0) { ABC3(MACH_TRUNC); }
|
||||
/* Generic comparisons */
|
||||
else if (strcmp(op, "eq") == 0) { ABC3(MACH_EQ); }
|
||||
else if (strcmp(op, "ne") == 0) { ABC3(MACH_NEQ); }
|
||||
else if (strcmp(op, "lt") == 0) { ABC3(MACH_LT); }
|
||||
else if (strcmp(op, "le") == 0) { ABC3(MACH_LE); }
|
||||
else if (strcmp(op, "gt") == 0) { ABC3(MACH_GT); }
|
||||
else if (strcmp(op, "ge") == 0) { ABC3(MACH_GE); }
|
||||
/* Typed integer comparisons */
|
||||
else if (strcmp(op, "eq_int") == 0) { ABC3(MACH_EQ_INT); }
|
||||
else if (strcmp(op, "ne_int") == 0) { ABC3(MACH_NE_INT); }
|
||||
|
||||
Reference in New Issue
Block a user