1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Predefined type strings for inlined std function parameters.

This commit is contained in:
acqn 2021-04-05 16:40:32 +08:00 committed by Oliver Schmidt
parent 9cea9ce5e2
commit f901adba22
3 changed files with 27 additions and 11 deletions

View File

@ -72,6 +72,12 @@ const Type type_size_t[] = { TYPE(T_SIZE_T), TYPE(T_END) };
const Type type_float[] = { TYPE(T_FLOAT), TYPE(T_END) };
const Type type_double[] = { TYPE(T_DOUBLE), TYPE(T_END) };
/* More predefined type strings */
const Type type_char_p[] = { TYPE(T_PTR), TYPE(T_CHAR), TYPE(T_END) };
const Type type_c_char_p[] = { TYPE(T_PTR), TYPE(T_C_CHAR), TYPE(T_END) };
const Type type_void_p[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
const Type type_c_void_p[] = { TYPE(T_PTR), TYPE(T_C_VOID), TYPE(T_END) };
/*****************************************************************************/

View File

@ -146,6 +146,10 @@ enum {
T_PTR = T_TYPE_PTR | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE,
T_FUNC = T_TYPE_FUNC | T_CLASS_FUNC | T_SIGN_NONE | T_SIZE_NONE,
/* More types for convenience */
T_C_CHAR = T_CHAR | T_QUAL_CONST,
T_C_VOID = T_VOID | T_QUAL_CONST,
/* Aliases */
T_SIZE_T = T_UINT,
};
@ -211,6 +215,12 @@ extern const Type type_size_t[];
extern const Type type_float[];
extern const Type type_double[];
/* More predefined type strings */
extern const Type type_char_p[];
extern const Type type_c_char_p[];
extern const Type type_void_p[];
extern const Type type_c_void_p[];
/* Forward for the SymEntry struct */
struct SymEntry;

View File

@ -212,9 +212,9 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
/* Handle the memcpy function */
{
/* Argument types: (void*, const void*, size_t) */
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_VOID|T_QUAL_CONST), TYPE(T_END) };
static const Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) };
static const Type* Arg1Type = type_void_p;
static const Type* Arg2Type = type_c_void_p;
static const Type* Arg3Type = type_size_t;
ArgDesc Arg1, Arg2, Arg3;
unsigned ParamSize = 0;
@ -556,9 +556,9 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
/* Handle the memset function */
{
/* Argument types: (void*, int, size_t) */
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) };
static const Type Arg2Type[] = { TYPE(T_INT), TYPE(T_END) };
static const Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) };
static const Type* Arg1Type = type_void_p;
static const Type* Arg2Type = type_int;
static const Type* Arg3Type = type_size_t;
ArgDesc Arg1, Arg2, Arg3;
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 */
{
/* Argument types: (const char*, const char*) */
static const Type Arg1Type[] = { 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) };
static const Type* Arg1Type = type_c_char_p;
static const Type* Arg2Type = type_c_char_p;
ArgDesc Arg1, Arg2;
unsigned ParamSize = 0;
@ -983,8 +983,8 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
/* Handle the strcpy function */
{
/* Argument types: (char*, const char*) */
static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR), TYPE(T_END) };
static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
static const Type* Arg1Type = type_char_p;
static const Type* Arg2Type = type_c_char_p;
ArgDesc Arg1, Arg2;
unsigned ParamSize = 0;
@ -1180,7 +1180,7 @@ ExitPoint:
static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
/* Handle the strlen function */
{
static const Type ArgType[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) };
static const Type* ArgType = type_c_char_p;
ExprDesc Arg;
int IsArray;
int IsPtr;