Numworks Epsilon  1.4.1
Graphing Calculator Operating System
emitglue.h
Go to the documentation of this file.
1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2013, 2014 Damien P. George
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 #ifndef MICROPY_INCLUDED_PY_EMITGLUE_H
27 #define MICROPY_INCLUDED_PY_EMITGLUE_H
28 
29 #include "py/obj.h"
30 
31 // These variables and functions glue the code emitters to the runtime.
32 
33 typedef enum {
41 
42 typedef struct _mp_raw_code_t {
46  union {
47  struct {
48  const byte *bytecode;
50  #if MICROPY_PERSISTENT_CODE_SAVE
51  mp_uint_t bc_len;
52  uint16_t n_obj;
53  uint16_t n_raw_code;
54  #endif
55  } u_byte;
56  struct {
57  void *fun_data;
58  const mp_uint_t *const_table;
59  mp_uint_t type_sig; // for viper, compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
60  } u_native;
61  } data;
63 
65 
66 void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len,
67  const mp_uint_t *const_table,
69  uint16_t n_obj, uint16_t n_raw_code,
70  #endif
71  mp_uint_t scope_flags);
72 void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig);
73 
76 
77 #endif // MICROPY_INCLUDED_PY_EMITGLUE_H
mp_raw_code_kind_t
Definition: emitglue.h:33
uintptr_t mp_uint_t
Definition: mpconfigport.h:74
union _mp_raw_code_t::@15 data
mp_uint_t type_sig
Definition: emitglue.h:59
struct _mp_raw_code_t::@15::@16 u_byte
mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args)
Definition: emitglue.c:157
const mp_uint_t * const_table
Definition: emitglue.h:49
unsigned short uint16_t
Definition: stdint.h:5
struct _mp_raw_code_t mp_raw_code_t
struct _mp_raw_code_t::@15::@17 u_native
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, const mp_uint_t *const_table, mp_uint_t scope_flags)
Definition: emitglue.c:58
void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig)
mp_raw_code_t * mp_emit_glue_new_raw_code(void)
Definition: emitglue.c:52
mp_uint_t n_pos_args
Definition: emitglue.h:45
args
Definition: i18n.py:175
mp_uint_t scope_flags
Definition: emitglue.h:44
unsigned char byte
Definition: misc.h:37
void * fun_data
Definition: emitglue.h:57
mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args)
Definition: emitglue.c:116
uint64_t mp_obj_t
Definition: obj.h:39
#define MICROPY_PERSISTENT_CODE_SAVE
Definition: mpconfig.h:246
const byte * bytecode
Definition: emitglue.h:48
mp_raw_code_kind_t kind
Definition: emitglue.h:43