Norimasa Okamoto
/
pymite
python-on-a-chip online compiler
- http://pymbed.appspot.com/
- https://code.google.com/p/python-on-a-chip/
- http://www.youtube.com/watch?v=Oyqc2bFRW9I
- https://bitbucket.org/va009039/pymbed/
more info: python-on-a-chip
vm/func.h@15:94ca5c8003e5, 2016-04-14 (annotated)
- Committer:
- va009039
- Date:
- Thu Apr 14 22:32:57 2016 +0000
- Revision:
- 15:94ca5c8003e5
- Parent:
- 0:65f1469d6bfb
update Nucleo-F401RE.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:65f1469d6bfb | 1 | /* |
va009039 | 0:65f1469d6bfb | 2 | # This file is Copyright 2002 Dean Hall. |
va009039 | 0:65f1469d6bfb | 3 | # This file is part of the PyMite VM. |
va009039 | 0:65f1469d6bfb | 4 | # This file is licensed under the MIT License. |
va009039 | 0:65f1469d6bfb | 5 | # See the LICENSE file for details. |
va009039 | 0:65f1469d6bfb | 6 | */ |
va009039 | 0:65f1469d6bfb | 7 | |
va009039 | 0:65f1469d6bfb | 8 | |
va009039 | 0:65f1469d6bfb | 9 | #ifndef __FUNC_H__ |
va009039 | 0:65f1469d6bfb | 10 | #define __FUNC_H__ |
va009039 | 0:65f1469d6bfb | 11 | |
va009039 | 0:65f1469d6bfb | 12 | /** |
va009039 | 0:65f1469d6bfb | 13 | * \file |
va009039 | 0:65f1469d6bfb | 14 | * \brief Function Object Type |
va009039 | 0:65f1469d6bfb | 15 | * |
va009039 | 0:65f1469d6bfb | 16 | * Function object type header. |
va009039 | 0:65f1469d6bfb | 17 | */ |
va009039 | 0:65f1469d6bfb | 18 | |
va009039 | 0:65f1469d6bfb | 19 | /** |
va009039 | 0:65f1469d6bfb | 20 | * Function obj |
va009039 | 0:65f1469d6bfb | 21 | * |
va009039 | 0:65f1469d6bfb | 22 | * A function is like an instance of a code obj. |
va009039 | 0:65f1469d6bfb | 23 | * Contains ptr to its code obj and has its own attributes dict. |
va009039 | 0:65f1469d6bfb | 24 | * |
va009039 | 0:65f1469d6bfb | 25 | * The first (__main__) module that is executed has a function obj |
va009039 | 0:65f1469d6bfb | 26 | * created for it to execute the bytecode which builds the module. |
va009039 | 0:65f1469d6bfb | 27 | */ |
va009039 | 0:65f1469d6bfb | 28 | typedef struct PmFunc_s |
va009039 | 0:65f1469d6bfb | 29 | { |
va009039 | 0:65f1469d6bfb | 30 | /** Object descriptor */ |
va009039 | 0:65f1469d6bfb | 31 | PmObjDesc_t od; |
va009039 | 0:65f1469d6bfb | 32 | |
va009039 | 0:65f1469d6bfb | 33 | /** Ptr to code obj */ |
va009039 | 0:65f1469d6bfb | 34 | pPmCo_t f_co; |
va009039 | 0:65f1469d6bfb | 35 | |
va009039 | 0:65f1469d6bfb | 36 | /** Ptr to attribute dict */ |
va009039 | 0:65f1469d6bfb | 37 | pPmDict_t f_attrs; |
va009039 | 0:65f1469d6bfb | 38 | |
va009039 | 0:65f1469d6bfb | 39 | /** Ptr to globals dict */ |
va009039 | 0:65f1469d6bfb | 40 | pPmDict_t f_globals; |
va009039 | 0:65f1469d6bfb | 41 | |
va009039 | 0:65f1469d6bfb | 42 | #ifdef HAVE_DEFAULTARGS |
va009039 | 0:65f1469d6bfb | 43 | /** Ptr to tuple holding default args */ |
va009039 | 0:65f1469d6bfb | 44 | pPmTuple_t f_defaultargs; |
va009039 | 0:65f1469d6bfb | 45 | #endif /* HAVE_DEFAULTARGS */ |
va009039 | 0:65f1469d6bfb | 46 | |
va009039 | 0:65f1469d6bfb | 47 | #ifdef HAVE_CLOSURES |
va009039 | 0:65f1469d6bfb | 48 | /** Ptr to tuple of cell values */ |
va009039 | 0:65f1469d6bfb | 49 | pPmTuple_t f_closure; |
va009039 | 0:65f1469d6bfb | 50 | #endif /* HAVE_CLOSURES */ |
va009039 | 0:65f1469d6bfb | 51 | |
va009039 | 0:65f1469d6bfb | 52 | } PmFunc_t, |
va009039 | 0:65f1469d6bfb | 53 | *pPmFunc_t; |
va009039 | 0:65f1469d6bfb | 54 | |
va009039 | 0:65f1469d6bfb | 55 | |
va009039 | 0:65f1469d6bfb | 56 | /** |
va009039 | 0:65f1469d6bfb | 57 | * Creates a Function Obj for the given Code Obj. |
va009039 | 0:65f1469d6bfb | 58 | * Allocate space for a Func obj and fill the fields. |
va009039 | 0:65f1469d6bfb | 59 | * |
va009039 | 0:65f1469d6bfb | 60 | * @param pco ptr to code obj |
va009039 | 0:65f1469d6bfb | 61 | * @param pglobals ptr to globals dict (from containing func/module) |
va009039 | 0:65f1469d6bfb | 62 | * @param r_pfunc Return by reference; pointer to new function |
va009039 | 0:65f1469d6bfb | 63 | * @return Return status |
va009039 | 0:65f1469d6bfb | 64 | */ |
va009039 | 0:65f1469d6bfb | 65 | PmReturn_t func_new(pPmObj_t pco, pPmObj_t pglobals, pPmObj_t *r_pfunc); |
va009039 | 0:65f1469d6bfb | 66 | |
va009039 | 0:65f1469d6bfb | 67 | #endif /* __FUNC_H__ */ |