summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-12-21 17:44:27 +0000
committerDamien George <damien.p.george@gmail.com>2014-12-21 17:44:27 +0000
commit01039b5bd8297e4a0393da26710f7ec99b7b8749 (patch)
tree124b7f895df8cea399f5bc25c8858e29ac57279c
parent584ba6762f5f41b3ebaabc060d0db18b7954103f (diff)
downloadmicropython-01039b5bd8297e4a0393da26710f7ec99b7b8749.tar.gz
micropython-01039b5bd8297e4a0393da26710f7ec99b7b8749.zip
py: Remove last uses of printf from compile; use proper SyntaxError.
-rw-r--r--py/compile.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/py/compile.c b/py/compile.c
index 072580a01f..7cecf279b2 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -2490,20 +2490,16 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
// this is to handle special super() call
if (MP_PARSE_NODE_IS_NULL(pn_arglist) && comp->func_arg_is_super && comp->scope_cur->kind == SCOPE_FUNCTION) {
EMIT_ARG(load_id, MP_QSTR___class__);
- // get first argument to function
- bool found = false;
+ // look for first argument to function (assumes it's "self")
for (int i = 0; i < comp->scope_cur->id_info_len; i++) {
if (comp->scope_cur->id_info[i].flags & ID_FLAG_IS_PARAM) {
+ // first argument found; load it and call super
EMIT_ARG(load_fast, MP_QSTR_, comp->scope_cur->id_info[i].flags, comp->scope_cur->id_info[i].local_num);
- found = true;
- break;
+ EMIT_ARG(call_function, 2, 0, 0);
+ return;
}
}
- if (!found) {
- printf("TypeError: super() call cannot find self\n");
- return;
- }
- EMIT_ARG(call_function, 2, 0, 0);
+ compile_syntax_error(comp, MP_PARSE_NODE_NULL, "super() call cannot find self"); // really a TypeError
return;
}
#endif
@@ -2972,8 +2968,8 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
} else {
compile_function_t f = compile_function[MP_PARSE_NODE_STRUCT_KIND(pns)];
if (f == NULL) {
- printf("node %u cannot be compiled\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns));
#if MICROPY_DEBUG_PRINTERS
+ printf("node %u cannot be compiled\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns));
mp_parse_node_print(pn, 0);
#endif
compile_syntax_error(comp, pn, "internal compiler error");
@@ -3377,7 +3373,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
comp->next_label = 1;
if (scope->kind != SCOPE_FUNCTION) {
- printf("Error: inline assembler must be a function\n");
+ compile_syntax_error(comp, MP_PARSE_NODE_NULL, "inline assembler must be a function");
return;
}