mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-26 13:50:53 +00:00
fteqcc __GITDESC__ et all were not quite working properly. Fix bitnot operator.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5972 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
e41e42b966
commit
9d8b442cf3
2 changed files with 65 additions and 39 deletions
|
@ -9762,6 +9762,47 @@ QCC_sref_t QCC_PR_GenerateLogicalNot(QCC_sref_t e, const char *errormessage)
|
||||||
return nullsref;
|
return nullsref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QCC_sref_t QCC_PR_GenerateBitwiseNot(QCC_sref_t e, const char *errormessage)
|
||||||
|
{
|
||||||
|
etype_t t;
|
||||||
|
QCC_type_t *type = e.cast;
|
||||||
|
while(type->type == ev_accessor || type->type == ev_boolean)
|
||||||
|
type = type->parentclass;
|
||||||
|
t = type->type;
|
||||||
|
if (t == ev_float)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_F], e, nullsref, NULL);
|
||||||
|
else if (t == ev_string)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[flag_brokenifstring?OP_NOT_ENT:OP_NOT_S], e, nullsref, NULL);
|
||||||
|
// else if (t == ev_entity)
|
||||||
|
// return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_ENT], e, nullsref, NULL);
|
||||||
|
else if (t == ev_vector)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_V], e, nullsref, NULL);
|
||||||
|
// else if (t == ev_function)
|
||||||
|
// return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_FNC], e, nullsref, NULL);
|
||||||
|
else if (t == ev_integer || t == ev_uint)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I], e, nullsref, NULL); //functions are integer values too.
|
||||||
|
else if (t == ev_pointer)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I], e, nullsref, NULL); //Pointers are too.
|
||||||
|
else if (t == ev_double)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_D], e, QCC_MakeDoubleConst(0), NULL);
|
||||||
|
else if (t == ev_int64)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I64], e, QCC_MakeInt64Const(0), NULL);
|
||||||
|
else if (t == ev_uint64)
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_BITNOT_U64], e, QCC_MakeUInt64Const(0), NULL);
|
||||||
|
else if (t == ev_void && flag_laxcasts)
|
||||||
|
{
|
||||||
|
QCC_PR_ParseWarning(WARN_LAXCAST, errormessage, "void");
|
||||||
|
return QCC_PR_Statement (&pr_opcodes[OP_NOT_F], e, nullsref, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char etype[256];
|
||||||
|
TypeName(e.cast, etype, sizeof(etype));
|
||||||
|
|
||||||
|
QCC_PR_ParseError (ERR_BADNOTTYPE, errormessage, etype);
|
||||||
|
return nullsref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//doesn't consider parents
|
//doesn't consider parents
|
||||||
static QCC_sref_t QCC_TryEvaluateCast(QCC_sref_t src, QCC_type_t *cast, pbool implicit)
|
static QCC_sref_t QCC_TryEvaluateCast(QCC_sref_t src, QCC_type_t *cast, pbool implicit)
|
||||||
|
@ -10042,7 +10083,6 @@ static QCC_ref_t *QCC_PR_RefTerm (QCC_ref_t *retbuf, unsigned int exprflags)
|
||||||
{
|
{
|
||||||
QCC_ref_t *r;
|
QCC_ref_t *r;
|
||||||
QCC_sref_t e, e2;
|
QCC_sref_t e, e2;
|
||||||
etype_t t;
|
|
||||||
if (pr_token_type == tt_punct) //a little extra speed...
|
if (pr_token_type == tt_punct) //a little extra speed...
|
||||||
{
|
{
|
||||||
int preinc;
|
int preinc;
|
||||||
|
@ -10108,29 +10148,8 @@ static QCC_ref_t *QCC_PR_RefTerm (QCC_ref_t *retbuf, unsigned int exprflags)
|
||||||
if (QCC_PR_CheckToken ("~"))
|
if (QCC_PR_CheckToken ("~"))
|
||||||
{
|
{
|
||||||
e = QCC_PR_Expression (NOT_PRIORITY, EXPR_DISALLOW_COMMA|EXPR_WARN_ABOVE_1);
|
e = QCC_PR_Expression (NOT_PRIORITY, EXPR_DISALLOW_COMMA|EXPR_WARN_ABOVE_1);
|
||||||
t = e.cast->type;
|
e = QCC_PR_GenerateBitwiseNot(e, "Type mismatch: ~%s");
|
||||||
if (t == ev_accessor)
|
return QCC_DefToRef(retbuf, e);
|
||||||
t = e.cast->parentclass->type;
|
|
||||||
if (t == ev_float)
|
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_F], e, nullsref, NULL);
|
|
||||||
// else if (t == ev_double)
|
|
||||||
// e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_D], e, nullsref, NULL);
|
|
||||||
else if (t == ev_integer)
|
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I], e, nullsref, NULL);
|
|
||||||
else if (t == ev_uint)
|
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_U], e, nullsref, NULL);
|
|
||||||
else if (t == ev_int64)
|
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I64], e, nullsref, NULL);
|
|
||||||
else if (t == ev_uint64)
|
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_U64], e, nullsref, NULL);
|
|
||||||
else if (t == ev_vector)
|
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_V], e, nullsref, NULL);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e2 = nullsref; // shut up compiler warning;
|
|
||||||
QCC_PR_ParseError (ERR_BADNOTTYPE, "type mismatch for binary not");
|
|
||||||
}
|
|
||||||
return QCC_DefToRef(retbuf, e2);
|
|
||||||
}
|
}
|
||||||
if (QCC_PR_CheckToken ("&"))
|
if (QCC_PR_CheckToken ("&"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -3274,25 +3274,32 @@ static char *QCC_PR_PopenMacro(const char *macroname, const char *cmd, char *ret
|
||||||
}
|
}
|
||||||
retbufsize-=3; // '""\0'
|
retbufsize-=3; // '""\0'
|
||||||
*retbuf++ = '\"';
|
*retbuf++ = '\"';
|
||||||
len = fread(temp, 1, sizeof(temp), f);
|
for (;;)
|
||||||
if (len < 0)
|
|
||||||
len = 0;
|
|
||||||
else while (len --> 0 && *t && retbufsize > 1)
|
|
||||||
{
|
{
|
||||||
if (*t == '\"') *retbuf = '\"';
|
len = fread(temp, 1, sizeof(temp), f);
|
||||||
else if (*t == '\n') *retbuf = 'n';
|
if (len <= 0)
|
||||||
else if (*t == '\r') *retbuf = 'r';
|
break;
|
||||||
else if (*t == '#') *retbuf = '#'; //so we don't get preqcc-style expansion in strings.
|
else for (t=temp; len --> 0 && *t && retbufsize > 1; t++)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
*retbuf++ = *t++;
|
if (*t == '\"') retbuf[1] = '\"';
|
||||||
retbufsize--;
|
else if (*t == '\n') retbuf[1] = 'n';
|
||||||
continue;
|
else if (*t == '\r') retbuf[1] = 'r';
|
||||||
|
else if (*t == '#') retbuf[1] = '#'; //so we don't get preqcc-style expansion in strings.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*retbuf++ = *t;
|
||||||
|
retbufsize--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retbuf[0] = '\\';
|
||||||
|
retbuf+=2;
|
||||||
|
retbufsize-=2;
|
||||||
}
|
}
|
||||||
retbuf[0] = '\n';
|
|
||||||
retbuf+=2;
|
|
||||||
retbufsize-=2;
|
|
||||||
}
|
}
|
||||||
|
if (retbuf[-1] == 'n' && retbuf[-2] == '\\')
|
||||||
|
retbuf -= 2;
|
||||||
|
if (retbuf[-1] == 'r' && retbuf[-2] == '\\')
|
||||||
|
retbuf -= 2;
|
||||||
*retbuf++ = '\"';
|
*retbuf++ = '\"';
|
||||||
*retbuf++ = 0;
|
*retbuf++ = 0;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
Loading…
Reference in a new issue