8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:03:04 +01:00

Some changes as per Claudio comments

This commit is contained in:
asfernandes 2007-04-16 15:31:28 +00:00
parent 68f806099a
commit f7b7f2b96f
4 changed files with 35 additions and 74 deletions

View File

@ -159,22 +159,32 @@ static double cot(double value)
}
static void makeDoubleResult(DataTypeUtilBase* dataTypeUtil, SysFunction* function, dsc* result, int argsCount, const dsc** args)
static bool initResult(dsc* result, int argsCount, const dsc** args, bool* isNullable)
{
bool isNullable = false;
*isNullable = false;
for (int i = 0; i < argsCount; ++i)
{
if (args[i]->isNull())
{
result->makeNullString();
return;
return true;
}
if (args[i]->isNullable())
isNullable = true;
*isNullable = true;
}
return false;
}
static void makeDoubleResult(DataTypeUtilBase* dataTypeUtil, SysFunction* function, dsc* result, int argsCount, const dsc** args)
{
bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
return;
result->makeDouble();
result->setNullable(isNullable);
}
@ -189,19 +199,9 @@ static void makeFromListResult(DataTypeUtilBase* dataTypeUtil, SysFunction* func
static void makeInt64Result(DataTypeUtilBase* dataTypeUtil, SysFunction* function, dsc* result, int argsCount, const dsc** args)
{
bool isNullable = false;
for (int i = 0; i < argsCount; ++i)
{
if (args[i]->isNull())
{
result->makeNullString();
return;
}
if (args[i]->isNullable())
isNullable = true;
}
bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
return;
result->makeInt64(0);
result->setNullable(isNullable);
@ -210,19 +210,9 @@ static void makeInt64Result(DataTypeUtilBase* dataTypeUtil, SysFunction* functio
static void makeLongResult(DataTypeUtilBase* dataTypeUtil, SysFunction* function, dsc* result, int argsCount, const dsc** args)
{
bool isNullable = false;
for (int i = 0; i < argsCount; ++i)
{
if (args[i]->isNull())
{
result->makeNullString();
return;
}
if (args[i]->isNullable())
isNullable = true;
}
bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
return;
result->makeLong(0);
result->setNullable(isNullable);
@ -244,19 +234,9 @@ static void makeLongStringOrBlobResult(DataTypeUtilBase* dataTypeUtil, SysFuncti
static void makeShortResult(DataTypeUtilBase* dataTypeUtil, SysFunction* function, dsc* result, int argsCount, const dsc** args)
{
bool isNullable = false;
for (int i = 0; i < argsCount; ++i)
{
if (args[i]->isNull())
{
result->makeNullString();
return;
}
if (args[i]->isNullable())
isNullable = true;
}
bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
return;
result->makeShort(0);
result->setNullable(isNullable);
@ -487,19 +467,9 @@ static void makeOverlay(DataTypeUtilBase* dataTypeUtil, SysFunction* function, d
{
fb_assert(argsCount >= function->minArgCount);
bool isNullable = false;
for (int i = 0; i < argsCount; ++i)
{
if (args[i]->isNull())
{
result->makeNullString();
return;
}
if (args[i]->isNullable())
isNullable = true;
}
bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
return;
const dsc* value = args[0];
const dsc* placing = args[1];
@ -532,19 +502,9 @@ static void makePad(DataTypeUtilBase* dataTypeUtil, SysFunction* function, dsc*
{
fb_assert(argsCount >= function->minArgCount);
bool isNullable = false;
for (int i = 0; i < argsCount; ++i)
{
if (args[i]->isNull())
{
result->makeNullString();
return;
}
if (args[i]->isNullable())
isNullable = true;
}
bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
return;
const dsc* value1 = args[0];
const dsc* value2 = (argsCount >= 3 ? args[2] : NULL);
@ -783,8 +743,8 @@ static dsc* evlAsciiChar(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_n
if (!(code >= 0 && code <= 255))
status_exception::raise(isc_arith_except, 0);
impure->vlu_misc.vlu_char = (SCHAR) code;
impure->vlu_desc.makeText(1, ttype_none, (UCHAR*) &impure->vlu_misc.vlu_char);
impure->vlu_misc.vlu_uchar = (UCHAR) code;
impure->vlu_desc.makeText(1, ttype_none, &impure->vlu_misc.vlu_uchar);
return &impure->vlu_desc;
}

View File

@ -207,7 +207,7 @@ struct impure_value {
USHORT vlu_flags; // Computed/invariant flags
VaryingString* vlu_string;
union {
SCHAR vlu_char;
UCHAR vlu_uchar;
SSHORT vlu_short;
SLONG vlu_long;
SINT64 vlu_int64;
@ -500,6 +500,7 @@ const int e_domval_length = sizeof (DSC) / sizeof(::Jrd::jrd_nod*); // Room for
// System function expression
const int e_sysfun_args = 0;
const int e_sysfun_function = 1;
const int e_sysfun_count = 1;
const int e_sysfun_length = 2;
// Request resources

View File

@ -2457,7 +2457,7 @@ static jrd_nod* par_sys_function(thread_db* tdbb, CompilerScratch* csb)
}
jrd_nod* node = PAR_make_node(tdbb, e_sysfun_length);
node->nod_count = 1;
node->nod_count = count_table[blr_sys_function];
node->nod_arg[e_sysfun_args] = par_args(tdbb, csb, VALUE);
node->nod_arg[e_sysfun_function] = (jrd_nod*) function;

View File

@ -218,7 +218,7 @@ static const VERB verbs[] =
PAIR(nod_strlen, blr_strlen, e_strlen_length, e_strlen_count, VALUE, VALUE),
PAIR(nod_trim, blr_trim, e_trim_length, e_trim_count, VALUE, VALUE),
PAIR(nod_init_variable, blr_init_variable, e_init_var_length, 0, STATEMENT, OTHER),
PAIR(nod_sys_function, blr_sys_function, 0, 0, VALUE, VALUE),
PAIR(nod_sys_function, blr_sys_function, e_sysfun_length, e_sysfun_count, VALUE, VALUE),
{0, NULL, NULL, NULL, NULL, NULL, NULL}
};