codeobj.c File Reference

CodeObj Type. More...

#include "pm.h"

Defines

#define __FILE_ID__   0x01

Functions

PmReturn_t co_loadFromImg (PmMemSpace_t memspace, uint8_t const **paddr, pPmObj_t *r_pco)
PmReturn_t no_loadFromImg (PmMemSpace_t memspace, uint8_t const **paddr, pPmObj_t *r_pno)


Detailed Description

CodeObj Type.

CodeObj type operations.


Function Documentation

PmReturn_t co_loadFromImg ( PmMemSpace_t  memspace,
uint8_t const **  paddr,
pPmObj_t r_pco 
)

Creates a CodeObj by loading info from a code image in memory.

An image is a static representation of a Python object. The process of converting an object to and from an image is also called marshalling. In PyMite, code images are the equivalent of .pyc files. Code images can only contain a select subset of object types (None, Int, Float, String, Slice?, Tuple, and CodeImg). All other types (Lists, Dicts, CodeObjs, Modules, Classes, Functions, ClassInstances) are built at runtime.

All multibyte values are in Little Endian order (least significant byte comes first in the byte stream).

memspace and *paddr determine the start of the code image. Load the code object with values from the code image, including the names and consts tuples. Leave contents of paddr pointing one byte past end of code img.

The code image has the following structure: -type: 8b - OBJ_TYPE_CIM -size: 16b - number of bytes the code image occupies. -argcount: 8b - number of arguments to this code obj. -stacksz: 8b - the maximum arg-stack size needed. -nlocals: 8b - number of local vars in the code obj. -names: Tuple - tuple of string objs. -consts: Tuple - tuple of objs. -code: 8b[] - bytecode array.

Parameters:
memspace memory space containing image
paddr ptr to ptr to code img in memspace return by reference: paddr points one byte past end of code img
r_pco Return arg. New code object with fields filled in.
Returns:
Return status

PmReturn_t no_loadFromImg ( PmMemSpace_t  memspace,
uint8_t const **  paddr,
pPmObj_t r_pno 
)

Creates a Native code object by loading a native image.

An image is a static representation of a Python object. A native image is much smaller than a regular image because only two items of data are needed after the type: the number of args the func expects and the index into the native function table. A reference to the image is not needed since it is just as efficient to store the info in RAM as it is to store a pointer and memspace value.

memspace and *paddr determine the start of the native image. Loads the argcount and the func index from the native object. Leaves contents of paddr pointing one byte past end of code img.

The native image has the following structure: -type: 8b - OBJ_TYPE_CIM -argcount: 8b - number of arguments to this code obj. -code: 16b - index into native function table.

Parameters:
memspace memory space containing image
paddr ptr to ptr to code img in memspace (return)
Returns:
new code object with fields filled in. return by reference: paddr points one byte past end of code img


Generated on Wed Feb 24 13:37:02 2010 for Python-on-a-chip by  doxygen 1.5.9