mirror of
https://github.com/cc65/cc65.git
synced 2025-08-16 12:27:49 +00:00
Made the code more constness-correct with 'Type' usage for inlined std functions.
This commit is contained in:
@@ -141,7 +141,7 @@ static long ArrayElementCount (const ArgDesc* Arg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ParseArg (ArgDesc* Arg, Type* Type, ExprDesc* Expr)
|
static void ParseArg (ArgDesc* Arg, const Type* Type, ExprDesc* Expr)
|
||||||
/* Parse one argument but do not push it onto the stack. Make all fields in
|
/* Parse one argument but do not push it onto the stack. Make all fields in
|
||||||
** Arg valid.
|
** Arg valid.
|
||||||
*/
|
*/
|
||||||
@@ -212,9 +212,9 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
|||||||
/* Handle the memcpy function */
|
/* Handle the memcpy function */
|
||||||
{
|
{
|
||||||
/* Argument types: (void*, const void*, size_t) */
|
/* Argument types: (void*, const void*, size_t) */
|
||||||
static Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
|
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
|
||||||
static Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_VOID|T_QUAL_CONST), TYPE(T_END) };
|
static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_VOID|T_QUAL_CONST), TYPE(T_END) };
|
||||||
static Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) };
|
static const Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) };
|
||||||
|
|
||||||
ArgDesc Arg1, Arg2, Arg3;
|
ArgDesc Arg1, Arg2, Arg3;
|
||||||
unsigned ParamSize = 0;
|
unsigned ParamSize = 0;
|
||||||
@@ -556,9 +556,9 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
|||||||
/* Handle the memset function */
|
/* Handle the memset function */
|
||||||
{
|
{
|
||||||
/* Argument types: (void*, int, size_t) */
|
/* Argument types: (void*, int, size_t) */
|
||||||
static Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
|
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
|
||||||
static Type Arg2Type[] = { TYPE(T_INT), TYPE(T_END) };
|
static const Type Arg2Type[] = { TYPE(T_INT), TYPE(T_END) };
|
||||||
static Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) };
|
static const Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) };
|
||||||
|
|
||||||
ArgDesc Arg1, Arg2, Arg3;
|
ArgDesc Arg1, Arg2, Arg3;
|
||||||
int MemSet = 1; /* Use real memset if true */
|
int MemSet = 1; /* Use real memset if true */
|
||||||
@@ -782,8 +782,8 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
|||||||
/* Handle the strcmp function */
|
/* Handle the strcmp function */
|
||||||
{
|
{
|
||||||
/* Argument types: (const char*, const char*) */
|
/* Argument types: (const char*, const char*) */
|
||||||
static Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
||||||
static Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
||||||
|
|
||||||
ArgDesc Arg1, Arg2;
|
ArgDesc Arg1, Arg2;
|
||||||
unsigned ParamSize = 0;
|
unsigned ParamSize = 0;
|
||||||
@@ -792,10 +792,6 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
|||||||
int IsArray;
|
int IsArray;
|
||||||
int Offs;
|
int Offs;
|
||||||
|
|
||||||
/* Setup the argument type string */
|
|
||||||
Arg1Type[1].C = T_CHAR | T_QUAL_CONST;
|
|
||||||
Arg2Type[1].C = T_CHAR | T_QUAL_CONST;
|
|
||||||
|
|
||||||
/* Argument #1 */
|
/* Argument #1 */
|
||||||
ParseArg (&Arg1, Arg1Type, Expr);
|
ParseArg (&Arg1, Arg1Type, Expr);
|
||||||
g_push (Arg1.Flags, Arg1.Expr.IVal);
|
g_push (Arg1.Flags, Arg1.Expr.IVal);
|
||||||
@@ -987,18 +983,14 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
|||||||
/* Handle the strcpy function */
|
/* Handle the strcpy function */
|
||||||
{
|
{
|
||||||
/* Argument types: (char*, const char*) */
|
/* Argument types: (char*, const char*) */
|
||||||
static Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR), TYPE(T_END) };
|
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR), TYPE(T_END) };
|
||||||
static Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
||||||
|
|
||||||
ArgDesc Arg1, Arg2;
|
ArgDesc Arg1, Arg2;
|
||||||
unsigned ParamSize = 0;
|
unsigned ParamSize = 0;
|
||||||
long ECount;
|
long ECount;
|
||||||
unsigned L1;
|
unsigned L1;
|
||||||
|
|
||||||
/* Setup the argument type string */
|
|
||||||
Arg1Type[1].C = T_CHAR;
|
|
||||||
Arg2Type[1].C = T_CHAR | T_QUAL_CONST;
|
|
||||||
|
|
||||||
/* Argument #1 */
|
/* Argument #1 */
|
||||||
ParseArg (&Arg1, Arg1Type, Expr);
|
ParseArg (&Arg1, Arg1Type, Expr);
|
||||||
g_push (Arg1.Flags, Arg1.Expr.IVal);
|
g_push (Arg1.Flags, Arg1.Expr.IVal);
|
||||||
@@ -1188,7 +1180,7 @@ ExitPoint:
|
|||||||
static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||||
/* Handle the strlen function */
|
/* Handle the strlen function */
|
||||||
{
|
{
|
||||||
static Type ArgType[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
static const Type ArgType[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
|
||||||
ExprDesc Arg;
|
ExprDesc Arg;
|
||||||
int IsArray;
|
int IsArray;
|
||||||
int IsPtr;
|
int IsPtr;
|
||||||
@@ -1199,9 +1191,6 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
|||||||
ED_Init (&Arg);
|
ED_Init (&Arg);
|
||||||
Arg.Flags |= Expr->Flags & E_MASK_KEEP_SUBEXPR;
|
Arg.Flags |= Expr->Flags & E_MASK_KEEP_SUBEXPR;
|
||||||
|
|
||||||
/* Setup the argument type string */
|
|
||||||
ArgType[1].C = T_CHAR | T_QUAL_CONST;
|
|
||||||
|
|
||||||
/* Evaluate the parameter */
|
/* Evaluate the parameter */
|
||||||
hie1 (&Arg);
|
hie1 (&Arg);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user