1. 28 Şub, 2001 4 kayıt (commit)
    • Jeremy Hylton's avatar
      add DEF_BOUND · 99858b53
      Jeremy Hylton yazdı
      99858b53
    • Guido van Rossum's avatar
      1bcb7e93
    • Jeremy Hylton's avatar
      Improve SyntaxErrors for bad future statements. Set file and location · ad3d3f2f
      Jeremy Hylton yazdı
      for errors raised in future.c.
      
      Move some helper functions from compile.c to errors.c and make them
      API functions: PyErr_SyntaxLocation() and PyErr_ProgramText().
      ad3d3f2f
    • Jeremy Hylton's avatar
      Presumed correct compiler pass for future statements · 39e2f3f8
      Jeremy Hylton yazdı
      XXX still need to integrate into symtable API
      
      compile.h: Remove ff_n_simple_stmt; obsolete.
      
                 Add ff_found_docstring used internally to skip one and only
                 one string at the beginning of a module.
      
      compile.c: Add check for from __future__ imports to far into the file.
      
       	   In symtable_global() check for -1 returned from
      	   symtable_lookup(), which signifies name not defined.
      
      	   Add missing DECERF in symtable_add_def.
      
                 Free c->c_future.
      
      future.c:  Add special handling for multiple statements joined on a
      	   single line using one or more semicolons; this form can
                 include an illegal future statement that would otherwise be
                 hard to detect.
      
      	   Add support for detecting and skipping doc strings.
      39e2f3f8
  2. 27 Şub, 2001 3 kayıt (commit)
    • Jeremy Hylton's avatar
      Improved __future__ parser; still more to do · 4db62b1e
      Jeremy Hylton yazdı
      Makefile.pre.in: add target future.o
      
      Include/compile.h: define PyFutureFeaters and PyNode_Future()
                         add c_future slot to struct compiling
      
      Include/symtable.h: add st_future slot to struct symtable
      
      Python/future.c: implementation of PyNode_Future()
      
      Python/compile.c: use PyNode_Future() for nested_scopes support
      
      Python/symtable.c: include compile.h to pick up PyFutureFeatures decl
      4db62b1e
    • Neil Schemenauer's avatar
      a35c6880
    • Jeremy Hylton's avatar
      Preliminary support for future nested scopes · 29906eef
      Jeremy Hylton yazdı
      compile.h: #define NESTED_SCOPES_DEFAULT 0 for Python 2.1
                 __future__ feature name: "nested_scopes"
      
      symtable.h: Add st_nested_scopes slot.  Define flags to track exec and
          import star.
      
      Lib/test/test_scope.py: requires nested scopes
      
      compile.c: Fiddle with error messages.
      
          Reverse the sense of ste_optimized flag on
          PySymtableEntryObjects.  If it is true, there is an optimization
          conflict.
      
          Modify get_ref_type to respect st_nested_scopes flags.
      
          Refactor symtable_load_symbols() into several smaller functions,
          which use struct symbol_info to share variables.  In new function
          symtable_update_flags(), raise an error or warning for import * or
          bare exec that conflicts with nested scopes.  Also, modify handle
          for free variables to respect st_nested_scopes flag.
      
          In symtable_init() assign st_nested_scopes flag to
          NESTED_SCOPES_DEFAULT (defined in compile.h).
      
          Add preliminary and often incorrect implementation of
          symtable_check_future().
      
          Add symtable_lookup() helper for future use.
      29906eef
  3. 26 Şub, 2001 1 kayıt (commit)
  4. 23 Şub, 2001 1 kayıt (commit)
  5. 09 Şub, 2001 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Relax the rules for using 'from ... import *' and exec in the presence · cb17ae8b
      Jeremy Hylton yazdı
      of nested functions.  Either is allowed in a function if it contains
      no defs or lambdas or the defs and lambdas it contains have no free
      variables.  If a function is itself nested and has free variables,
      either is illegal.
      
      Revise the symtable to use a PySymtableEntryObject, which holds all
      the revelent information for a scope, rather than using a bunch of
      st_cur_XXX pointers in the symtable struct.  The changes simplify the
      internal management of the current symtable scope and of the stack.
      
      Added new C source file: Python/symtable.c.  (Does the Windows build
      process need to be updated?)
      
      As part of these changes, the initial _symtable module interface
      introduced in 2.1a2 is replaced.  A dictionary of
      PySymtableEntryObjects are returned.
      cb17ae8b
  6. 03 Şub, 2001 1 kayıt (commit)
  7. 02 Şub, 2001 4 kayıt (commit)
  8. 01 Şub, 2001 3 kayıt (commit)
  9. 29 Ock, 2001 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Remove f_closure slot of frameobject and use f_localsplus instead. · 2b724da8
      Jeremy Hylton yazdı
      This change eliminates an extra malloc/free when a frame with free
      variables is created.  Any cell vars or free vars are stored in
      f_localsplus after the locals and before the stack.
      
      eval_code2() fills in the appropriate values after handling
      initialization of locals.
      
      To track the size the frame has an f_size member that tracks the total
      size of f_localsplus. It used to be implicitly f_nlocals + f_stacksize.
      2b724da8
  10. 28 Ock, 2001 2 kayıt (commit)
  11. 25 Ock, 2001 3 kayıt (commit)
    • Fred Drake's avatar
      The addition of new parameters to functions in the Python/C API requires · 73a3c8fa
      Fred Drake yazdı
      that PYTHON_API_VERSION be incremented.
      73a3c8fa
    • Jeremy Hylton's avatar
      PEP 227 implementation · 64949cb7
      Jeremy Hylton yazdı
      The majority of the changes are in the compiler.  The mainloop changes
      primarily to implement the new opcodes and to pass a function's
      closure to eval_code2().  Frames and functions got new slots to hold
      the closure.
      
      Include/compile.h
          Add co_freevars and co_cellvars slots to code objects.
          Update PyCode_New() to take freevars and cellvars as arguments
      Include/funcobject.h
          Add func_closure slot to function objects.
          Add GetClosure()/SetClosure() functions (and corresponding
          macros) for getting at the closure.
      Include/frameobject.h
          PyFrame_New() now takes a closure.
      Include/opcode.h
          Add four new opcodes: MAKE_CLOSURE, LOAD_CLOSURE, LOAD_DEREF,
          STORE_DEREF.
          Remove comment about old requirement for opcodes to fit in 7
          bits.
      compile.c
          Implement changes to code objects for co_freevars and co_cellvars.
      
          Modify symbol table to use st_cur_name (string object for the name
          of the current scope) and st_cur_children (list of nested blocks).
          Also define st_nested, which might more properly be called
          st_cur_nested.  Add several DEF_XXX flags to track def-use
          information for free variables.
      
          New or modified functions of note:
          com_make_closure(struct compiling *, PyCodeObject *)
              Emit LOAD_CLOSURE opcodes as needed to pass cells for free
              variables into nested scope.
          com_addop_varname(struct compiling *, int, char *)
              Emits opcodes for LOAD_DEREF and STORE_DEREF.
          get_ref_type(struct compiling *, char *name)
              Return NAME_CLOSURE if ref type is FREE or CELL
          symtable_load_symbols(struct compiling *)
              Decides what variables are cell or free based on def-use info.
              Can now raise SyntaxError if nested scopes are mixed with
              exec or from blah import *.
          make_scope_info(PyObject *, PyObject *, int, int)
              Helper functions for symtable scope stack.
          symtable_update_free_vars(struct symtable *)
              After a code block has been analyzed, it must check each of
              its children for free variables that are not defined in the
              block.  If a variable is free in a child and not defined in
              the parent, then it is defined by block the enclosing the
              current one or it is a global.  This does the right logic.
          symtable_add_use() is now a macro for symtable_add_def()
          symtable_assign(struct symtable *, node *)
              Use goto instead of for (;;)
      
          Fixed bug in symtable where name of keyword argument in function
          call was treated as assignment in the scope of the call site. Ex:
              def f():
                  g(a=2) # a was considered a local of f
      
      ceval.c
          eval_code2() now take one more argument, a closure.
          Implement LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE>
      
          Also: When name error occurs for global variable, report that the
          name was global in the error mesage.
      
      Objects/frameobject.c
          Initialize f_closure to be a tuple containing space for cellvars
          and freevars.  f_closure is NULL if neither are present.
      Objects/funcobject.c
          Add support for func_closure.
      Python/import.c
          Change the magic number.
      Python/marshal.c
          Track changes to code objects.
      64949cb7
    • Jeremy Hylton's avatar
      PEP 227 implementation · fbd849f2
      Jeremy Hylton yazdı
      A cell contains a reference to a single PyObject.  It could be
      implemented as a mutable, one-element sequence, but the separate type
      has less overhead.
      fbd849f2
  12. 24 Ock, 2001 3 kayıt (commit)
  13. 23 Ock, 2001 3 kayıt (commit)
  14. 22 Ock, 2001 1 kayıt (commit)
  15. 21 Ock, 2001 1 kayıt (commit)
  16. 20 Ock, 2001 1 kayıt (commit)
  17. 19 Ock, 2001 1 kayıt (commit)
  18. 18 Ock, 2001 1 kayıt (commit)
  19. 17 Ock, 2001 5 kayıt (commit)