-static void StdFunc_strlen (struct expent*);
+static void StdFunc_strlen (ExprDesc*);
/* Table with all known functions and their handlers. Must be sorted
* alphabetically!
*/
-static struct FuncDesc {
- const char* Name;
- void (*Handler) (struct expent*);
+static struct StdFuncDesc {
+ const char* Name;
+ void (*Handler) (ExprDesc*);
} StdFuncs [] = {
{ "strlen", StdFunc_strlen },
static int CmpFunc (const void* Key, const void* Elem)
/* Compare function for bsearch */
{
- return strcmp ((const char*) Key, ((const struct FuncDesc*) Elem)->Name);
+ return strcmp ((const char*) Key, ((const struct StdFuncDesc*) Elem)->Name);
}
-static struct FuncDesc* FindFunc (const char* Name)
+static struct StdFuncDesc* FindFunc (const char* Name)
/* Find a function with the given name. Return a pointer to the descriptor if
* found, return NULL otherwise.
*/
/*****************************************************************************/
-/* Handle known functions */
+/* Handle known functions */
/*****************************************************************************/
-static void StdFunc_strlen (struct expent* lval)
+static void StdFunc_strlen (ExprDesc* lval)
/* Handle the strlen function */
{
- struct expent pval;
+ ExprDesc pval;
+ static type ArgType[] = { T_PTR, T_SCHAR, T_END };
+
/* Fetch the parameter */
int k = hie1 (&pval);
/* Check if the parameter is a const address */
unsigned flags = 0;
- unsigned pflags = pval.e_flags & ~E_MCTYPE;
+ unsigned pflags = pval.Flags & ~E_MCTYPE;
if (pflags == E_MCONST) {
/* Constant numeric address */
flags |= CF_CONST | CF_ABSOLUTE;
- } else if (k == 0 && ((pflags & E_MGLOBAL) != 0 || pval.e_flags == E_MEOFFS)) {
+ } else if (k == 0 && ((pflags & E_MGLOBAL) != 0 || pval.Flags == E_MEOFFS)) {
/* Global array with or without offset */
flags |= CF_CONST;
- if (pval.e_flags & E_TGLAB) {
+ if (pval.Flags & E_TGLAB) {
/* External linkage */
flags |= CF_EXTERNAL;
} else {
exprhs (CF_NONE, k, &pval);
}
+ /* Setup the argument type string */
+ ArgType[1] = GetDefaultChar () | T_QUAL_CONST;
+
/* Convert the parameter type to the type needed, check for mismatches */
- assignadjust (SignedChars? type_pschar : type_puchar, &pval);
+ assignadjust (ArgType, &pval);
/* Generate the strlen code */
- g_strlen (flags, pval.e_name, pval.e_const);
+ g_strlen (flags, pval.Name, pval.ConstVal);
/* We expect the closing brace */
ConsumeRParen ();
-void HandleStdFunc (struct expent* lval)
+void HandleStdFunc (ExprDesc* lval)
/* Generate code for a known standard function. */
{
/* Get a pointer to the table entry */
- struct FuncDesc* F = FindFunc ((const char*) lval->e_name);
+ struct StdFuncDesc* F = FindFunc ((const char*) lval->Name);
CHECK (F != 0);
/* Call the handler function */