&qc_sqrt, /* 13 */
&qc_floor /* 14 */
};
-static size_t qc_builtins_count = sizeof(qc_builtins) / sizeof(qc_builtins[0]);
static const char *arg0 = NULL;
}
prog->builtins = qc_builtins;
- prog->builtins_count = qc_builtins_count;
+ prog->builtins_count = GMQCC_ARRAY_COUNT(qc_builtins);
if (opts_info) {
printf("Program's system-checksum = 0x%04x\n", (unsigned int)prog->crc16);
{ "__TIME_STAMP__", &ftepp_predef_timestamp }
};
-static GMQCC_INLINE int ftepp_predef_index(const char *name) {
+static GMQCC_INLINE size_t ftepp_predef_index(const char *name) {
/* no hashtable here, we simply check for one to exist the naive way */
- int i;
- for(i = 0; i < (int)(sizeof(ftepp_predefs)/sizeof(*ftepp_predefs)); i++)
- if (!strcmp(ftepp_predefs[i].name, name))
+ size_t i;
+ for(i = 1; i < GMQCC_ARRAY_COUNT(ftepp_predefs) + 1; i++)
+ if (!strcmp(ftepp_predefs[i-1].name, name))
return i;
- return -1;
+ return 0;
}
bool ftepp_predef_exists(const char *name);
bool ftepp_predef_exists(const char *name) {
- return ftepp_predef_index(name) != -1;
+ return ftepp_predef_index(name) != 0;
}
/* singleton because we're allowed */
static GMQCC_INLINE char *(*ftepp_predef(const char *name))(lex_file *context) {
- int i = ftepp_predef_index(name);
- return (i != -1) ? ftepp_predefs[i].func : NULL;
+ size_t i = ftepp_predef_index(name);
+ return (i != 0) ? ftepp_predefs[i-1].func : NULL;
}
#define ftepp_tokval(f) ((f)->lex->tok.value)
"return",
"const"
};
-static size_t num_keywords_qc = sizeof(keywords_qc) / sizeof(keywords_qc[0]);
-
/* For fte/gmgqcc */
static const char *keywords_fg[] = {
"switch", "case", "default",
"__builtin_debug_printtype"
};
-static size_t num_keywords_fg = sizeof(keywords_fg) / sizeof(keywords_fg[0]);
/*
* Lexer code
*/
-
static char* *lex_filenames;
static void lexerror(lex_file *lex, const char *fmt, ...)
lex->tok.constval.t = TYPE_VECTOR;
} else {
size_t kw;
- for (kw = 0; kw < num_keywords_qc; ++kw) {
+ for (kw = 0; kw < GMQCC_ARRAY_COUNT(keywords_qc); ++kw) {
if (!strcmp(v, keywords_qc[kw]))
return (lex->tok.ttype = TOKEN_KEYWORD);
}
if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_QCC) {
- for (kw = 0; kw < num_keywords_fg; ++kw) {
+ for (kw = 0; kw < GMQCC_ARRAY_COUNT(keywords_fg); ++kw) {
if (!strcmp(v, keywords_fg[kw]))
return (lex->tok.ttype = TOKEN_KEYWORD);
}
{ ",", 2, opid1(','), ASSOC_LEFT, 0, 0, false}
};
-static const size_t c_operator_count = (sizeof(c_operators) / sizeof(c_operators[0]));
static const oper_info fte_operators[] = {
{ "(", 0, opid1('('), ASSOC_LEFT, 99, OP_PREFIX, false}, /* paren expression - non function call */
{ ",", 2, opid1(','), ASSOC_LEFT, 2, 0, false},
{ ":", 0, opid2(':','?'), ASSOC_RIGHT, 1, 0, false}
};
-static const size_t fte_operator_count = (sizeof(fte_operators) / sizeof(fte_operators[0]));
static const oper_info qcc_operators[] = {
{ "(", 0, opid1('('), ASSOC_LEFT, 99, OP_PREFIX, false}, /* paren expression - non function call */
{ ",", 2, opid1(','), ASSOC_LEFT, 2, 0, false},
};
-static const size_t qcc_operator_count = (sizeof(qcc_operators) / sizeof(qcc_operators[0]));
-
extern const oper_info *operators;
extern size_t operator_count;
-/*void lexerror(lex_file*, const char *fmt, ...);*/
#endif
else if (!strcmp(argv[0]+2, "NO_ERROR") ||
!strcmp(argv[0]+2, "NO_ERROR_ALL"))
{
- for (itr = 0; itr < sizeof(opts.werror)/sizeof(opts.werror[0]); ++itr)
+ for (itr = 0; itr < GMQCC_ARRAY_COUNT(opts.werror); ++itr)
opts.werror[itr] = 0;
break;
}
!strcmp(argv[0]+2, "ERROR_ALL"))
{
opts_backup_non_Werror_all();
- for (itr = 0; itr < sizeof(opts.werror)/sizeof(opts.werror[0]); ++itr)
+ for (itr = 0; itr < GMQCC_ARRAY_COUNT(opts.werror); ++itr)
opts.werror[itr] = 0xFFFFFFFFL;
opts_restore_non_Werror_all();
break;
}
else if (!strcmp(argv[0]+2, "NONE")) {
- for (itr = 0; itr < sizeof(opts.warn)/sizeof(opts.warn[0]); ++itr)
+ for (itr = 0; itr < GMQCC_ARRAY_COUNT(opts.warn); ++itr)
opts.warn[itr] = 0;
break;
}
else if (!strcmp(argv[0]+2, "ALL")) {
opts_backup_non_Wall();
- for (itr = 0; itr < sizeof(opts.warn)/sizeof(opts.warn[0]); ++itr)
+ for (itr = 0; itr < GMQCC_ARRAY_COUNT(opts.warn); ++itr)
opts.warn[itr] = 0xFFFFFFFFL;
opts_restore_non_Wall();
break;
/* the standard decides which set of operators to use */
if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
operators = c_operators;
- operator_count = c_operator_count;
+ operator_count = GMQCC_ARRAY_COUNT(c_operators);
} else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_FTEQCC) {
operators = fte_operators;
- operator_count = fte_operator_count;
+ operator_count = GMQCC_ARRAY_COUNT(fte_operators);
} else {
operators = qcc_operators;
- operator_count = qcc_operator_count;
+ operator_count = GMQCC_ARRAY_COUNT(qcc_operators);
}
if (operators == fte_operators) {