New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmp doesn't works for integers #88
Comments
From @bacekParrot's op cmp doesn't work for integers. $ cat v.pir .local pmc a, b b = new 'Int' $I0 = cmp a, b $I0 = cmp b, a Expected results (Thanks to pmichaud for clean version of test case) |
From @bacekOn Mon May 19 14:10:05 2008, bacek wrote:
I did some investigations. Everything will work, if I'll replace (gdb) r v.pir Breakpoint 3, Parrot_cmp_i_p_p (cur_opcode=0xb23690, interp=0xb09d30) at Breakpoint 6, Parrot_Integer_cmp (interp=0xb09d30, pmc=0xd2bbe0, |
@bacek - Status changed from 'new' to 'open' |
From @bacekThere is a patch for src/pmc/integer.pm to use SELF.get_integer() |
From @bacekinteger.diffIndex: src/pmc/integer.pmc
===================================================================
--- src/pmc/integer.pmc (revision 27652)
+++ src/pmc/integer.pmc (working copy)
@@ -200,7 +200,7 @@
*/
VTABLE FLOATVAL get_number() {
- return (FLOATVAL)PMC_int_val(SELF);
+ return (FLOATVAL)SELF.get_integer();
}
/*
@@ -229,11 +229,11 @@
*/
VTABLE STRING *get_string() {
- return string_from_int(INTERP, PMC_int_val(SELF));
+ return string_from_int(INTERP, SELF.get_integer());
}
VTABLE STRING *get_repr() {
- return string_from_int(INTERP, PMC_int_val(SELF));
+ return string_from_int(INTERP, SELF.get_integer());
}
/*
@@ -413,7 +413,7 @@
}
MMD_DEFAULT: {
VTABLE_set_number_native(INTERP, SELF,
- PMC_int_val(SELF) + VTABLE_get_number(INTERP, value));
+ SELF.get_integer() + VTABLE_get_number(INTERP, value));
}
}
@@ -660,7 +660,7 @@
}
MMD_DEFAULT: {
VTABLE_set_number_native(INTERP, SELF,
- PMC_int_val(SELF) * VTABLE_get_number(INTERP, value));
+ SELF.get_integer() * VTABLE_get_number(INTERP, value));
}
}
@@ -1136,7 +1136,7 @@
VTABLE INTVAL is_equal(PMC *value) {
MMD_BigInt: {
PMC * const temp = pmc_new(INTERP, enum_class_BigInt);
- VTABLE_set_integer_native(INTERP, temp, PMC_int_val(SELF));
+ VTABLE_set_integer_native(INTERP, temp, SELF.get_integer());
return Parrot_BigInt_is_equal_BigInt(INTERP, temp, value);
}
MMD_DEFAULT: {
@@ -1157,10 +1157,10 @@
VTABLE INTVAL cmp(PMC *value) {
MMD_String: {
FLOATVAL fdiff =
- PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_integer() - VTABLE_get_number(INTERP, value);
if (FLOAT_IS_ZERO(fdiff)) {
const INTVAL idiff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
}
else {
@@ -1169,12 +1169,12 @@
}
MMD_Float: {
const FLOATVAL diff =
- (FLOATVAL)PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ (FLOATVAL)SELF.get_integer() - VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
/* int or undef */
- const INTVAL diff = PMC_int_val(SELF)
+ const INTVAL diff = SELF.get_integer()
- VTABLE_get_integer(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
@@ -1192,11 +1192,11 @@
VTABLE INTVAL cmp_num(PMC *value) {
MMD_String: {
FLOATVAL fdiff =
- PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_integer() - VTABLE_get_number(INTERP, value);
if (FLOAT_IS_ZERO(fdiff)) {
const INTVAL idiff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
}
else {
@@ -1205,13 +1205,13 @@
}
MMD_Float: {
const FLOATVAL diff =
- (FLOATVAL)PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ (FLOATVAL)SELF.get_integer() - VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
/* int or undef */
const INTVAL diff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
}
@@ -1308,7 +1308,7 @@
VTABLE void freeze(visit_info *info) {
IMAGE_IO * const io = info->image_io;
SUPER(info);
- VTABLE_push_integer(INTERP, io, PMC_int_val(SELF));
+ VTABLE_push_integer(INTERP, io, SELF.get_integer());
}
/*
|
From @bacekCleaned version of patch. |
From @bacekinteger2.diff--- src/pmc/integer.pmc 2008-05-21 00:31:57.000000000 +1000
+++ src/pmc/integer2.pmc 2008-05-21 00:28:32.000000000 +1000
@@ -187,7 +187,7 @@
*/
VTABLE INTVAL get_bool() {
- return PMC_int_val(SELF) ? 1 : 0;
+ return SELF.get_integer() ? 1 : 0;
}
/*
@@ -200,7 +200,7 @@
*/
VTABLE FLOATVAL get_number() {
- return (FLOATVAL)PMC_int_val(SELF);
+ return SELF.get_integer();
}
/*
@@ -229,11 +229,11 @@
*/
VTABLE STRING *get_string() {
- return string_from_int(INTERP, PMC_int_val(SELF));
+ return string_from_int(INTERP, SELF.get_integer());
}
VTABLE STRING *get_repr() {
- return string_from_int(INTERP, PMC_int_val(SELF));
+ return string_from_int(INTERP, SELF.get_integer());
}
/*
@@ -413,7 +413,7 @@
}
MMD_DEFAULT: {
VTABLE_set_number_native(INTERP, SELF,
- PMC_int_val(SELF) + VTABLE_get_number(INTERP, value));
+ SELF.get_integer() + VTABLE_get_number(INTERP, value));
}
}
@@ -660,7 +660,7 @@
}
MMD_DEFAULT: {
VTABLE_set_number_native(INTERP, SELF,
- PMC_int_val(SELF) * VTABLE_get_number(INTERP, value));
+ SELF.get_integer() * VTABLE_get_number(INTERP, value));
}
}
@@ -1136,7 +1136,7 @@
VTABLE INTVAL is_equal(PMC *value) {
MMD_BigInt: {
PMC * const temp = pmc_new(INTERP, enum_class_BigInt);
- VTABLE_set_integer_native(INTERP, temp, PMC_int_val(SELF));
+ VTABLE_set_integer_native(INTERP, temp, SELF.get_integer());
return Parrot_BigInt_is_equal_BigInt(INTERP, temp, value);
}
MMD_DEFAULT: {
@@ -1157,10 +1157,10 @@
VTABLE INTVAL cmp(PMC *value) {
MMD_String: {
FLOATVAL fdiff =
- PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_number() - VTABLE_get_number(INTERP, value);
if (FLOAT_IS_ZERO(fdiff)) {
const INTVAL idiff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
}
else {
@@ -1169,12 +1169,12 @@
}
MMD_Float: {
const FLOATVAL diff =
- (FLOATVAL)PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_number() - VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
/* int or undef */
- const INTVAL diff = PMC_int_val(SELF)
+ const INTVAL diff = SELF.get_integer()
- VTABLE_get_integer(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
@@ -1192,11 +1192,11 @@
VTABLE INTVAL cmp_num(PMC *value) {
MMD_String: {
FLOATVAL fdiff =
- PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_number() - VTABLE_get_number(INTERP, value);
if (FLOAT_IS_ZERO(fdiff)) {
const INTVAL idiff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
}
else {
@@ -1205,13 +1205,13 @@
}
MMD_Float: {
const FLOATVAL diff =
- (FLOATVAL)PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_number() - VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
/* int or undef */
const INTVAL diff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
}
@@ -1308,7 +1308,7 @@
VTABLE void freeze(visit_info *info) {
IMAGE_IO * const io = info->image_io;
SUPER(info);
- VTABLE_push_integer(INTERP, io, PMC_int_val(SELF));
+ VTABLE_push_integer(INTERP, io, SELF.get_integer());
}
/*
|
From @cokeThe original problem description is a little off: this works for core I was able to use gdb to break in the function called by the cmp op, I suspect that if this is the right fix (see below), that we need to $ svn diff src
|
From @chromaticOn Tuesday 20 May 2008 13:05:43 Will Coleda wrote:
This is correct. PMC_*_val must die. -- c |
From @bacekHello. There is patch for src/pmc/integer.pmc which changes usage of -- |
From @bacekinteger.diffIndex: src/pmc/integer.pmc
===================================================================
--- src/pmc/integer.pmc (revision 27652)
+++ src/pmc/integer.pmc (working copy)
@@ -200,7 +200,7 @@
*/
VTABLE FLOATVAL get_number() {
- return (FLOATVAL)PMC_int_val(SELF);
+ return (FLOATVAL)SELF.get_integer();
}
/*
@@ -229,11 +229,11 @@
*/
VTABLE STRING *get_string() {
- return string_from_int(INTERP, PMC_int_val(SELF));
+ return string_from_int(INTERP, SELF.get_integer());
}
VTABLE STRING *get_repr() {
- return string_from_int(INTERP, PMC_int_val(SELF));
+ return string_from_int(INTERP, SELF.get_integer());
}
/*
@@ -413,7 +413,7 @@
}
MMD_DEFAULT: {
VTABLE_set_number_native(INTERP, SELF,
- PMC_int_val(SELF) + VTABLE_get_number(INTERP, value));
+ SELF.get_integer() + VTABLE_get_number(INTERP, value));
}
}
@@ -660,7 +660,7 @@
}
MMD_DEFAULT: {
VTABLE_set_number_native(INTERP, SELF,
- PMC_int_val(SELF) * VTABLE_get_number(INTERP, value));
+ SELF.get_integer() * VTABLE_get_number(INTERP, value));
}
}
@@ -1136,7 +1136,7 @@
VTABLE INTVAL is_equal(PMC *value) {
MMD_BigInt: {
PMC * const temp = pmc_new(INTERP, enum_class_BigInt);
- VTABLE_set_integer_native(INTERP, temp, PMC_int_val(SELF));
+ VTABLE_set_integer_native(INTERP, temp, SELF.get_integer());
return Parrot_BigInt_is_equal_BigInt(INTERP, temp, value);
}
MMD_DEFAULT: {
@@ -1157,10 +1157,10 @@
VTABLE INTVAL cmp(PMC *value) {
MMD_String: {
FLOATVAL fdiff =
- PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_integer() - VTABLE_get_number(INTERP, value);
if (FLOAT_IS_ZERO(fdiff)) {
const INTVAL idiff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
}
else {
@@ -1169,12 +1169,12 @@
}
MMD_Float: {
const FLOATVAL diff =
- (FLOATVAL)PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ (FLOATVAL)SELF.get_integer() - VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
/* int or undef */
- const INTVAL diff = PMC_int_val(SELF)
+ const INTVAL diff = SELF.get_integer()
- VTABLE_get_integer(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
@@ -1192,11 +1192,11 @@
VTABLE INTVAL cmp_num(PMC *value) {
MMD_String: {
FLOATVAL fdiff =
- PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ SELF.get_integer() - VTABLE_get_number(INTERP, value);
if (FLOAT_IS_ZERO(fdiff)) {
const INTVAL idiff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
}
else {
@@ -1205,13 +1205,13 @@
}
MMD_Float: {
const FLOATVAL diff =
- (FLOATVAL)PMC_int_val(SELF) - VTABLE_get_number(INTERP, value);
+ (FLOATVAL)SELF.get_integer() - VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
/* int or undef */
const INTVAL diff =
- PMC_int_val(SELF) - VTABLE_get_integer(INTERP, value);
+ SELF.get_integer() - VTABLE_get_integer(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
}
@@ -1308,7 +1308,7 @@
VTABLE void freeze(visit_info *info) {
IMAGE_IO * const io = info->image_io;
SUPER(info);
- VTABLE_push_integer(INTERP, io, PMC_int_val(SELF));
+ VTABLE_push_integer(INTERP, io, SELF.get_integer());
}
/*
|
From @bacekOn Tue May 20 13:18:36 2008, chromatic@wgz.org wrote:
I've created patch with replacing PMC_int_val with SELF.get_integer(). -- |
From @jnthnOn Tue May 20 15:08:28 2008, bacek wrote:
Applied as r27700, thanks. Jonathan |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#54474 (status was 'resolved')
Searchable as RT54474$
The text was updated successfully, but these errors were encountered: