py: Move to guarded includes, everywhere in py/ core.

Addresses issue #1022.
This commit is contained in:
Damien George
2015-01-01 20:27:54 +00:00
parent db1ac360c3
commit 51dfcb4bb7
128 changed files with 528 additions and 817 deletions
+2 -6
View File
@@ -27,12 +27,8 @@
#include <stdlib.h>
#include <assert.h>
#include "mpconfig.h"
#include "nlr.h"
#include "misc.h"
#include "qstr.h"
#include "obj.h"
#include "runtime.h"
#include "py/nlr.h"
#include "py/runtime.h"
void mp_arg_check_num(mp_uint_t n_args, mp_uint_t n_kw, mp_uint_t n_args_min, mp_uint_t n_args_max, bool takes_kw) {
// TODO maybe take the function name as an argument so we can print nicer error messages
+3 -3
View File
@@ -29,13 +29,13 @@
#include <assert.h>
#include <string.h>
#include "mpconfig.h"
#include "misc.h"
#include "asmarm.h"
#include "py/mpconfig.h"
// wrapper around everything in this file
#if MICROPY_EMIT_ARM
#include "py/asmarm.h"
#define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000)
struct _asm_arm_t {
+3 -3
View File
@@ -28,13 +28,13 @@
#include <assert.h>
#include <string.h>
#include "mpconfig.h"
#include "misc.h"
#include "asmthumb.h"
#include "py/mpconfig.h"
// wrapper around everything in this file
#if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB
#include "py/asmthumb.h"
#define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0)
#define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0)
#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)
+2 -3
View File
@@ -29,13 +29,12 @@
#include <assert.h>
#include <string.h>
#include "mpconfig.h"
#include "misc.h"
#include "py/mpconfig.h"
// wrapper around everything in this file
#if MICROPY_EMIT_X64
#include "asmx64.h"
#include "py/asmx64.h"
/* all offsets are measured in multiples of 8 bytes */
#define WORD_SIZE (8)
+2 -3
View File
@@ -29,13 +29,12 @@
#include <assert.h>
#include <string.h>
#include "mpconfig.h"
#include "misc.h"
#include "py/mpconfig.h"
// wrapper around everything in this file
#if MICROPY_EMIT_X86
#include "asmx86.h"
#include "py/asmx86.h"
/* all offsets are measured in multiples of 4 bytes */
#define WORD_SIZE (4)
+3 -11
View File
@@ -29,17 +29,9 @@
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include "nlr.h"
#include "misc.h"
#include "qstr.h"
#include "obj.h"
#include "objtuple.h"
#include "objfun.h"
#include "runtime0.h"
#include "runtime.h"
#include "bc.h"
#include "stackctrl.h"
#include "py/nlr.h"
#include "py/objfun.h"
#include "py/bc.h"
#if 0 // print debugging info
#define DEBUG_PRINT (1)
+7
View File
@@ -23,6 +23,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __MICROPY_INCLUDED_PY_BC_H__
#define __MICROPY_INCLUDED_PY_BC_H__
#include "py/runtime.h"
#include "py/obj.h"
// Exception stack entry
typedef struct _mp_exc_stack {
@@ -61,3 +66,5 @@ const byte *mp_bytecode_print_str(const byte *ip);
#define MP_TAGPTR_TAG0(x) ((mp_uint_t)(x) & 1)
#define MP_TAGPTR_TAG1(x) ((mp_uint_t)(x) & 2)
#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((mp_uint_t)(ptr) | (tag)))
#endif // __MICROPY_INCLUDED_PY_BC_H__
+4
View File
@@ -23,6 +23,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __MICROPY_INCLUDED_PY_BC0_H__
#define __MICROPY_INCLUDED_PY_BC0_H__
// Micro Python byte-codes.
// The comment at the end of the line (if it exists) tells the arguments to the byte-code.
@@ -118,3 +120,5 @@
#define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16)
#define MP_BC_UNARY_OP_MULTI (0xd0) // + op(5)
#define MP_BC_BINARY_OP_MULTI (0xd5) // + op(35)
#endif // __MICROPY_INCLUDED_PY_BC0_H__
+2 -6
View File
@@ -30,12 +30,8 @@
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
#include "obj.h"
#include "smallint.h"
#include "binary.h"
#include "py/binary.h"
#include "py/smallint.h"
// Helpers to work with binary-encoded data
+6
View File
@@ -23,6 +23,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __MICROPY_INCLUDED_PY_BINARY_H__
#define __MICROPY_INCLUDED_PY_BINARY_H__
#include "py/obj.h"
// Use special typecode to differentiate repr() of bytearray vs array.array('B')
// (underlyingly they're same).
@@ -36,3 +40,5 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr);
void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr);
long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src);
void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val);
#endif // __MICROPY_INCLUDED_PY_BINARY_H__
+6
View File
@@ -23,6 +23,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __MICROPY_INCLUDED_PY_BUILTIN_H__
#define __MICROPY_INCLUDED_PY_BUILTIN_H__
#include "py/obj.h"
mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args);
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
@@ -101,3 +105,5 @@ extern const mp_obj_module_t mp_module_ure;
extern const mp_obj_module_t mp_module_uheapq;
extern const mp_obj_module_t mp_module_uhashlib;
extern const mp_obj_module_t mp_module_ubinascii;
#endif // __MICROPY_INCLUDED_PY_BUILTIN_H__
+5 -14
View File
@@ -26,20 +26,11 @@
#include <stdint.h>
#include "mpconfig.h"
#include "nlr.h"
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
#include "lexerunix.h"
#include "parse.h"
#include "obj.h"
#include "objfun.h"
#include "parsehelper.h"
#include "compile.h"
#include "runtime0.h"
#include "runtime.h"
#include "builtin.h"
#include "py/nlr.h"
#include "py/objfun.h"
#include "py/compile.h"
#include "py/runtime.h"
#include "py/builtin.h"
#if MICROPY_PY_BUILTINS_COMPILE
+5 -15
View File
@@ -25,25 +25,15 @@
* THE SOFTWARE.
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include "nlr.h"
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
#include "lexerunix.h"
#include "parse.h"
#include "obj.h"
#include "objmodule.h"
#include "parsehelper.h"
#include "compile.h"
#include "runtime0.h"
#include "runtime.h"
#include "builtin.h"
#include "py/nlr.h"
#include "py/compile.h"
#include "py/objmodule.h"
#include "py/runtime.h"
#include "py/builtin.h"
#if 0 // print debugging info
#define DEBUG_PRINT (1)
+8 -16
View File
@@ -31,26 +31,18 @@
#include <assert.h>
#include <math.h>
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
#include "parse.h"
#include "runtime0.h"
#include "obj.h"
#include "emitglue.h"
#include "scope.h"
#include "emit.h"
#include "compile.h"
#include "runtime.h"
#include "builtin.h"
#include "smallint.h"
#include "py/scope.h"
#include "py/emit.h"
#include "py/compile.h"
#include "py/smallint.h"
#include "py/runtime.h"
#include "py/builtin.h"
// TODO need to mangle __attr names
typedef enum {
#define DEF_RULE(rule, comp, kind, ...) PN_##rule,
#include "grammar.h"
#include "py/grammar.h"
#undef DEF_RULE
PN_maximum_number_of,
PN_string, // special node for non-interned string
@@ -2937,7 +2929,7 @@ STATIC compile_function_t compile_function[] = {
#define nc NULL
#define c(f) compile_##f
#define DEF_RULE(rule, comp, kind, ...) comp,
#include "grammar.h"
#include "py/grammar.h"
#undef nc
#undef c
#undef DEF_RULE
+7 -4
View File
@@ -24,6 +24,13 @@
* THE SOFTWARE.
*/
#ifndef __MICROPY_INCLUDED_PY_EMIT_H__
#define __MICROPY_INCLUDED_PY_EMIT_H__
#include "py/lexer.h"
#include "py/scope.h"
#include "py/runtime0.h"
/* Notes on passes:
* We don't know exactly the opcodes in pass 1 because they depend on the
* closing over of variables (LOAD_CLOSURE, BUILD_TUPLE, MAKE_CLOSURE), which
@@ -33,10 +40,6 @@
* This is problematic for some emitters (x64) since they need to know the maximum
* stack size to compile the entry to the function, and this affects code size.
*/
#ifndef __MICROPY_INCLUDED_PY_EMIT_H__
#define __MICROPY_INCLUDED_PY_EMIT_H__
#include "py/runtime0.h"
typedef enum {
MP_PASS_SCOPE = 1, // work out id's and their kind, and number of labels
+2 -11
View File
@@ -30,17 +30,8 @@
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
#include "parse.h"
#include "obj.h"
#include "emitglue.h"
#include "scope.h"
#include "runtime0.h"
#include "emit.h"
#include "bc0.h"
#include "py/emit.h"
#include "py/bc0.h"
#if !MICROPY_EMIT_CPYTHON
+1 -10
View File
@@ -28,16 +28,7 @@
#include <stdint.h>
#include <assert.h>
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
#include "parse.h"
#include "runtime0.h"
#include "obj.h"
#include "emitglue.h"
#include "scope.h"
#include "emit.h"
#include "py/emit.h"
#define EMIT(fun, ...) (emit_method_table->fun(emit, __VA_ARGS__))
+1 -10
View File
@@ -30,16 +30,7 @@
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
#include "parse.h"
#include "obj.h"
#include "emitglue.h"
#include "scope.h"
#include "runtime0.h"
#include "emit.h"
#include "py/emit.h"
// wrapper around everything in this file
#if MICROPY_EMIT_CPYTHON
+3 -8
View File
@@ -30,14 +30,9 @@
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
#include "obj.h"
#include "runtime0.h"
#include "runtime.h"
#include "emitglue.h"
#include "bc.h"
#include "py/emitglue.h"
#include "py/runtime0.h"
#include "py/bc.h"
#if 0 // print debugging info
#define DEBUG_PRINT (1)
+2
View File
@@ -26,6 +26,8 @@
#ifndef __MICROPY_INCLUDED_PY_EMITGLUE_H__
#define __MICROPY_INCLUDED_PY_EMITGLUE_H__
#include "py/obj.h"
// These variables and functions glue the code emitters to the runtime.
typedef enum {

Some files were not shown because too many files have changed in this diff Show More