diff --git a/main/gbc/gbc_trans.c b/main/gbc/gbc_trans.c index 51ba9dac2..641a7cc79 100644 --- a/main/gbc/gbc_trans.c +++ b/main/gbc/gbc_trans.c @@ -776,7 +776,8 @@ void TRANS_get_constant_value(TRANS_DECL *decl) value = *JOB->current++; index = PATTERN_index(value); - + decl->is_integer = FALSE; + if (PATTERN_is_integer(value)) { decl->is_integer = TRUE; @@ -790,7 +791,11 @@ void TRANS_get_constant_value(TRANS_DECL *decl) if (type == T_SINGLE && !finite((float)number.dval)) THROW("Out of range"); - decl->is_integer = FALSE; + if (COMP_version >= 0x03180000 && number.dval == (double)(int)number.dval && number.dval >= -128 && number.dval <= 127) + { + decl->is_integer = TRUE; + index = (int)number.dval; + } } decl->value = index; diff --git a/main/gbc/gbc_trans_expr.c b/main/gbc/gbc_trans_expr.c index 520a91b54..83adafaf3 100644 --- a/main/gbc/gbc_trans_expr.c +++ b/main/gbc/gbc_trans_expr.c @@ -313,6 +313,8 @@ static void trans_identifier(int index, bool point, PATTERN next) CODE_push_boolean(constant->value); else if (type == T_INTEGER) CODE_push_number(constant->value); + else if (constant->is_integer) + CODE_push_float(constant->value); else CODE_push_const(sym->global.value);