00001 /* 00002 # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall. 00003 # 00004 # This file is part of the PyMite VM. 00005 # The PyMite VM is free software: you can redistribute it and/or modify 00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. 00007 # 00008 # The PyMite VM is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 00012 # is seen in the file COPYING in this directory. 00013 */ 00014 00015 00016 #ifndef __CODEOBJ_H__ 00017 #define __CODEOBJ_H__ 00018 00019 00029 #define CI_TYPE_FIELD 0 00030 #define CI_SIZE_FIELD 1 00031 #define CI_ARGCOUNT_FIELD 3 00032 #define CI_FLAGS_FIELD 4 00033 #define CI_STACKSIZE_FIELD 5 00034 #define CI_NLOCALS_FIELD 6 00035 00036 #ifdef HAVE_CLOSURES 00037 # define CI_FREEVARS_FIELD 7 00038 # ifdef HAVE_DEBUG_INFO 00039 # define CI_FIRST_LINE_NO 8 00040 # define CI_NAMES_FIELD 10 00041 # else 00042 # define CI_NAMES_FIELD 8 00043 # endif /* HAVE_DEBUG_INFO */ 00044 #else 00045 # ifdef HAVE_DEBUG_INFO 00046 # define CI_FIRST_LINE_NO 7 00047 # define CI_NAMES_FIELD 9 00048 # else 00049 # define CI_NAMES_FIELD 7 00050 # endif /* HAVE_DEBUG_INFO */ 00051 #endif /* HAVE_CLOSURES */ 00052 00053 00055 #define NATIVE_IMAGE_SIZE 4 00056 00057 /* Masks for co_flags (from Python's code.h) */ 00058 #define CO_OPTIMIZED 0x01 00059 #define CO_NEWLOCALS 0x02 00060 #define CO_VARARGS 0x04 00061 #define CO_VARKEYWORDS 0x08 00062 #define CO_NESTED 0x10 00063 #define CO_GENERATOR 0x20 00064 #define CO_NOFREE 0x40 00065 00073 typedef struct PmCo_s 00074 { 00076 PmObjDesc_t od; 00078 uint8_t const *co_codeimgaddr; 00080 pPmTuple_t co_names; 00082 pPmTuple_t co_consts; 00084 uint8_t const *co_codeaddr; 00085 00086 #ifdef HAVE_DEBUG_INFO 00087 00088 uint8_t const *co_lnotab; 00090 uint8_t const *co_filename; 00092 uint16_t co_firstlineno; 00093 #endif /* HAVE_DEBUG_INFO */ 00094 00095 #ifdef HAVE_CLOSURES 00096 00097 pPmTuple_t co_cellvars; 00099 uint8_t co_nfreevars; 00100 #endif /* HAVE_CLOSURES */ 00101 00103 PmMemSpace_t co_memspace:8; 00105 uint8_t co_argcount; 00107 uint8_t co_flags; 00109 uint8_t co_stacksize; 00111 uint8_t co_nlocals; 00112 } PmCo_t, 00113 *pPmCo_t; 00114 00122 typedef struct PmNo_s 00123 { 00125 PmObjDesc_t od; 00127 int8_t no_argcount; 00129 int16_t no_funcindx; 00130 } PmNo_t, 00131 *pPmNo_t; 00132 00133 00174 PmReturn_t 00175 co_loadFromImg(PmMemSpace_t memspace, uint8_t const **paddr, pPmObj_t *r_pco); 00176 00186 void co_rSetCodeImgAddr(pPmCo_t pco, uint8_t const *pimg); 00187 00215 PmReturn_t no_loadFromImg(PmMemSpace_t memspace, 00216 uint8_t const **paddr, pPmObj_t *r_pno); 00217 00218 #endif /* __CODEOBJ_H__ */