]> git.sur5r.net Git - cc65/blobdiff - src/cc65/stdfunc.c
Removed unused modules
[cc65] / src / cc65 / stdfunc.c
index 40d74f692695bb5c49d81411287e0681a35bc27a..7877f6c9da95a9f2a5355d45b2fc39cd33a6f5ab 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -48,6 +48,7 @@
 #include "litpool.h"
 #include "scanner.h"
 #include "stdfunc.h"
+#include "stdnames.h"
 #include "typeconv.h"
 
 
@@ -116,17 +117,17 @@ static unsigned ParseArg (type* Type, ExprDesc* Arg)
     unsigned Flags = CF_FORCECHAR;
 
     /* Read the expression we're going to pass to the function */
-    int k = hie1 (InitExprDesc (Arg));
+    hie1 (InitExprDesc (Arg));
 
     /* Convert this expression to the expected type */
-    k = TypeConversion (Arg, k, Type);
+    TypeConversion (Arg, Type);
 
     /* If the value is not a constant, load it into the primary */
-    if (k != 0 || Arg->Flags != E_MCONST) {
+    if (ED_IsLVal (Arg) || Arg->Flags != E_MCONST) {
 
         /* Load into the primary */
-        exprhs (CF_NONE, k, Arg);
-        k = 0;
+        ExprLoad (CF_NONE, Arg);
+        ED_MakeRVal (Arg);
 
     } else {
 
@@ -161,12 +162,6 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)),
     int      MemSet    = 1;             /* Use real memset if true */
     unsigned ParamSize = 0;
 
-
-    /* Check the prototype of the function against what we know about it, so
-     * we can detect errors.
-     */
-    /* ### */
-
     /* Argument #1 */
     Flags = ParseArg (Arg1Type, &Arg);
     g_push (Flags, Arg.ConstVal);
@@ -194,11 +189,14 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)),
      */
     Flags = ParseArg (Arg3Type, &Arg);
     if (Flags & CF_CONST) {
-        exprhs (CF_FORCECHAR, 0, &Arg);
+       if (Arg.ConstVal == 0) {
+           Warning ("Call to memset has no effect");
+       }
+        ExprLoad (CF_FORCECHAR, &Arg);
     }
 
     /* Emit the actual function call */
-    g_call (CF_NONE, MemSet? "memset" : "_bzero", ParamSize);
+    g_call (CF_NONE, MemSet? Func_memset : Func__bzero, ParamSize);
 
     /* We expect the closing brace */
     ConsumeRParen ();
@@ -211,7 +209,6 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)),
 /* Handle the strlen function */
 {
     static type   ParamType[] = { T_PTR, T_SCHAR, T_END };
-    int           k;
     ExprDesc      Param;
     unsigned      CodeFlags;
     unsigned long ParamName;
@@ -220,7 +217,8 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)),
     ParamType[1] = GetDefaultChar () | T_QUAL_CONST;
 
     /* Fetch the parameter and convert it to the type needed */
-    k = TypeConversion (&Param, hie1 (InitExprDesc (&Param)), ParamType);
+    hie1 (InitExprDesc (&Param));
+    TypeConversion (&Param, ParamType);
 
     /* Check if the parameter is a constant array of some type, or a numeric
      * address cast to a pointer.
@@ -262,9 +260,9 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)),
                 if (!WriteableStrings) {
                     /* String literals are const */
                     ExprDesc Length;
-                    MakeConstIntExpr (&Length, strlen (GetLiteral (Param.ConstVal)));
+                    ED_MakeConstInt (&Length, strlen (GetLiteral (Param.ConstVal)));
                     ResetLiteralPoolOffs (Param.ConstVal);
-                    exprhs (CF_NONE, 0, &Length);
+                    ExprLoad (CF_NONE, &Length);
                     goto ExitPoint;
                 } else {
                     CodeFlags |= CF_CONST | CF_STATIC;
@@ -279,7 +277,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)),
     } else {
 
        /* Not an array with a constant address. Load parameter into primary */
-       exprhs (CF_NONE, k, &Param);
+       ExprLoad (CF_NONE, &Param);
 
     }