2014-05-03 22:27:38 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013, 2014 Damien P. George
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2014-12-25 21:29:19 +00:00
|
|
|
#ifndef __MICROPY_INCLUDED_PY_RUNTIME0_H__
|
|
|
|
#define __MICROPY_INCLUDED_PY_RUNTIME0_H__
|
2014-05-03 22:27:38 +00:00
|
|
|
|
2014-04-09 11:27:39 +00:00
|
|
|
// These must fit in 8 bits; see scope.h
|
2015-08-17 21:39:03 +00:00
|
|
|
#define MP_SCOPE_FLAG_VARARGS (0x01)
|
|
|
|
#define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
|
|
|
|
#define MP_SCOPE_FLAG_GENERATOR (0x04)
|
2015-10-22 22:45:37 +00:00
|
|
|
#define MP_SCOPE_FLAG_DEFKWARGS (0x08)
|
2014-02-15 19:33:11 +00:00
|
|
|
|
2014-08-15 15:45:41 +00:00
|
|
|
// types for native (viper) function signature
|
|
|
|
#define MP_NATIVE_TYPE_OBJ (0x00)
|
|
|
|
#define MP_NATIVE_TYPE_BOOL (0x01)
|
|
|
|
#define MP_NATIVE_TYPE_INT (0x02)
|
|
|
|
#define MP_NATIVE_TYPE_UINT (0x03)
|
2016-02-02 23:16:05 +00:00
|
|
|
#define MP_NATIVE_TYPE_PTR (0x04)
|
|
|
|
#define MP_NATIVE_TYPE_PTR8 (0x05)
|
|
|
|
#define MP_NATIVE_TYPE_PTR16 (0x06)
|
|
|
|
#define MP_NATIVE_TYPE_PTR32 (0x07)
|
2014-08-15 15:45:41 +00:00
|
|
|
|
2013-12-21 18:17:45 +00:00
|
|
|
typedef enum {
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_UNARY_OP_BOOL, // __bool__
|
|
|
|
MP_UNARY_OP_LEN, // __len__
|
2015-05-11 12:25:19 +00:00
|
|
|
MP_UNARY_OP_HASH, // __hash__; must return a small int
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_UNARY_OP_POSITIVE,
|
|
|
|
MP_UNARY_OP_NEGATIVE,
|
|
|
|
MP_UNARY_OP_INVERT,
|
|
|
|
MP_UNARY_OP_NOT,
|
|
|
|
} mp_unary_op_t;
|
2013-12-21 18:17:45 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_OR,
|
|
|
|
MP_BINARY_OP_XOR,
|
|
|
|
MP_BINARY_OP_AND,
|
|
|
|
MP_BINARY_OP_LSHIFT,
|
|
|
|
MP_BINARY_OP_RSHIFT,
|
2014-05-10 01:24:22 +00:00
|
|
|
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_ADD,
|
|
|
|
MP_BINARY_OP_SUBTRACT,
|
|
|
|
MP_BINARY_OP_MULTIPLY,
|
|
|
|
MP_BINARY_OP_FLOOR_DIVIDE,
|
|
|
|
MP_BINARY_OP_TRUE_DIVIDE,
|
2014-05-10 01:24:22 +00:00
|
|
|
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_MODULO,
|
|
|
|
MP_BINARY_OP_POWER,
|
2015-06-13 21:00:10 +00:00
|
|
|
MP_BINARY_OP_DIVMOD, // not emitted by the compiler but supported by the runtime
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_INPLACE_OR,
|
|
|
|
MP_BINARY_OP_INPLACE_XOR,
|
2014-05-10 01:24:22 +00:00
|
|
|
|
2015-06-13 21:00:10 +00:00
|
|
|
MP_BINARY_OP_INPLACE_AND,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_INPLACE_LSHIFT,
|
|
|
|
MP_BINARY_OP_INPLACE_RSHIFT,
|
|
|
|
MP_BINARY_OP_INPLACE_ADD,
|
|
|
|
MP_BINARY_OP_INPLACE_SUBTRACT,
|
2014-05-10 01:24:22 +00:00
|
|
|
|
2015-06-13 21:00:10 +00:00
|
|
|
MP_BINARY_OP_INPLACE_MULTIPLY,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_INPLACE_FLOOR_DIVIDE,
|
|
|
|
MP_BINARY_OP_INPLACE_TRUE_DIVIDE,
|
|
|
|
MP_BINARY_OP_INPLACE_MODULO,
|
|
|
|
MP_BINARY_OP_INPLACE_POWER,
|
2015-06-13 21:00:10 +00:00
|
|
|
|
2014-02-01 23:04:09 +00:00
|
|
|
// these should return a bool
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_LESS,
|
|
|
|
MP_BINARY_OP_MORE,
|
|
|
|
MP_BINARY_OP_EQUAL,
|
|
|
|
MP_BINARY_OP_LESS_EQUAL,
|
|
|
|
MP_BINARY_OP_MORE_EQUAL,
|
2014-05-10 01:24:22 +00:00
|
|
|
|
2015-06-13 21:00:10 +00:00
|
|
|
MP_BINARY_OP_NOT_EQUAL,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_IN,
|
|
|
|
MP_BINARY_OP_IS,
|
|
|
|
MP_BINARY_OP_EXCEPTION_MATCH,
|
2014-02-01 23:04:09 +00:00
|
|
|
// these are not supported by the runtime and must be synthesised by the emitter
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_BINARY_OP_NOT_IN,
|
|
|
|
MP_BINARY_OP_IS_NOT,
|
|
|
|
} mp_binary_op_t;
|
2013-12-21 18:17:45 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2014-08-15 22:47:59 +00:00
|
|
|
MP_F_CONVERT_OBJ_TO_NATIVE = 0,
|
|
|
|
MP_F_CONVERT_NATIVE_TO_OBJ,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_LOAD_NAME,
|
|
|
|
MP_F_LOAD_GLOBAL,
|
|
|
|
MP_F_LOAD_BUILD_CLASS,
|
|
|
|
MP_F_LOAD_ATTR,
|
|
|
|
MP_F_LOAD_METHOD,
|
|
|
|
MP_F_STORE_NAME,
|
2014-08-15 22:47:59 +00:00
|
|
|
MP_F_STORE_GLOBAL,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_STORE_ATTR,
|
2014-04-17 21:10:53 +00:00
|
|
|
MP_F_OBJ_SUBSCR,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_OBJ_IS_TRUE,
|
|
|
|
MP_F_UNARY_OP,
|
|
|
|
MP_F_BINARY_OP,
|
|
|
|
MP_F_BUILD_TUPLE,
|
|
|
|
MP_F_BUILD_LIST,
|
|
|
|
MP_F_LIST_APPEND,
|
|
|
|
MP_F_BUILD_MAP,
|
|
|
|
MP_F_STORE_MAP,
|
2014-06-01 12:46:47 +00:00
|
|
|
#if MICROPY_PY_BUILTINS_SET
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_BUILD_SET,
|
|
|
|
MP_F_STORE_SET,
|
2014-06-01 12:46:47 +00:00
|
|
|
#endif
|
2014-04-13 10:04:33 +00:00
|
|
|
MP_F_MAKE_FUNCTION_FROM_RAW_CODE,
|
2014-08-16 21:06:11 +00:00
|
|
|
MP_F_NATIVE_CALL_FUNCTION_N_KW,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_CALL_METHOD_N_KW,
|
2015-04-06 21:48:21 +00:00
|
|
|
MP_F_CALL_METHOD_N_KW_VAR,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_GETITER,
|
|
|
|
MP_F_ITERNEXT,
|
2014-08-16 21:31:57 +00:00
|
|
|
MP_F_NLR_PUSH,
|
|
|
|
MP_F_NLR_POP,
|
2014-08-16 21:06:11 +00:00
|
|
|
MP_F_NATIVE_RAISE,
|
2014-04-06 11:58:40 +00:00
|
|
|
MP_F_IMPORT_NAME,
|
2014-08-16 21:31:57 +00:00
|
|
|
MP_F_IMPORT_FROM,
|
2014-04-06 11:58:40 +00:00
|
|
|
MP_F_IMPORT_ALL,
|
2014-06-01 12:49:35 +00:00
|
|
|
#if MICROPY_PY_BUILTINS_SLICE
|
2014-04-06 11:58:40 +00:00
|
|
|
MP_F_NEW_SLICE,
|
2014-06-01 12:49:35 +00:00
|
|
|
#endif
|
2014-04-06 11:58:40 +00:00
|
|
|
MP_F_UNPACK_SEQUENCE,
|
2014-05-07 17:30:52 +00:00
|
|
|
MP_F_UNPACK_EX,
|
2014-09-06 17:38:20 +00:00
|
|
|
MP_F_DELETE_NAME,
|
|
|
|
MP_F_DELETE_GLOBAL,
|
2015-01-15 14:41:41 +00:00
|
|
|
MP_F_NEW_CELL,
|
|
|
|
MP_F_MAKE_CLOSURE_FROM_RAW_CODE,
|
2015-04-06 21:38:53 +00:00
|
|
|
MP_F_SETUP_CODE_STATE,
|
2014-03-30 12:35:08 +00:00
|
|
|
MP_F_NUMBER_OF,
|
|
|
|
} mp_fun_kind_t;
|
2013-12-21 18:17:45 +00:00
|
|
|
|
2014-03-30 12:35:08 +00:00
|
|
|
extern void *const mp_fun_table[MP_F_NUMBER_OF];
|
2014-12-25 21:29:19 +00:00
|
|
|
|
|
|
|
#endif // __MICROPY_INCLUDED_PY_RUNTIME0_H__
|