summaryrefslogtreecommitdiff
path: root/py/emitglue.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-29 01:26:02 +0000
committerDamien George <damien.p.george@gmail.com>2014-03-29 01:26:02 +0000
commitc47fd2da8ec705a3c6f51d1a09b7bf4a180a01ff (patch)
tree8304956bd360b2bda7a6f5ee8e9443111da183dd /py/emitglue.c
parentbcc9298e5bd2049bbee8c1d00482d2695b8e0b70 (diff)
parent1d7553311c70810a6fea2d72b04403b93711389c (diff)
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'py/emitglue.c')
-rw-r--r--py/emitglue.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/py/emitglue.c b/py/emitglue.c
index 0ab909092..ed816a516 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -1,6 +1,6 @@
// This code glues the code emitters to the runtime.
-#include <stdlib.h>
+#include <stdio.h>
#include <assert.h>
#include "misc.h"
@@ -10,6 +10,7 @@
#include "runtime0.h"
#include "runtime.h"
#include "emitglue.h"
+#include "bc.h"
#if 0 // print debugging info
#define DEBUG_PRINT (1)
@@ -51,13 +52,27 @@ STATIC machine_uint_t unique_codes_alloc = 0;
STATIC mp_code_t *unique_codes = NULL;
STATIC uint next_unique_code_id;
+#ifdef WRITE_CODE
+FILE *fp_write_code = NULL;
+#endif
+
void mp_emit_glue_init(void) {
next_unique_code_id = 0;
unique_codes_alloc = 0;
unique_codes = NULL;
+
+#ifdef WRITE_CODE
+ fp_write_code = fopen("out-code", "wb");
+#endif
}
void mp_emit_glue_deinit(void) {
+#ifdef WRITE_CODE
+ if (fp_write_code != NULL) {
+ fclose(fp_write_code);
+ }
+#endif
+
m_del(mp_code_t, unique_codes, unique_codes_alloc);
}