Go to the source code of this file.
Classes | |
struct | PmCo_s |
struct | PmNo_s |
Defines | |
#define | CI_TYPE_FIELD 0 |
#define | CI_SIZE_FIELD 1 |
#define | CI_ARGCOUNT_FIELD 3 |
#define | CI_FLAGS_FIELD 4 |
#define | CI_STACKSIZE_FIELD 5 |
#define | CI_NLOCALS_FIELD 6 |
#define | CI_NAMES_FIELD 7 |
#define | NATIVE_IMAGE_SIZE 4 |
#define | CO_OPTIMIZED 0x01 |
#define | CO_NEWLOCALS 0x02 |
#define | CO_VARARGS 0x04 |
#define | CO_VARKEYWORDS 0x08 |
#define | CO_NESTED 0x10 |
#define | CO_GENERATOR 0x20 |
#define | CO_NOFREE 0x40 |
Typedefs | |
typedef struct PmCo_s | PmCo_t |
typedef struct PmCo_s * | pPmCo_t |
typedef struct PmNo_s | PmNo_t |
typedef struct PmNo_s * | pPmNo_t |
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) |
CodeObj type header.
#define CI_TYPE_FIELD 0 |
Code image field offset consts
#define NATIVE_IMAGE_SIZE 4 |
Native code image size
Code Object
An extended object that holds only the most frequently used parts of the static code image. Other parts can be obtained by inspecting the code image itself.
Native Code Object
An extended object that holds only the most frequently used parts of the static native image. Other parts can be obtained by inspecting the native image itself.
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.
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. |
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.
memspace | memory space containing image | |
paddr | ptr to ptr to code img in memspace (return) |