cvsuser     04/08/04 04:55:25

  Modified:    ast      ast_main.c hello.past node.c
               imcc     debug.h main.c
               languages/python ast2past.py
  Log:
  ast 13 - add outer Parrot_AST
  * this creates a more regular tree
  * add meta info to AST
  * add -d100 to Parrot flags
  * more cleanup
  
  Revision  Changes    Path
  1.6       +3 -4      parrot/ast/ast_main.c
  
  Index: ast_main.c
  ===================================================================
  RCS file: /cvs/public/parrot/ast/ast_main.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- ast_main.c        3 Aug 2004 14:39:20 -0000       1.5
  +++ ast_main.c        4 Aug 2004 11:55:17 -0000       1.6
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: ast_main.c,v 1.5 2004/08/03 14:39:20 leo Exp $
  +$Id: ast_main.c,v 1.6 2004/08/04 11:55:17 leo Exp $
   
   =head1 NAME
   
  @@ -54,9 +54,8 @@
       top_node = interpreter->imc_info->top_node;
       top_node = IMCC_expand_nodes(interpreter, top_node);
       if (top_node) {
  -        if (interpreter->imc_info->debug & 0x100) {
  -            IMCC_dump_nodes(top_node); /* TODO commandline switches */
  -            fprintf(stderr, "\n");
  +        if (interpreter->imc_info->debug & DEBUG_AST) {
  +            IMCC_dump_nodes(top_node);
           }
           IMCC_free_nodes(interpreter, top_node);
       }
  
  
  
  1.3       +7 -2      parrot/ast/hello.past
  
  Index: hello.past
  ===================================================================
  RCS file: /cvs/public/parrot/ast/hello.past,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- hello.past        2 Aug 2004 10:33:04 -0000       1.2
  +++ hello.past        4 Aug 2004 11:55:17 -0000       1.3
  @@ -1,7 +1,11 @@
   
  -# generated by ast2past.py on Mon Aug  2 07:40:16 2004
  +# generated by ast2past.py on Wed Aug  4 13:26:44 2004
   
  -Src_File("hello.py")
  +Parrot_AST(
  +  version(Const('0.1'))
  + _options(
  + ) # _options
  + Src_File("languages/python/hello.py")
    Py_Module(
     _()
     Stmts(
  @@ -12,3 +16,4 @@
     ) # Stmts
    ) # Py_Module
    # end
  +) # Parrot_AST
  
  
  
  1.14      +23 -49    parrot/ast/node.c
  
  Index: node.c
  ===================================================================
  RCS file: /cvs/public/parrot/ast/node.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -r1.13 -r1.14
  --- node.c    4 Aug 2004 09:00:37 -0000       1.13
  +++ node.c    4 Aug 2004 11:55:17 -0000       1.14
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: node.c,v 1.13 2004/08/04 09:00:37 leo Exp $
  +$Id: node.c,v 1.14 2004/08/04 11:55:17 leo Exp $
   
   =head1 NAME
   
  @@ -195,22 +195,9 @@
       return p;
   }
   
  -/*
  - * create code for a sequence of nodes likes chained statements
  - */
  -static nodeType*
  -exp_next(Interp* interpreter, nodeType *p)
  -{
  -    nodeType *next;
  -    for (next = p->next; next; next = next->next) {
  -        if (next->expand)
  -            next->expand(interpreter, next);
  -    }
  -    return p;
  -}
   
   /*
  - * like above but expand child nodes
  + * create code by expanding child nodes
    */
   static nodeType*
   exp_default(Interp* interpreter, nodeType *p)
  @@ -510,25 +497,6 @@
       return NULL;
   }
   
  -/*
  - * TODO
  - */
  -static nodeType*
  -exp_Src_File(Interp* interpreter, nodeType *p)
  -{
  -    return exp_next(interpreter, p);
  -}
  -
  -/*
  - * TODO
  - */
  -static nodeType*
  -exp_Src_Lines(Interp* interpreter, nodeType *p)
  -{
  -    return exp_next(interpreter, p);
  -}
  -
  -
   
   typedef struct {
       const char *name;
  @@ -552,19 +520,24 @@
       { "Const",               NULL,     exp_Const, NULL, dump_Const },
       { "Defaults",    create_1, exp_Defaults, NULL, NULL },
       { "Function",    create_Func, exp_Function, NULL, NULL },
  +    { "Line_no",        create_1,  NULL, NULL, NULL },
       { "Name",           create_Name, NULL, NULL, NULL },
       { "Op",             create_Name, NULL, NULL, NULL },
       { "Params",      create_1, exp_Params, NULL, NULL },
  +    { "Parrot_AST",  create_1, exp_default, NULL, NULL },
       { "Py_Call",     create_1, exp_Py_Call, NULL, NULL },
       { "Py_Local",    create_Name, exp_Py_Local, NULL, NULL },
       { "Py_Module",   create_1, exp_Py_Module, NULL, NULL },
       { "Py_Print" ,   create_1, exp_Py_Print, NULL, NULL },
       { "Py_Print_nl", create_0, exp_Py_Print_nl, NULL, NULL },
  -    { "Src_File",            create_1, exp_Src_File, NULL, NULL },
  -    { "Src_Line",            create_1, exp_Src_Lines, NULL, NULL },
  +    { "Src_File",            create_1, NULL, NULL, NULL },
  +    { "Src_Line",            create_1, NULL, NULL, NULL },
       { "Stmts",          create_1, exp_default, NULL, NULL },
       { "Void",           create_1, exp_default, NULL, NULL },
  -    { "_",              create_0, NULL, NULL, NULL }
  +    { "_",              create_0, NULL, NULL, NULL },
  +    { "_options",       create_1, NULL, NULL, NULL },
  +    { "version",        create_1, exp_default, NULL, NULL }
  +
   #define CONST_NODE 5
   };
   
  @@ -820,12 +793,16 @@
   IMCC_dump_nodes(nodeType *p)
   {
       dump(p, 0);
  -    printf("\n");
  +    fprintf(stderr, "\n");
   }
   
   nodeType *
   IMCC_expand_nodes(Interp* interpreter, nodeType *p)
   {
  +    /*
  +     * TODO remove Src_Line, Src_File, Line_no
  +     *      and convert this info to meta info for the node
  +     */
       p = check_nodes(interpreter, p);
       return p->expand(interpreter, p);
   }
  @@ -833,18 +810,15 @@
   void
   IMCC_free_nodes(Interp* interpreter, nodeType *p)
   {
  -    nodeType *child, *next, *dest;
  +    nodeType *child, *next;
  +    for (next = p; next; ) {
       if (p->flags & NODE_HAS_CHILD) {
           child = CHILD(p);
           IMCC_free_nodes(interpreter, child);
       }
  -    dest = p->dest;
  -    if (dest && dest->expand == exp_Temp)
  -        mem_sys_free(dest);
       next = p->next;
       mem_sys_free(p);
  -    if (next)
  -        IMCC_free_nodes(interpreter, next);
  +    }
   }
   
   /*
  
  
  
  1.17      +2 -0      parrot/imcc/debug.h
  
  Index: debug.h
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/debug.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -w -r1.16 -r1.17
  --- debug.h   22 Apr 2004 08:55:00 -0000      1.16
  +++ debug.h   4 Aug 2004 11:55:22 -0000       1.17
  @@ -9,6 +9,8 @@
   #define DEBUG_OPT1   0x0020
   #define DEBUG_OPT2   0x0040
   
  +#define DEBUG_AST    0x0100
  +
   #define DEBUG_PBC    0x1000
   #define DEBUG_PBC_CONST    0x2000
   #define DEBUG_PBC_FIXUP    0x4000
  
  
  
  1.77      +1 -0      parrot/imcc/main.c
  
  Index: main.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/main.c,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -w -r1.76 -r1.77
  --- main.c    1 Aug 2004 16:10:18 -0000       1.76
  +++ main.c    4 Aug 2004 11:55:22 -0000       1.77
  @@ -46,6 +46,7 @@
       "    0x0010    CFG\n"
       "    0x0020    optimization 1\n"
       "    0x0040    optimization 2\n"
  +    "    0x0100    AST\n"
       "    0x1000    PBC\n"
       "    0x2000    PBC constants\n"
       "    0x4000    PBC fixups\n");
  
  
  
  1.6       +9 -5      parrot/languages/python/ast2past.py
  
  Index: ast2past.py
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/ast2past.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- ast2past.py       4 Aug 2004 07:48:47 -0000       1.5
  +++ ast2past.py       4 Aug 2004 11:55:25 -0000       1.6
  @@ -24,6 +24,8 @@
   import traceback
   from compiler import ast
   
  +VERSION = '0.1'
  +
   class imclist(list):
       def __init__(self):
        self._verbose = False
  @@ -712,12 +714,14 @@
       pir._print_source = source
       compiler.visitor.walk(ast, pir, vis, 1)
       pir.append("# end")
  -    [EMAIL PROTECTED]: refactor this mess:
  -    if name=="__main__":
  -        lines = [ "Src_File(\"%s\")" % fn
  +    lines = [ "Parrot_AST(",
  +           "  version(Const('%s'))" % VERSION,
  +              " _options(",
  +           " ) # _options",
  +              " Src_File(\"%s\")" % fn
                   ]
   
  -        pir.lines = lines + pir.lines
  +    pir.lines = lines + pir.lines + [") # Parrot_AST"]
       code =  pir.getCode()
       return code
   
  
  
  

Reply via email to