summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitpass1.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-05 00:51:47 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-05 00:51:47 +0000
commit35e2a4e6bb319a208af8d3e5c3e59cee7873400a (patch)
treeabe2bb266bbb011c807a335b839226a6a66f8341 /py/emitpass1.c
parente0723497b3dbce94e6ce2a2dcd59af510f094fa4 (diff)
downloadmicropython-35e2a4e6bb319a208af8d3e5c3e59cee7873400a.tar.gz
micropython-35e2a4e6bb319a208af8d3e5c3e59cee7873400a.zip
py: Add built-in super.
Diffstat (limited to 'py/emitpass1.c')
-rw-r--r--py/emitpass1.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/py/emitpass1.c b/py/emitpass1.c
index 38115a51c1..634d090518 100644
--- a/py/emitpass1.c
+++ b/py/emitpass1.c
@@ -15,13 +15,11 @@
#include "emit.h"
struct _emit_t {
- qstr qstr___class__;
scope_t *scope;
};
-emit_t *emit_pass1_new(qstr qstr___class__) {
+emit_t *emit_pass1_new(void) {
emit_t *emit = m_new(emit_t, 1);
- emit->qstr___class__ = qstr___class__;
return emit;
}
@@ -45,18 +43,21 @@ static void emit_pass1_load_id(emit_t *emit, qstr qstr) {
bool added;
id_info_t *id = scope_find_or_add_id(emit->scope, qstr, &added);
if (added) {
- if (strcmp(qstr_str(qstr), "super") == 0 && emit->scope->kind == SCOPE_FUNCTION) {
+#if MICROPY_EMIT_CPYTHON
+ if (qstr == MP_QSTR_super && emit->scope->kind == SCOPE_FUNCTION) {
// special case, super is a global, and also counts as use of __class__
id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT;
- id_info_t *id2 = scope_find_local_in_parent(emit->scope, emit->qstr___class__);
+ id_info_t *id2 = scope_find_local_in_parent(emit->scope, MP_QSTR___class__);
if (id2 != NULL) {
- id2 = scope_find_or_add_id(emit->scope, emit->qstr___class__, &added);
+ id2 = scope_find_or_add_id(emit->scope, MP_QSTR___class__, &added);
if (added) {
id2->kind = ID_INFO_KIND_FREE;
- scope_close_over_in_parents(emit->scope, emit->qstr___class__);
+ scope_close_over_in_parents(emit->scope, MP_QSTR___class__);
}
}
- } else {
+ } else
+#endif
+ {
id_info_t *id2 = scope_find_local_in_parent(emit->scope, qstr);
if (id2 != NULL && (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE)) {
id->kind = ID_INFO_KIND_FREE;