py, compiler: Clean up and compress scope/compile structures.

Convert int types to uint where sensible, and then to uint8_t or
uint16_t where possible to reduce RAM usage.
diff --git a/py/compile.c b/py/compile.c
index 95fe1d7..778e932 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -38,16 +38,17 @@
 
 typedef struct _compiler_t {
     qstr source_file;
-    bool is_repl;
-    pass_kind_t pass;
-    bool had_error; // try to keep compiler clean from nlr
+    uint8_t is_repl;
+    uint8_t pass; // holds enum type pass_kind_t
+    uint8_t had_error; // try to keep compiler clean from nlr
+    uint8_t func_arg_is_super; // used to compile special case of super() function call
 
     int next_label;
 
     int break_label;
     int continue_label;
     int break_continue_except_level;
-    int cur_except_level; // increased for SETUP_EXCEPT, SETUP_FINALLY; decreased for POP_BLOCK, POP_EXCEPT
+    uint16_t cur_except_level; // increased for SETUP_EXCEPT, SETUP_FINALLY; decreased for POP_BLOCK, POP_EXCEPT
 
     int n_arg_keyword;
     bool have_star_arg;
@@ -57,8 +58,6 @@
     int param_pass_num_dict_params;
     int param_pass_num_default_params;
 
-    bool func_arg_is_super; // used to compile special case of super() function call
-
     scope_t *scope_head;
     scope_t *scope_cur;
 
diff --git a/py/compile.h b/py/compile.h
index d4a17b7..10fd603 100644
--- a/py/compile.h
+++ b/py/compile.h
@@ -1,3 +1,4 @@
+// These must fit in 8 bits; see scope.h
 enum {
     MP_EMIT_OPT_NONE,
     MP_EMIT_OPT_BYTE_CODE,
diff --git a/py/emitbc.c b/py/emitbc.c
index 50bb001..b2edc25 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -321,6 +321,7 @@
 }
 
 STATIC void emit_bc_pre(emit_t *emit, int stack_size_delta) {
+    assert((int)emit->stack_size + stack_size_delta >= 0);
     emit->stack_size += stack_size_delta;
     if (emit->stack_size > emit->scope->stack_size) {
         emit->scope->stack_size = emit->stack_size;
diff --git a/py/emitnative.c b/py/emitnative.c
index af8b35f..a02b125 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -308,8 +308,8 @@
 
 STATIC void adjust_stack(emit_t *emit, int stack_size_delta) {
     DEBUG_printf("adjust stack: stack:%d + delta:%d\n", emit->stack_size, stack_size_delta);
+    assert((int)emit->stack_size + stack_size_delta >= 0);
     emit->stack_size += stack_size_delta;
-    assert(emit->stack_size >= 0);
     if (emit->pass > PASS_1 && emit->stack_size > emit->scope->stack_size) {
         emit->scope->stack_size = emit->stack_size;
     }
diff --git a/py/runtime0.h b/py/runtime0.h
index be598c6..6ee70aa 100644
--- a/py/runtime0.h
+++ b/py/runtime0.h
@@ -1,4 +1,5 @@
 // taken from python source, Include/code.h
+// These must fit in 8 bits; see scope.h
 #define MP_SCOPE_FLAG_OPTIMISED    0x01
 #define MP_SCOPE_FLAG_NEWLOCALS    0x02
 #define MP_SCOPE_FLAG_VARARGS      0x04
diff --git a/py/scope.c b/py/scope.c
index cc4be7c..d55a4dd 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -10,10 +10,8 @@
 #include "scope.h"
 
 scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, uint unique_code_id, uint emit_options) {
-    scope_t *scope = m_new(scope_t, 1);
+    scope_t *scope = m_new0(scope_t, 1);
     scope->kind = kind;
-    scope->parent = NULL;
-    scope->next = NULL;
     scope->pn = pn;
     scope->source_file = source_file;
     switch (kind) {
@@ -43,19 +41,10 @@
         default:
             assert(0);
     }
-    scope->id_info_alloc = 8;
-    scope->id_info_len = 0;
-    scope->id_info = m_new(id_info_t, scope->id_info_alloc);
-
-    scope->scope_flags = 0;
-    scope->num_params = 0;
-    /* not needed
-    scope->num_default_params = 0;
-    scope->num_dict_params = 0;
-    */
-    scope->num_locals = 0;
     scope->unique_code_id = unique_code_id;
     scope->emit_options = emit_options;
+    scope->id_info_alloc = 8;
+    scope->id_info = m_new(id_info_t, scope->id_info_alloc);
 
     return scope;
 }
diff --git a/py/scope.h b/py/scope.h
index 7ecd1e1..daba296 100644
--- a/py/scope.h
+++ b/py/scope.h
@@ -7,14 +7,12 @@
 };
 
 typedef struct _id_info_t {
-    // TODO compress this info to make structure smaller in memory
-    bool param;
-    int kind;
-    qstr qstr;
-
+    uint8_t param;
+    uint8_t kind;
     // when it's an ID_INFO_KIND_LOCAL this is the unique number of the local
     // whet it's an ID_INFO_KIND_CELL/FREE this is the unique number of the closed over variable
-    int local_num;
+    uint16_t local_num;
+    qstr qstr;
 } id_info_t;
 
 // scope is a "block" in Python parlance
@@ -26,20 +24,16 @@
     mp_parse_node_t pn;
     qstr source_file;
     qstr simple_name;
-    int id_info_alloc;
-    int id_info_len;
-    id_info_t *id_info;
-    uint scope_flags; // see runtime0.h
-    int num_params;
-    /* not needed
-    int num_default_params;
-    int num_dict_params;
-    */
-    int num_locals;
-    int stack_size;     // maximum size of the locals stack
-    int exc_stack_size; // maximum size of the exception stack
     uint unique_code_id;
-    uint emit_options;
+    uint8_t scope_flags;  // see runtime0.h
+    uint8_t emit_options; // see compile.h
+    uint16_t num_params;
+    uint16_t num_locals;
+    uint16_t stack_size;     // maximum size of the locals stack
+    uint16_t exc_stack_size; // maximum size of the exception stack
+    uint16_t id_info_alloc;
+    uint16_t id_info_len;
+    id_info_t *id_info;
 } scope_t;
 
 scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, uint unique_code_id, uint emit_options);