Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions cobj/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,6 @@ static const char *const bin_set_funcs[] = {NULL,
"setSwpS56Binary",
"setSwpS64Binary"};

static const char *const bin_compare_funcs[] = {
"cmpU8Binary", "cmpU16Binary", "cmpU24Binary", "cmpU32Binary",
"cmpU40Binary", "cmpU48Binary", "cmpU56Binary", "cmpU64Binary",
"cmpS8Binary", "cmpS16Binary", "cmpS24Binary", "cmpS32Binary",
"cmpS40Binary", "cmpS48Binary", "cmpS56Binary", "cmpS64Binary",
"cmpU8Binary", "cmpSwpU16Binary", "cmpSwpU24Binary", "cmpSwpU32Binary",
"cmpSwpU40Binary", "cmpSwpU48Binary", "cmpSwpU56Binary", "cmpSwpU64Binary",
"cmpS8Binary", "cmpSwpS16Binary", "cmpSwpS24Binary", "cmpSwpS32Binary",
"cmpSwpS40Binary", "cmpSwpS48Binary", "cmpSwpS56Binary", "cmpSwpS64Binary"};

static const char *const bin_add_funcs[] = {
"addU8Binary", "addU16Binary", "addU24Binary", "addU32Binary",
"addU40Binary", "addU48Binary", "addU56Binary", "addU64Binary",
Expand Down Expand Up @@ -2245,18 +2235,18 @@ static cb_tree cb_build_optim_cond(struct cb_binary_op *p) {
if (!fy->pic->have_sign &&
(fy->usage == CB_USAGE_BINARY || fy->usage == CB_USAGE_COMP_5 ||
fy->usage == CB_USAGE_COMP_X)) {
return cb_build_method_call_2("cmpUint", p->x,
return cb_build_method_call_2("cmpInteger", p->x,
cb_build_cast_integer(p->y));
}
}
if (CB_REF_OR_FIELD_P(p->x)) {
struct cb_field *f = cb_field(p->x);
if (!f->pic->scale && f->usage == CB_USAGE_PACKED) {
if (f->pic->digits < 10) {
return cb_build_method_call_2("cmpInt", p->x,
return cb_build_method_call_2("cmpInteger", p->x,
cb_build_cast_integer(p->y));
} else {
return cb_build_method_call_2("cmpInt", p->x,
return cb_build_method_call_2("cmpInteger", p->x,
cb_build_cast_integer(p->y));
}
}
Expand Down Expand Up @@ -2287,16 +2277,12 @@ static cb_tree cb_build_optim_cond(struct cb_binary_op *p) {
if (!f->pic->scale &&
(f->usage == CB_USAGE_BINARY || f->usage == CB_USAGE_COMP_5 ||
f->usage == CB_USAGE_INDEX || f->usage == CB_USAGE_COMP_X)) {
size_t n = (f->size - 1) + (8 * (f->pic->have_sign ? 1 : 0)) +
(16 * (f->flag_binary_swap ? 1 : 0));
const char *s = bin_compare_funcs[n];
if (s) {
return cb_build_method_call_2(s, cb_build_cast_address(p->x),
cb_build_cast_integer(p->y));
}
return cb_build_method_call_2("cmpInteger", p->x,
cb_build_cast_integer(p->y));
}
}
return cb_build_method_call_2("cmpInt", p->x, cb_build_cast_integer(p->y));
return cb_build_method_call_2("cmpInteger", p->x,
cb_build_cast_integer(p->y));
}

static int cb_chk_num_cond(cb_tree x, cb_tree y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ public int divRemainder(int opt) throws CobolStopRunException {
}

/**
* TODO: 準備中
*
* @param n TODO: 準備中
* @return TODO: 準備中
* 整数値との比較を行う
* @deprecated 代わりにcmpIntegerを使用してください
* @param n 比較対象の整数値
* @return 保持する数値データの比較を行い,this&lt;nなら負の値,this==nなら0,this&gt;nなら正の値
*/
public int cmpInt(int n) {
CobolDecimal d1 = this.getDecimal();
Expand All @@ -427,30 +427,51 @@ public int cmpInt(int n) {
}

/**
* TODO: 準備中
*
* @param n TODO: 準備中
* @return TODO: 準備中
* 整数値との比較を行う
* @deprecated 代わりにcmpIntegerを使用してください
* @param n 比較対象の整数値
* @return 保持する数値データの比較を行い,this&lt;nなら負の値,this==nなら0,this&gt;nなら正の値
*/
public int cmpInt(long n) {
return this.cmpInt((int) n);
}

/**
* TODO: 準備中
*
* @param n TODO: 準備中
* @return TODO: 準備中
* 整数値との比較を行う
* @param n 比較対象の整数値
* @return 保持する数値データの比較を行い,this&lt;nなら負の値,this==nなら0,this&gt;nなら正の値
*/
public int cmpInteger(long n) {
CobolDecimal d1 = this.getDecimal();
CobolDecimal d2 = new CobolDecimal(n);
d2.setScale(0);
return d1.compareTo(d2);
}

/**
* 整数値との比較を行う
* @param n 比較対象の整数値
* @return 保持する数値データの比較を行い,this&lt;nなら負の値,this==nなら0,this&gt;nなら正の値
*/
public int cmpInteger(int n) {
return this.cmpInteger((long) n);
}

/**
* 整数値との比較を行う
* @deprecated 代わりにcmpIntegerを使用してください
* @param n 比較対象の整数値
* @return 保持する数値データの比較を行い,this&lt;nなら負の値,this==nなら0,this&gt;nなら正の値
*/
public int cmpUint(int n) {
return this.cmpInt(n);
}

/**
* TODO: 準備中
*
* @param n TODO: 準備中
* @return TODO: 準備中
* 整数値との比較を行う
* @deprecated 代わりにcmpIntegerを使用してください
* @param n 比較対象の整数値
* @return 保持する数値データの比較を行い,this&lt;nなら負の値,this==nなら0,this&gt;nなら正の値
*/
public int cmpUint(long n) {
return this.cmpUint((int) n);
Expand Down
Loading
Loading