Commits

Dean Hall  committed 2aeed4d

#166 mainlined directly

  • Participants
  • Parent commits 4a3e5d7
  • Tags pymite-07

Comments (0)

Files changed (16)

 :Author:    Dean Hall
 :Copyright: Copyright 2002 Dean Hall.
             See `License`_ for details.
-:Release:   06
+:Release:   07
 :Site:      http://pymite.python-hosting.com/
 :Id:        $Id: README 116 2006-08-24 13:42:09Z dwhall $
 
 -------
 
 PyMite is offered through one of two licenses: commercial or open-source.
-See the LICENSE file at the root of this package for licensing details.
+See the LICENSE_ file at the root of this package for licensing details.
 
 All of the documentation and images for PyMite are
 licensed under the GNU Free Documentation License.
     with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
     Texts.  A copy of the license is in the file ``docs/LICENSE``.
 
+.. _LICENSE: LICENSE
+
 
 Build
 -----
     2. In ``src/sample/avr`` run ``make`` to build a sample program for the AVR.
 
 The development system should have installed the GNU Compiler
-Collection version 3.4 or later and Python 2.5 or later.
-The author also uses avr-gcc to target Atmel AVR microcontrollers.
+Collection version 3.4 or later and Python 2.5 or 2.6.
+The author also uses avr-gcc to target Atmel AVR microcontrollers
+and arm-elf-gcc to target ARM7TDMI microcontrollers.
 
 PyMite is developed on Mac OS X and should also compile on
 GNU/Linux and Cygwin operating systems.  Since PyMite is so
 Release Notes
 -------------
 
-This is PyMite release 06
+This is PyMite release 07
+
+* Release 07, 2009/03/08
+
+    - #166:   Created release 07
+    - #97:    Implemented plat_reportError for AVR
+    - #176:   Improved ipm host to accept serial device and baudrate arguments
+    - #175:   Removed src/tests/interactive
+    - #168:   Updated file header copyright
+    - #171:   Removed platform-specific code from src/vm/
+    - #174:   Added support for keyword lambda
+    - #173:   Fixed type-punned pointer warning in interp.c
+    - #167:   Updated the MMB103 sample project
+    - #169:   Removed rarely used builtins to save heap
+    - #164:   Added support for list comprehensions
+    - #163:   Fixed sys.runInThread()
+    - #162:   Implemented builtin function dir()
+    - #161:   Improved filter for unsupported code
+    - #160:   Added support for string and tuple replication
+    - #159:   Created a make target for ipm
+    - #158:   Fixed builtin sum() to support float
+    - #155:   Fixed bytecodes that POP an object
+    - #157:   Added support for funcs with default args
+    - #52:    Investigated GPL issues with respect to the user's application
+      code
+    - #146:   Found and made some existing features configurable
+    - #154:   Reduced heap memory used during global_loadBuiltins()
+    - #149:   Supported the keyword del
+    - #151:   t090 runs too fast and fails on some systems
+    - #66:    Created doc explaining requirements for using PyMite on device
+    - #106:   Documented in the code when to use HAVE_STRING_H
+    - #153:   Fixed dict.clear() which fails to free the seglists
+    - #5:     Created script to automate dist process
+    - #44:    Updated DevelopmentProcess.txt for short and long branches
+    - #152:   Changed image terminator
+    - #121:   Fixed type-punned compiler warnings
+    - #150:   Replaced PmImgInfo_t to save RAM
+    - #148:   Created configurable Float datatype
+    - #147:   Supported Boolean type and True/False constants
+    - #47:    Designed and implement method for basic types to access their
+      respective class methods
+    - #144:   Maked GC a configurable option
+    - #142:   list.append left a remnant on the stack
+    - #143:   ipm can't import sys
+    - #145:   System test t110.py fails during make check
+    - #126:   Fixed GC so it works properly during ipm
+    - #125:   Unreachable chunks not collected
+    - #127:   SEGV or Error 0xFC in endless loop
+    - #141:   String cache not handled by GC
+    - #140:   Created func module with introspection functions
+    - #55:    Created index doc
+    - #119:   Printed Python traceback on exception
+    - #139:   Allow heap larger than 64 KB
+    - #110:   Prevent IMPORT_NAME from reloading existing module
+    - #138:   globals namespace isn't right
 
 * Release 06, 2009/01/30
 
     - #114: Created platform file for Atmel's ARM7
     - #112: Forced Dict keys to be of hashable type
     - #105: Moved OBJ_TYPE_THR to some value before OBJ_TYPE_HASHABLE_MAX
-    - #108: Cleaned up *_POWER bytecodes
+    - #108: Cleaned up \*_POWER bytecodes
     - #113: Fixed the implementation of builtin map()
     - #68:  Cleaned up code to meet standards
-    - #102: Implemented the remaining IMPORT_ bytecodes
+    - #102: Implemented the remaining IMPORT_* bytecodes
     - #46:  Finalized design of string objects
     - #69:  Fixed bitwise operators to prevent automatic promotion
     - #32:  Used GNU indent for code formatting

File src/vm/float.c

     retval = heap_getChunk(sizeof(PmFloat_t), (uint8_t **)r_pf);
     PM_RETURN_IF_ERROR(retval);
     OBJ_SET_TYPE(*r_pf, OBJ_TYPE_FLT);
-    ((pPmFloat_t)*r_pf)->val = f;
+    ((pPmFloat_t) * r_pf)->val = f;
     return retval;
 }
 
     /* This does not use snprintf because glibc's snprintf is only
      * included for compiles without strict-ansi.
      */
-    bytesWritten =
-        sprintf((void *)&tBuffer, "%f", ((pPmFloat_t)pf)->val);
+    bytesWritten = sprintf((void *)&tBuffer, "%f", ((pPmFloat_t) pf)->val);
 
     /* Sanity check */
     C_ASSERT(bytesWritten != 0);
 float_negative(pPmObj_t pf, pPmObj_t *r_pf)
 {
     /* Create new int obj */
-    return float_new(-((pPmFloat_t)pf)->val, r_pf);
+    return float_new(-((pPmFloat_t) pf)->val, r_pf);
 }
 
 #endif /* HAVE_PRINT */
     }
     else
     {
-        x = ((pPmFloat_t)px)->val;
+        x = ((pPmFloat_t) px)->val;
     }
 
     if (OBJ_GET_TYPE(py) == OBJ_TYPE_INT)
     }
     else
     {
-        y = ((pPmFloat_t)py)->val;
+        y = ((pPmFloat_t) py)->val;
     }
 
     /* Raise ZeroDivisionError if denominator is zero */
     }
     else
     {
-        x = ((pPmFloat_t)px)->val;
+        x = ((pPmFloat_t) px)->val;
     }
 
     if (OBJ_GET_TYPE(py) == OBJ_TYPE_INT)
     }
     else
     {
-        y = ((pPmFloat_t)py)->val;
+        y = ((pPmFloat_t) py)->val;
     }
 
     switch (cmp)

File src/vm/float.h

 
     /** Float value */
     float val;
-} PmFloat_t,
- *pPmFloat_t;
+} PmFloat_t, *pPmFloat_t;
 
 
 /**
  * @param cmp The comparison operator
  * @return Return status
  */
-PmReturn_t float_compare(pPmObj_t px, pPmObj_t py, pPmObj_t *r_pobj, PmCompare_t cmp);
+PmReturn_t float_compare(pPmObj_t px, pPmObj_t py, pPmObj_t *r_pobj,
+                         PmCompare_t cmp);
 
 #ifdef HAVE_PRINT
 /**

File src/vm/func.h

 #ifdef HAVE_DEFAULTARGS
     /** Ptr to tuple holding default args */
     pPmTuple_t f_defaultargs;
-#endif /* HAVE_DEFAULTARGS */
+#endif                          /* HAVE_DEFAULTARGS */
 
 } PmFunc_t,
  *pPmFunc_t;

File src/vm/global.c

     PM_RETURN_IF_ERROR(retval);
     pobj = (pPmObj_t)pchunk;
     OBJ_SET_TYPE(pobj, OBJ_TYPE_BOOL);
-    ((pPmBoolean_t)pobj)->val = (int32_t)C_FALSE;
+    ((pPmBoolean_t) pobj)->val = (int32_t)C_FALSE;
     gVmGlobal.pfalse = (pPmInt_t)pobj;
 
     /* Init True */
     PM_RETURN_IF_ERROR(retval);
     pobj = (pPmObj_t)pchunk;
     OBJ_SET_TYPE(pobj, OBJ_TYPE_BOOL);
-    ((pPmBoolean_t)pobj)->val = (int32_t)C_TRUE;
+    ((pPmBoolean_t) pobj)->val = (int32_t)C_TRUE;
     gVmGlobal.ptrue = (pPmInt_t)pobj;
 
     /* Init None */

File src/vm/heap.c

 
     /** Boolean to indicate if GC should run automatically */
     uint8_t auto_gc;
-#endif /* HAVE_GC */
+#endif                          /* HAVE_GC */
 
 } PmHeap_t,
  *pPmHeap_t;
 heap_gcPrintFreelist(void)
 {
     pPmHeapDesc_t pchunk = pmHeap.pfreelist;
+
     printf("DEBUG: pmHeap.avail = %d\n", pmHeap.avail);
     printf("DEBUG: freelist:\n");
     while (pchunk != C_NULL)
 heap_init(void)
 {
     pPmHeapDesc_t pchunk;
+
 #if HEAP_SIZE > 65535
     uint32_t hs;
 #else
 
     /* Create as many max-sized chunks as possible in the freelist */
     for (pchunk = (pPmHeapDesc_t)pmHeap.base, hs = HEAP_SIZE;
-         hs >= HEAP_MAX_FREE_CHUNK_SIZE;
-         hs -= HEAP_MAX_FREE_CHUNK_SIZE)
+         hs >= HEAP_MAX_FREE_CHUNK_SIZE; hs -= HEAP_MAX_FREE_CHUNK_SIZE)
     {
         OBJ_SET_FREE(pchunk, 1);
         OBJ_SET_SIZE(pchunk, HEAP_MAX_FREE_CHUNK_SIZE);
         heap_linkToFreelist(pchunk);
-        pchunk = (pPmHeapDesc_t)((uint8_t *)pchunk + HEAP_MAX_FREE_CHUNK_SIZE);
+        pchunk =
+            (pPmHeapDesc_t)((uint8_t *)pchunk + HEAP_MAX_FREE_CHUNK_SIZE);
     }
 
     /* Add any leftover memory to the freelist */
         OBJ_SET_FREE(pchunk, 0);
         OBJ_SET_SIZE(pchunk, size);
 
-        C_DEBUG_PRINT(VERBOSITY_HIGH, "heap_getChunkImpl()carved, id=%p, s=%d\n",
-                      pchunk, size);
+        C_DEBUG_PRINT(VERBOSITY_HIGH,
+                      "heap_getChunkImpl()carved, id=%p, s=%d\n", pchunk,
+                      size);
     }
     else
     {
         OBJ_SET_TYPE((pPmObj_t)pchunk, OBJ_TYPE_NON);
         OBJ_SET_FREE(pchunk, 0);
 
-        C_DEBUG_PRINT(VERBOSITY_HIGH, "heap_getChunkImpl()exact, id=%p, s=%d\n",
-                      pchunk, OBJ_GET_SIZE(pchunk));
+        C_DEBUG_PRINT(VERBOSITY_HIGH,
+                      "heap_getChunkImpl()exact, id=%p, s=%d\n", pchunk,
+                      OBJ_GET_SIZE(pchunk));
     }
 
     /*
 
     /* The pointer must be within the heap (native frame is special case) */
     C_ASSERT((((uint8_t *)pobj >= &pmHeap.base[0])
-             && ((uint8_t *)pobj <= &pmHeap.base[HEAP_SIZE]))
+              && ((uint8_t *)pobj <= &pmHeap.base[HEAP_SIZE]))
              || ((uint8_t *)pobj == (uint8_t *)&gVmGlobal.nativeframe));
 
     /* The object must not already be free */
     type = OBJ_GET_TYPE(pobj);
     switch (type)
     {
-        /* Objects with no references to other objects */
+            /* Objects with no references to other objects */
         case OBJ_TYPE_NON:
         case OBJ_TYPE_INT:
         case OBJ_TYPE_FLT:
             retval = heap_gcMarkObj((pPmObj_t)((pPmClass_t)pobj)->cl_attrs);
             break;
 
-        /*
-         * An obj in ram should not be of these types.
-         * Images arrive in RAM as string objects (image is array of bytes)
-         */
+            /*
+             * An obj in ram should not be of these types.
+             * Images arrive in RAM as string objects (image is array of bytes)
+             */
         case OBJ_TYPE_CIM:
         case OBJ_TYPE_NIM:
             PM_RAISE(retval, PM_RET_EX_SYS);
                 /* Mark the args to the native func */
                 for (i = 0; i < NATIVE_GET_NUM_ARGS(); i++)
                 {
-                    retval = heap_gcMarkObj(gVmGlobal.nativeframe
-                                            .nf_locals[i]);
+                    retval =
+                        heap_gcMarkObj(gVmGlobal.nativeframe.nf_locals[i]);
                     PM_RETURN_IF_ERROR(retval);
                 }
             }
     }
 
     /* Unlink remaining strings that are not marked */
-    for (pstr = *ppstrcache; pstr->next != C_NULL; )
+    for (pstr = *ppstrcache; pstr->next != C_NULL;)
     {
         /* Unlink consecutive non-marked strings */
         while ((pstr->next != C_NULL) && (OBJ_GET_GCVAL(pstr->next) != gcval))
 
             /* Proceed to the next chunk */
             pchunk = (pPmHeapDesc_t)
-                     ((uint8_t *)pchunk + OBJ_GET_SIZE(pchunk));
+                ((uint8_t *)pchunk + OBJ_GET_SIZE(pchunk));
 
             /* Stop if it's past the end of the heap */
             if ((uint8_t *)pchunk >= &pmHeap.base[HEAP_SIZE])

File src/vm/heap.h

 #else
 uint16_t
 #endif
-heap_getAvail(void);
+  heap_getAvail(void);
 
 #ifdef HAVE_GC
 /**

File src/vm/img.c

  */
 static PmReturn_t
 img_findInPath(uint8_t *cname, uint8_t cnamelen, PmMemSpace_t memspace,
-    uint8_t const **paddr)
+               uint8_t const **paddr)
 {
     uint8_t const *imgtop;
     PmType_t type;
 
         /* Ensure it's a tuple */
         type = mem_getByte(memspace, paddr);
-        C_ASSERT (type == OBJ_TYPE_TUP);
+        C_ASSERT(type == OBJ_TYPE_TUP);
 
         /* Scan to last name in tuple (it's the module's name) */
         i = mem_getByte(memspace, paddr) - (uint8_t)1;
 
 PmReturn_t
 img_findInPaths(pPmObj_t pname, PmMemSpace_t *r_memspace,
-    uint8_t const **r_imgaddr)
+                uint8_t const **r_imgaddr)
 {
     uint8_t i;
     PmReturn_t retval = PM_RET_NO;
         *r_memspace = gVmGlobal.imgPaths.memspace[i];
         retval = img_findInPath(((pPmString_t)pname)->val,
                                 ((pPmString_t)pname)->length,
-                                *r_memspace,
-                                r_imgaddr);
+                                *r_memspace, r_imgaddr);
         if (retval == PM_RET_NO)
         {
             continue;

File src/vm/img.h

  * @return Return status
  */
 PmReturn_t img_findInPaths(pPmObj_t pname, PmMemSpace_t *r_memspace,
-    uint8_t const **r_imgaddr);
+                           uint8_t const **r_imgaddr);
 
 /**
  * Appends the given memspace and address to the image path array

File src/vm/interp.c

             continue;
         }
 
-        /* Reschedule threads if flag is true?*/
+        /* Reschedule threads if flag is true? */
         if (gVmGlobal.reschedule)
         {
             retval = interp_reschedule();
 
 #ifdef HAVE_FLOAT
                 else if ((OBJ_GET_TYPE(TOS) == OBJ_TYPE_FLT)
-                    || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_FLT))
+                         || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_FLT))
                 {
                     retval = float_op(TOS1, TOS, &pobj3, '*');
                     PM_BREAK_IF_ERROR(retval);
                     }
 
                     pobj2 = TOS1;
-                    retval = string_replicate(
-                        (uint8_t const **)(uint8_t *)&pobj2, t16, &pobj3);
+                    retval = string_replicate((uint8_t const **)(uint8_t *)
+                                              &pobj2, t16, &pobj3);
                     PM_BREAK_IF_ERROR(retval);
                     SP--;
                     TOS = pobj3;
                 /* #109: Check that stack should now be empty */
                 /* Get the number of local variables for this code obj */
                 uint8_t const *paddr = FP->fo_func->f_co->co_codeimgaddr
-                                       + CI_STACKSIZE_FIELD + 1;
+                    + CI_STACKSIZE_FIELD + 1;
                 t8 = mem_getByte(FP->fo_func->f_co->co_memspace, &paddr);
 
                 /* SP should point to one past the end of the locals */
                 pobj1 = TOS;
                 pobj2 = TOS1;
                 pobj3 = TOS2;
-                if (t16 >= 3) PM_PUSH(pobj3);
-                if (t16 >= 2) PM_PUSH(pobj2);
-                if (t16 >= 1) PM_PUSH(pobj1);
+                if (t16 >= 3)
+                    PM_PUSH(pobj3);
+                if (t16 >= 2)
+                    PM_PUSH(pobj2);
+                if (t16 >= 1)
+                    PM_PUSH(pobj1);
                 continue;
 
             case LOAD_CONST:
                 if (((OBJ_GET_TYPE(TOS) == OBJ_TYPE_INT)
                      || (OBJ_GET_TYPE(TOS) == OBJ_TYPE_BOOL))
                     && ((OBJ_GET_TYPE(TOS1) == OBJ_TYPE_INT)
-                     || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_BOOL)))
+                        || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_BOOL)))
                 {
                     int32_t a = ((pPmInt_t)TOS1)->val;
                     int32_t b = ((pPmInt_t)TOS)->val;
 
                 /* #110: Prevent importing previously-loaded module */
                 /* If the named module is in globals, put it on the stack */
-                retval = dict_getItem((pPmObj_t)FP->fo_globals, pobj1, &pobj2);
+                retval =
+                    dict_getItem((pPmObj_t)FP->fo_globals, pobj1, &pobj2);
                 if ((retval == PM_RET_OK)
                     && (OBJ_GET_TYPE(pobj2) == OBJ_TYPE_MOD))
                 {
                     else
                     {
                         t8 = ((pPmFunc_t)pobj1)->f_co->co_argcount
-                             - ((pPmTuple_t)((pPmFunc_t)pobj1)->f_defaultargs)
-                                ->length;
+                            -
+                            ((pPmTuple_t)((pPmFunc_t)pobj1)->f_defaultargs)->
+                            length;
                     }
 
                     /*
                         int8_t i = 0;
 
                         /* Copy default args into the new frame's locals */
-                        for (/* t8 set above */;
-                             t8 < ((pPmFunc_t)pobj1)->f_co->co_argcount;
-                             t8++)
+                        for ( /* t8 set above */ ;
+                             t8 < ((pPmFunc_t)pobj1)->f_co->co_argcount; t8++)
                         {
                             ((pPmFrame_t)pobj2)->fo_locals[t8] =
-                                ((pPmTuple_t)((pPmFunc_t)pobj1)->f_defaultargs)
-                                 ->val[i++];
+                                ((pPmTuple_t)((pPmFunc_t)pobj1)->
+                                 f_defaultargs)->val[i++];
                         }
                     }
 #endif /* HAVE_DEFAULTARGS */

File src/vm/mem.c

 
 
 uint16_t
-mem_getStringLength(PmMemSpace_t memspace, uint8_t const * const pstr)
+mem_getStringLength(PmMemSpace_t memspace, uint8_t const *const pstr)
 {
     uint8_t const *psrc;
 
 
 PmReturn_t
 mem_cmpn(uint8_t *cname, uint8_t cnamelen, PmMemSpace_t memspace,
-    uint8_t const **paddr)
+         uint8_t const **paddr)
 {
     uint8_t i;
     uint8_t b;

File src/vm/mem.h

  * @return  Number of bytes in the string.
  */
 uint16_t mem_getStringLength(PmMemSpace_t memspace,
-                             uint8_t const * const pstr);
+                             uint8_t const *const pstr);
 
 /**
  * Compares a byte array in RAM to a byte array in the given memory space
  * @return PM_RET_OK if all bytes in both arrays match; PM_RET_NO otherwise
  */
 PmReturn_t mem_cmpn(uint8_t *cname, uint8_t cnamelen, PmMemSpace_t memspace,
-    uint8_t const **paddr);
+                    uint8_t const **paddr);
 
 #endif /* __MEM_H__ */

File src/vm/obj.c

 
 
     /* Get the object descriptor */
-    obj.od= (PmObjDesc_t)0x0000;
+    obj.od = (PmObjDesc_t)0x0000;
     OBJ_SET_TYPE(&obj, mem_getByte(memspace, paddr));
 
     switch (OBJ_GET_TYPE(&obj))
 #ifdef HAVE_FLOAT
         case OBJ_TYPE_FLT:
             /* The floats 0.0 and -0.0 are false */
-            return (((pPmFloat_t)pobj)->val == 0.0)
-                || (((pPmFloat_t)pobj)->val == -0.0);
+            return (((pPmFloat_t) pobj)->val == 0.0)
+                || (((pPmFloat_t) pobj)->val == -0.0);
 #endif /* HAVE_FLOAT */
 
         case OBJ_TYPE_STR:
 
         case OBJ_TYPE_BOOL:
             /* C int zero means false */
-            return ((pPmBoolean_t)pobj)->val == 0;
+            return ((pPmBoolean_t) pobj)->val == 0;
 
         default:
             /*
         case OBJ_TYPE_FLT:
         {
             pPmObj_t r_pobj;
+
             float_compare(pobj1, pobj2, &r_pobj, COMP_EQ);
             return (r_pobj == PM_TRUE) ? C_SAME : C_DIFFER;
         }
             break;
 
         case OBJ_TYPE_BOOL:
-            if (((pPmBoolean_t)pobj)->val == C_TRUE)
+            if (((pPmBoolean_t) pobj)->val == C_TRUE)
             {
                 plat_putByte('T');
                 plat_putByte('r');

File src/vm/obj.h

  * Macros are used to get and set field values.
  * Using macros eliminates declaring bit fields which fails on some compilers.
  */
-typedef uint16_t PmObjDesc_t, *pPmObjDesc_t;
+typedef uint16_t PmObjDesc_t,
+ *pPmObjDesc_t;
 
 /**
  * Object
     /** Boolean value */
     int32_t val;
 }
-PmBoolean_t,
-*pPmBoolean_t;
+PmBoolean_t, *pPmBoolean_t;
 
 
 /**
  * It helps locate a defect when used in conjunction with a fileID
  * and line number.
  */
-#define PM_RELEASE 6
+#define PM_RELEASE 7
 
 
 /** null for C code */

File src/vm/tuple.c

  * See the LICENSE file at the root of this package for licensing details.
  */
 
- 
+
 #undef __FILE_ID__
 #define __FILE_ID__ 0x13
 
  * Tuple object type operations.
  */
 
- 
+
 #include "pm.h"
 
 
     {
         for (j = 0; j < length; j++)
         {
-            ((pPmTuple_t)*r_ptuple)->val[length*i + j] =
+            ((pPmTuple_t)*r_ptuple)->val[length * i + j] =
                 ((pPmTuple_t)ptup)->val[j];
         }
     }