mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-22 03:30:46 +00:00
added more auto-conversions from 1-char-strings to integer
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@252 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
1261960cad
commit
89344d34ee
28
src/alu.c
28
src/alu.c
@ -43,6 +43,7 @@ static const char exception_no_value[] = "No value given.";
|
||||
static const char exception_paren_open[] = "Too many '('.";
|
||||
static const char exception_not_number[] = "Expression did not return a number.";
|
||||
static const char exception_float_to_int[]= "Converted to integer for binary logic operator.";
|
||||
static const char exception_lengthnot1[] = "String length is not 1.";
|
||||
|
||||
enum op_group {
|
||||
OPGROUP_SPECIAL, // start/end of expression, and parentheses
|
||||
@ -2481,6 +2482,16 @@ void ALU_any_int(intval_t *target) // ACCEPT_UNDEFINED
|
||||
*target = expression.result.u.number.val.fpval;
|
||||
else
|
||||
Bug_found("IllegalNumberType6", expression.result.u.number.ntype);
|
||||
} else if (expression.result.type == &type_string) {
|
||||
// accept single-char strings, to be more
|
||||
// compatible with versions before 0.97:
|
||||
if (expression.result.u.string->length != 1) {
|
||||
Throw_error(exception_lengthnot1);
|
||||
} else {
|
||||
// FIXME - throw a warning?
|
||||
}
|
||||
string_to_byte(&(expression.result), 0);
|
||||
*target = expression.result.u.number.val.intval;
|
||||
} else {
|
||||
*target = 0;
|
||||
Throw_error(exception_not_number);
|
||||
@ -2518,6 +2529,15 @@ void ALU_defined_int(struct number *intresult) // no ACCEPT constants?
|
||||
} else {
|
||||
Bug_found("IllegalNumberType7", expression.result.u.number.ntype);
|
||||
}
|
||||
} else if (expression.result.type == &type_string) {
|
||||
// accept single-char strings, to be more
|
||||
// compatible with versions before 0.97:
|
||||
if (expression.result.u.string->length != 1) {
|
||||
Throw_error(exception_lengthnot1);
|
||||
} else {
|
||||
// FIXME - throw a warning?
|
||||
}
|
||||
string_to_byte(&(expression.result), 0);
|
||||
} else {
|
||||
Throw_serious_error(exception_not_number);
|
||||
}
|
||||
@ -2544,12 +2564,12 @@ void ALU_addrmode_int(struct expression *expression, int paren) // ACCEPT_UNDEFI
|
||||
} else if (expression->result.type == &type_string) {
|
||||
// accept single-char strings, to be more
|
||||
// compatible with versions before 0.97:
|
||||
if (expression->result.u.string->length == 1) {
|
||||
// FIXME - throw a warning?
|
||||
string_to_byte(&(expression->result), 0);
|
||||
if (expression->result.u.string->length != 1) {
|
||||
Throw_error(exception_lengthnot1);
|
||||
} else {
|
||||
Throw_error("String length is not 1.");
|
||||
// FIXME - throw a warning?
|
||||
}
|
||||
string_to_byte(&(expression->result), 0);
|
||||
} else {
|
||||
Throw_error(exception_not_number);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user