]> git.gag.com Git - fw/sdcc/commitdiff
Added new option --dumptree . This will dump the front end tree
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 27 Oct 2001 21:09:22 +0000 (21:09 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 27 Oct 2001 21:09:22 +0000 (21:09 +0000)
before lowering it to iCode.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1456 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglobl.h
src/SDCCmain.c

index a266357356a7fa49870287a1d9cebc4874311068..2cc429de7c11f1f68b4bfc367e218e7d74aa9eab 100644 (file)
@@ -53,6 +53,7 @@ ast *createIvalCharPtr (ast *, sym_link *, ast *);
 ast *optimizeRRCRLC (ast *);
 ast *optimizeGetHbit (ast *);
 ast *backPatchLabels (ast *, symbol *, symbol *);
+void PA(ast *t);
 int inInitMode = 0;
 memmap *GcurMemmap=NULL;  /* points to the memmap that's currently active */
 FILE *codeOutFile;
@@ -4177,7 +4178,8 @@ createFunction (symbol * name, ast * body)
   ex = newAst_VALUE (symbolVal (name));                /* create name       */
   ex = newNode (FUNCTION, ex, body);
   ex->values.args = FUNC_ARGS(name->type);
-
+  ex->decorated=1;
+  if (options.dump_tree) PA(ex);
   if (fatalError)
     {
       werror (E_FUNC_NO_CODE, name->name);
@@ -4276,6 +4278,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
        }
        if (tree->opval.op == BLOCK) {
                symbol *decls = tree->values.sym;
+               INDENT(indent+4,outfile);
                fprintf(outfile,"{\n");
                while (decls) {
                        INDENT(indent+4,outfile);
@@ -4286,6 +4289,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                        decls = decls->next;                    
                }
                ast_print(tree->right,outfile,indent+4);
+               INDENT(indent+4,outfile);
                fprintf(outfile,"}\n");
                return;
        }
@@ -4845,18 +4849,17 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                /* ifx Statement              */
                /*----------------------------*/
        case IFX:
-               ast_print(tree->left,outfile,indent);
-               INDENT(indent,outfile);
                fprintf(outfile,"IF (%p) \n",tree);
+               ast_print(tree->left,outfile,indent+4);
                if (tree->trueLabel) {
                        INDENT(indent,outfile);
-                       fprintf(outfile,"NE(==) 0 goto %s\n",tree->trueLabel->name);
+                       fprintf(outfile,"NE(!=) 0 goto %s\n",tree->trueLabel->name);
                }
                if (tree->falseLabel) {
                        INDENT(indent,outfile);
                        fprintf(outfile,"EQ(==) 0 goto %s\n",tree->falseLabel->name);
                }
-               ast_print(tree->right,outfile,indent);
+               ast_print(tree->right,outfile,indent+4);
                return ;
                /*------------------------------------------------------------------*/
                /*----------------------------*/
index 3df24562d11f28a698b5d10da1d19ff45401c298..9e24a3e4c94de2d9d0c4ed6e470b047f60abb567 100644 (file)
@@ -203,6 +203,7 @@ struct options
     int dump_range;            /* dump after live range analysis */
     int dump_pack;             /* dump after register packing */
     int dump_rassgn;           /* dump after register assignment */
+    int dump_tree;              /* dump front-end tree before lowering to iCode */
     int cc_only;               /* compile only flag              */
     int intlong_rent;          /* integer & long support routines reentrant */
     int float_rent;            /* floating point routines are reentrant */
index be35a87756efcca74defcbc7ef6003617840badc..63d3937bff1735c4efc9391d4e4db1a165d51939 100644 (file)
@@ -171,6 +171,7 @@ optionsTable[] = {
     { 0,    "--dumpliverange",      &options.dump_range, NULL },
     { 0,    "--dumpregpack",        &options.dump_pack, NULL },
     { 0,    "--dumpregassign",      &options.dump_rassgn, NULL },
+    { 0,    "--dumptree",           &options.dump_tree, NULL },
     { 0,    OPTION_DUMP_ALL,        NULL, "Dump the internal structure at all stages" },
     { 0,    OPTION_XRAM_LOC,        NULL, "<nnnn> External Ram start location" },
     { 0,    OPTION_IRAM_SIZE,       NULL, "<nnnn> Internal Ram size" },