corto_int16 corto_ptr_binaryOp(corto_type type, corto_operatorKind operator, void *operand1, void *operand2, void *result) { if (type->kind == CORTO_PRIMITIVE) { corto__binaryOperator impl = corto_binaryOps[corto_primitive(type)->convertId][operator]; if (impl) { impl(operand1, operand2, result); } else { corto_seterr("binary operator '%s' is not implemented for type '%s'", corto_idof(corto_enum_constant(corto_operatorKind_o, operator)), corto_fullpath(NULL, type)); goto error; } } else if (operator == CORTO_ASSIGN) { corto_ptr_copy(operand1, type, operand2); if (result && result != operand1) { corto_ptr_copy(result, type, operand1); } } else { corto_seterr("invalid operand for non-scalar type"); goto error; } return 0; error: return -1; }
corto_int16 corto_binaryOperator(corto_type type, corto_operatorKind operator, void *operand1, void *operand2, void *result) { if (type->kind == CORTO_PRIMITIVE) { corto__binaryOperator impl = corto_binaryOps[corto_primitive(type)->convertId][operator]; if (impl) { impl(operand1, operand2, result); } else { corto_seterr("binary operator '%s' is not implemented for type '%s'", corto_idof(corto_enum_constant(corto_operatorKind_o, operator)), corto_fullpath(NULL, type)); goto error; } } return 0; error: return -1; }