[svn:parrot] r39776 - trunk/compilers/imcc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Thu Jun 25 20:08:17 UTC 2009


Author: NotFound
Date: Thu Jun 25 20:08:16 2009
New Revision: 39776
URL: https://trac.parrot.org/parrot/changeset/39776

Log:
[imcc] replace str_dup with mem_sys_strdup in lexer and parser

Modified:
   trunk/compilers/imcc/imcc.l
   trunk/compilers/imcc/imcc.y
   trunk/compilers/imcc/imclexer.c
   trunk/compilers/imcc/imcparser.c
   trunk/compilers/imcc/imcparser.h

Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l	Thu Jun 25 19:55:05 2009	(r39775)
+++ trunk/compilers/imcc/imcc.l	Thu Jun 25 20:08:16 2009	(r39776)
@@ -96,7 +96,7 @@
 
 #define DUP_AND_RET(valp, token)             \
   do {                                       \
-      if (valp) (valp)->s = str_dup(yytext); \
+      if (valp) (valp)->s = mem_sys_strdup(yytext); \
       return (token);                        \
   } while (0)
 
@@ -104,7 +104,7 @@
   do {                                       \
       if (valp) {                            \
           mem_sys_free((valp)->s);           \
-          (valp)->s = str_dup(yytext);       \
+          (valp)->s = mem_sys_strdup(yytext);       \
           return (token);                    \
       }                                      \
   } while (0)
@@ -171,7 +171,7 @@
         }
 
 <heredoc1>.*{EOL} {
-            IMCC_INFO(interp)->frames->heredoc_rest = str_dup(yytext);
+            IMCC_INFO(interp)->frames->heredoc_rest = mem_sys_strdup(yytext);
             BEGIN(heredoc2);
     }
 
@@ -231,8 +231,8 @@
         yy_pop_state(yyscanner);
         yy_push_state(cmt3, yyscanner);
 
-        IMCC_INFO(interp)->frames->s.file = str_dup(yytext);
-        IMCC_INFO(interp)->cur_unit->file = str_dup(yytext);
+        IMCC_INFO(interp)->frames->s.file = mem_sys_strdup(yytext);
+        IMCC_INFO(interp)->cur_unit->file = mem_sys_strdup(yytext);
 
         return FILECOMMENT;
     }
@@ -459,7 +459,7 @@
         if (c != STRINGC)
             return c;
 
-        /* STRINGCs have a str_dup()ed valp->s */
+        /* STRINGCs have a mem_sys_strdup()ed valp->s */
         mem_sys_free(valp->s);
         YYCHOP();
         include_file(interp, yytext + 1, yyscanner);
@@ -516,7 +516,7 @@
         YYCHOP();
 
         if (valp)
-            valp->s = str_dup(yytext);
+            valp->s = mem_sys_strdup(yytext);
 
         return LABEL;
     }
@@ -539,7 +539,7 @@
 <*>{OCT}              DUP_AND_RET(valp, INTC);
 
 <*>{BIGINT} {
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
 
         /* trailing 'L' */
         valp->s[strlen(valp->s) - 1] = '\0';
@@ -549,7 +549,7 @@
     }
 
 <*>{STRINGCONSTANT} {
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
 
         /* RT #42382 delete quotes, -> emit, pbc */
         return STRINGC;
@@ -562,7 +562,7 @@
            off newline and quote. */
         if (IMCC_INFO(interp)->frames->heredoc_rest)
             IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR, "nested heredoc not supported");
-        IMCC_INFO(interp)->heredoc_end = str_dup(yytext + 3);
+        IMCC_INFO(interp)->heredoc_end = mem_sys_strdup(yytext + 3);
         IMCC_INFO(interp)->heredoc_end[strlen(IMCC_INFO(interp)->heredoc_end) - 1] = 0;
 
         if (!strlen(IMCC_INFO(interp)->heredoc_end))
@@ -585,7 +585,7 @@
 
 <*>{UNICODE} {
         /* charset:"..." */
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
 
         /* this is actually not unicode but a string with a charset */
         return USTRINGC;
@@ -634,7 +634,7 @@
             "'%s' is only a valid register name in PASM mode", yytext);
 
         if (valp)
-            valp->s = str_dup(yytext);
+            valp->s = mem_sys_strdup(yytext);
 
         return REG;
     }
@@ -663,7 +663,7 @@
             }
         }
 
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
         return (!pesky_global__is_def && is_op(interp, valp->s) ? PARROT_OP : IDENTIFIER);
     }
 
@@ -788,7 +788,7 @@
     if (IMCC_INFO(interp)->frames) {
         tmp->s.pasm_file = IMCC_INFO(interp)->frames->s.pasm_file;
         if (IMCC_INFO(interp)->frames->s.file)
-            tmp->s.file = str_dup(IMCC_INFO(interp)->frames->s.file);
+            tmp->s.file = mem_sys_strdup(IMCC_INFO(interp)->frames->s.file);
     }
 
     tmp->s.interp = interp;
@@ -854,7 +854,7 @@
         if (*p == '\0')
             break;
 
-        /* free any str_dup()ed strings */
+        /* free any mem_sys_strdup()ed strings */
         if (yytext)
             mem_sys_free(valp->s);
     } while (*p != '\0');
@@ -912,7 +912,7 @@
 {
     YYSTYPE  val;
     size_t   len      = 0;
-    char    *current  = str_dup("");
+    char    *current  = mem_sys_strdup("");
     yyguts_t *yyg     = (yyguts_t *)yyscanner;
     int      c        = yylex_skip(&val, interp, " \n", yyscanner);
 
@@ -934,7 +934,7 @@
                             MAX_PARAM, macro_name);
 
             params->name[params->num_param++] = current;
-            current                           = str_dup("");
+            current                           = mem_sys_strdup("");
             len                               = 0;
 
             if (val.s)
@@ -1109,7 +1109,7 @@
     else
         memset(&m->params, 0, sizeof (params_t));
 
-    m->expansion = str_dup(expansion);
+    m->expansion = mem_sys_strdup(expansion);
     m->line      = start_line;
 }
 
@@ -1153,7 +1153,7 @@
         if (frame->s.file)
             mem_sys_free(frame->s.file);
 
-        frame->s.file            = str_dup(name);
+        frame->s.file            = mem_sys_strdup(name);
 
         /* whitespace can be safely ignored */
         do {
@@ -1182,7 +1182,7 @@
         BEGIN(start_cond);
 
         if (frame->expansion.num_param == 0 && m->params.num_param == 1) {
-            frame->expansion.name[0] = str_dup("");
+            frame->expansion.name[0] = mem_sys_strdup("");
             frame->expansion.num_param = 1;
         }
 
@@ -1201,7 +1201,7 @@
                 const char * const s = find_macro_param(interp, current + 1);
 
                 if (s) {
-                    frame->expansion.name[i] = str_dup(s);
+                    frame->expansion.name[i] = mem_sys_strdup(s);
                     mem_sys_free(current);
                 }
 
@@ -1244,7 +1244,7 @@
         IMCC_fataly(interp, EXCEPTION_EXTERNAL_ERROR, strerror(errno));
 
     mem_sys_free(s);
-    frame->s.file            = str_dup(file_name);
+    frame->s.file            = mem_sys_strdup(file_name);
     frame->s.handle          = file;
     ext                      = strrchr(file_name, '.');
 
@@ -1420,13 +1420,13 @@
 
     /* in case .line is used outside a .sub, then this
      * can't be done; hence the check.
-     * The str_dup() is done, as the original #line implementation
+     * The mem_sys_strdup() is done, as the original #line implementation
      * duplicated the string twice as well; one for the
      * frames->s.file and one for cur_unit->file.
-     * During the parse, the STRINGC is already str_dup()ed once.
+     * During the parse, the STRINGC is already mem_sys_strdup()ed once.
      */
     if (IMCC_INFO(interp)->cur_unit)
-        IMCC_INFO(interp)->cur_unit->file = str_dup(filename);
+        IMCC_INFO(interp)->cur_unit->file = mem_sys_strdup(filename);
 }
 
 /* Functions to set and get yyin, as we can't decorate it for export

Modified: trunk/compilers/imcc/imcc.y
==============================================================================
--- trunk/compilers/imcc/imcc.y	Thu Jun 25 19:55:05 2009	(r39775)
+++ trunk/compilers/imcc/imcc.y	Thu Jun 25 20:08:16 2009	(r39776)
@@ -437,11 +437,11 @@
     r[0] = left;
     if (ascii) {
         /* strip delimiters */
-        name                   = str_dup(constant + 1);
+        name                   = mem_sys_strdup(constant + 1);
         name[strlen(name) - 1] = 0;
     }
     else {
-        name = str_dup(constant);
+        name = mem_sys_strdup(constant);
     }
 
     switch (type_enum) {
@@ -487,7 +487,7 @@
     SymReg *r[3];
     char   *const_name;
     const int ascii       = (*constant == '\'' || *constant == '"');
-    char   *unquoted_name = str_dup(name + 1);
+    char   *unquoted_name = mem_sys_strdup(name + 1);
     size_t  name_length   = strlen(unquoted_name) - 1;
 
     unquoted_name[name_length] = 0;
@@ -504,11 +504,11 @@
     r[0] = left;
     if (ascii) {
         /* strip delimiters */
-        const_name                         = str_dup(constant + 1);
+        const_name                         = mem_sys_strdup(constant + 1);
         const_name[strlen(const_name) - 1] = 0;
     }
     else {
-        const_name = str_dup(constant);
+        const_name = mem_sys_strdup(constant);
     }
 
     if ((strncmp(unquoted_name, "Sub",       name_length) == 0)
@@ -759,7 +759,7 @@
     ASSERT_ARGS(mk_sub_address_fromc)
     /* name is a quoted sub name */
     SymReg *r;
-    char *name_copy                  = str_dup(name + 1);
+    char *name_copy                  = mem_sys_strdup(name + 1);
     name_copy[strlen(name_copy) - 1] = 0;
 
     r = mk_sub_address(interp, name_copy);
@@ -1348,7 +1348,7 @@
         {
           IMCC_INFO(interp)->cur_call->pcc_sub->pragma = $5;
           if (!IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->subid) {
-            IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->subid = str_dup(
+            IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->subid = mem_sys_strdup(
             IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->name);
           }
         }
@@ -1968,7 +1968,7 @@
 classname:
      IDENTIFIER
          {
-           /* there'd normally be a str_dup() here, but the lexer already
+           /* there'd normally be a mem_sys_strdup() here, but the lexer already
             * copied the string, so it's safe to use directly */
            if ((IMCC_INFO(interp)->cur_pmc_type = pmc_type(interp,
                Parrot_str_new(interp, $1, 0))) <= 0) {

Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c	Thu Jun 25 19:55:05 2009	(r39775)
+++ trunk/compilers/imcc/imclexer.c	Thu Jun 25 20:08:16 2009	(r39776)
@@ -2464,7 +2464,7 @@
 
 #define DUP_AND_RET(valp, token)             \
   do {                                       \
-      if (valp) (valp)->s = str_dup(yytext); \
+      if (valp) (valp)->s = mem_sys_strdup(yytext); \
       return (token);                        \
   } while (0)
 
@@ -2472,7 +2472,7 @@
   do {                                       \
       if (valp) {                            \
           mem_sys_free((valp)->s);           \
-          (valp)->s = str_dup(yytext);       \
+          (valp)->s = mem_sys_strdup(yytext);       \
           return (token);                    \
       }                                      \
   } while (0)
@@ -2836,7 +2836,7 @@
 YY_RULE_SETUP
 #line 173 "compilers/imcc/imcc.l"
 {
-            IMCC_INFO(interp)->frames->heredoc_rest = str_dup(yytext);
+            IMCC_INFO(interp)->frames->heredoc_rest = mem_sys_strdup(yytext);
             BEGIN(heredoc2);
     }
 	YY_BREAK
@@ -2907,8 +2907,8 @@
         yy_pop_state(yyscanner);
         yy_push_state(cmt3, yyscanner);
 
-        IMCC_INFO(interp)->frames->s.file = str_dup(yytext);
-        IMCC_INFO(interp)->cur_unit->file = str_dup(yytext);
+        IMCC_INFO(interp)->frames->s.file = mem_sys_strdup(yytext);
+        IMCC_INFO(interp)->cur_unit->file = mem_sys_strdup(yytext);
 
         return FILECOMMENT;
     }
@@ -3543,7 +3543,7 @@
         if (c != STRINGC)
             return c;
 
-        /* STRINGCs have a str_dup()ed valp->s */
+        /* STRINGCs have a mem_sys_strdup()ed valp->s */
         mem_sys_free(valp->s);
         YYCHOP();
         include_file(interp, yytext + 1, yyscanner);
@@ -3612,7 +3612,7 @@
         YYCHOP();
 
         if (valp)
-            valp->s = str_dup(yytext);
+            valp->s = mem_sys_strdup(yytext);
 
         return LABEL;
     }
@@ -3658,7 +3658,7 @@
 YY_RULE_SETUP
 #line 541 "compilers/imcc/imcc.l"
 {
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
 
         /* trailing 'L' */
         valp->s[strlen(valp->s) - 1] = '\0';
@@ -3671,7 +3671,7 @@
 YY_RULE_SETUP
 #line 551 "compilers/imcc/imcc.l"
 {
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
 
         /* RT #42382 delete quotes, -> emit, pbc */
         return STRINGC;
@@ -3687,7 +3687,7 @@
            off newline and quote. */
         if (IMCC_INFO(interp)->frames->heredoc_rest)
             IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR, "nested heredoc not supported");
-        IMCC_INFO(interp)->heredoc_end = str_dup(yytext + 3);
+        IMCC_INFO(interp)->heredoc_end = mem_sys_strdup(yytext + 3);
         IMCC_INFO(interp)->heredoc_end[strlen(IMCC_INFO(interp)->heredoc_end) - 1] = 0;
 
         if (!strlen(IMCC_INFO(interp)->heredoc_end))
@@ -3713,7 +3713,7 @@
 #line 586 "compilers/imcc/imcc.l"
 {
         /* charset:"..." */
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
 
         /* this is actually not unicode but a string with a charset */
         return USTRINGC;
@@ -3780,7 +3780,7 @@
             "'%s' is only a valid register name in PASM mode", yytext);
 
         if (valp)
-            valp->s = str_dup(yytext);
+            valp->s = mem_sys_strdup(yytext);
 
         return REG;
     }
@@ -3812,7 +3812,7 @@
             }
         }
 
-        valp->s = str_dup(yytext);
+        valp->s = mem_sys_strdup(yytext);
         return (!pesky_global__is_def && is_op(interp, valp->s) ? PARROT_OP : IDENTIFIER);
     }
 	YY_BREAK
@@ -5201,7 +5201,7 @@
     if (IMCC_INFO(interp)->frames) {
         tmp->s.pasm_file = IMCC_INFO(interp)->frames->s.pasm_file;
         if (IMCC_INFO(interp)->frames->s.file)
-            tmp->s.file = str_dup(IMCC_INFO(interp)->frames->s.file);
+            tmp->s.file = mem_sys_strdup(IMCC_INFO(interp)->frames->s.file);
     }
 
     tmp->s.interp = interp;
@@ -5267,7 +5267,7 @@
         if (*p == '\0')
             break;
 
-        /* free any str_dup()ed strings */
+        /* free any mem_sys_strdup()ed strings */
         if (yytext)
             mem_sys_free(valp->s);
     } while (*p != '\0');
@@ -5325,7 +5325,7 @@
 {
     YYSTYPE  val;
     size_t   len      = 0;
-    char    *current  = str_dup("");
+    char    *current  = mem_sys_strdup("");
     yyguts_t *yyg     = (yyguts_t *)yyscanner;
     int      c        = yylex_skip(&val, interp, " \n", yyscanner);
 
@@ -5347,7 +5347,7 @@
                             MAX_PARAM, macro_name);
 
             params->name[params->num_param++] = current;
-            current                           = str_dup("");
+            current                           = mem_sys_strdup("");
             len                               = 0;
 
             if (val.s)
@@ -5522,7 +5522,7 @@
     else
         memset(&m->params, 0, sizeof (params_t));
 
-    m->expansion = str_dup(expansion);
+    m->expansion = mem_sys_strdup(expansion);
     m->line      = start_line;
 }
 
@@ -5566,7 +5566,7 @@
         if (frame->s.file)
             mem_sys_free(frame->s.file);
 
-        frame->s.file            = str_dup(name);
+        frame->s.file            = mem_sys_strdup(name);
 
         /* whitespace can be safely ignored */
         do {
@@ -5595,7 +5595,7 @@
         BEGIN(start_cond);
 
         if (frame->expansion.num_param == 0 && m->params.num_param == 1) {
-            frame->expansion.name[0] = str_dup("");
+            frame->expansion.name[0] = mem_sys_strdup("");
             frame->expansion.num_param = 1;
         }
 
@@ -5614,7 +5614,7 @@
                 const char * const s = find_macro_param(interp, current + 1);
 
                 if (s) {
-                    frame->expansion.name[i] = str_dup(s);
+                    frame->expansion.name[i] = mem_sys_strdup(s);
                     mem_sys_free(current);
                 }
 
@@ -5657,7 +5657,7 @@
         IMCC_fataly(interp, EXCEPTION_EXTERNAL_ERROR, strerror(errno));
 
     mem_sys_free(s);
-    frame->s.file            = str_dup(file_name);
+    frame->s.file            = mem_sys_strdup(file_name);
     frame->s.handle          = file;
     ext                      = strrchr(file_name, '.');
 
@@ -5831,13 +5831,13 @@
 
     /* in case .line is used outside a .sub, then this
      * can't be done; hence the check.
-     * The str_dup() is done, as the original #line implementation
+     * The mem_sys_strdup() is done, as the original #line implementation
      * duplicated the string twice as well; one for the
      * frames->s.file and one for cur_unit->file.
-     * During the parse, the STRINGC is already str_dup()ed once.
+     * During the parse, the STRINGC is already mem_sys_strdup()ed once.
      */
     if (IMCC_INFO(interp)->cur_unit)
-        IMCC_INFO(interp)->cur_unit->file = str_dup(filename);
+        IMCC_INFO(interp)->cur_unit->file = mem_sys_strdup(filename);
 }
 
 /* Functions to set and get yyin, as we can't decorate it for export

Modified: trunk/compilers/imcc/imcparser.c
==============================================================================
--- trunk/compilers/imcc/imcparser.c	Thu Jun 25 19:55:05 2009	(r39775)
+++ trunk/compilers/imcc/imcparser.c	Thu Jun 25 20:08:16 2009	(r39776)
@@ -761,11 +761,11 @@
     r[0] = left;
     if (ascii) {
         /* strip delimiters */
-        name                   = str_dup(constant + 1);
+        name                   = mem_sys_strdup(constant + 1);
         name[strlen(name) - 1] = 0;
     }
     else {
-        name = str_dup(constant);
+        name = mem_sys_strdup(constant);
     }
 
     switch (type_enum) {
@@ -811,7 +811,7 @@
     SymReg *r[3];
     char   *const_name;
     const int ascii       = (*constant == '\'' || *constant == '"');
-    char   *unquoted_name = str_dup(name + 1);
+    char   *unquoted_name = mem_sys_strdup(name + 1);
     size_t  name_length   = strlen(unquoted_name) - 1;
 
     unquoted_name[name_length] = 0;
@@ -828,11 +828,11 @@
     r[0] = left;
     if (ascii) {
         /* strip delimiters */
-        const_name                         = str_dup(constant + 1);
+        const_name                         = mem_sys_strdup(constant + 1);
         const_name[strlen(const_name) - 1] = 0;
     }
     else {
-        const_name = str_dup(constant);
+        const_name = mem_sys_strdup(constant);
     }
 
     if ((strncmp(unquoted_name, "Sub",       name_length) == 0)
@@ -1083,7 +1083,7 @@
     ASSERT_ARGS(mk_sub_address_fromc)
     /* name is a quoted sub name */
     SymReg *r;
-    char *name_copy                  = str_dup(name + 1);
+    char *name_copy                  = mem_sys_strdup(name + 1);
     name_copy[strlen(name_copy) - 1] = 0;
 
     r = mk_sub_address(interp, name_copy);
@@ -1384,7 +1384,7 @@
     SymReg * sr;
     Instruction *i;
 }
-/* Line 193 of yacc.c.  */
+/* Line 187 of yacc.c.  */
 #line 1378 "compilers/imcc/imcparser.c"
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -3504,7 +3504,7 @@
     {
           IMCC_INFO(interp)->cur_call->pcc_sub->pragma = (yyvsp[(5) - (6)].t);
           if (!IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->subid) {
-            IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->subid = str_dup(
+            IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->subid = mem_sys_strdup(
             IMCC_INFO(interp)->cur_unit->instructions->symregs[0]->name);
           }
         }
@@ -4392,7 +4392,7 @@
   case 200:
 #line 1970 "compilers/imcc/imcc.y"
     {
-           /* there'd normally be a str_dup() here, but the lexer already
+           /* there'd normally be a mem_sys_strdup() here, but the lexer already
             * copied the string, so it's safe to use directly */
            if ((IMCC_INFO(interp)->cur_pmc_type = pmc_type(interp,
                Parrot_str_new(interp, (yyvsp[(1) - (1)].s), 0))) <= 0) {

Modified: trunk/compilers/imcc/imcparser.h
==============================================================================
--- trunk/compilers/imcc/imcparser.h	Thu Jun 25 19:55:05 2009	(r39775)
+++ trunk/compilers/imcc/imcparser.h	Thu Jun 25 20:08:16 2009	(r39776)
@@ -303,7 +303,7 @@
     SymReg * sr;
     Instruction *i;
 }
-/* Line 1529 of yacc.c.  */
+/* Line 1489 of yacc.c.  */
 #line 297 "compilers/imcc/imcparser.h"
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */


More information about the parrot-commits mailing list