Skip to content
Snippets Groups Projects
Commit eacbd7ae authored by Damien George's avatar Damien George
Browse files

py: Fix constant folding and inline-asm to work with new async grammar.

parent 81ebba7e
No related branches found
No related tags found
No related merge requests found
...@@ -1402,8 +1402,7 @@ STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { ...@@ -1402,8 +1402,7 @@ STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1]; mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1];
if (MP_PARSE_NODE_IS_ID(pns_it->nodes[0]) if (MP_PARSE_NODE_IS_ID(pns_it->nodes[0])
&& MP_PARSE_NODE_LEAF_ARG(pns_it->nodes[0]) == MP_QSTR_range && MP_PARSE_NODE_LEAF_ARG(pns_it->nodes[0]) == MP_QSTR_range
&& MP_PARSE_NODE_IS_STRUCT_KIND(pns_it->nodes[1], PN_trailer_paren) && MP_PARSE_NODE_IS_STRUCT_KIND(pns_it->nodes[1], PN_trailer_paren)) {
&& MP_PARSE_NODE_IS_NULL(pns_it->nodes[2])) {
mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0]; mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0];
mp_parse_node_t *args; mp_parse_node_t *args;
int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args); int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args);
...@@ -3186,7 +3185,6 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind ...@@ -3186,7 +3185,6 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns2->nodes[1], PN_trailer_paren)) { if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns2->nodes[1], PN_trailer_paren)) {
goto not_an_instruction; goto not_an_instruction;
} }
assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[2]));
// parse node looks like an instruction // parse node looks like an instruction
// get instruction name and args // get instruction name and args
......
...@@ -563,11 +563,10 @@ STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args ...@@ -563,11 +563,10 @@ STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args
// this node is of the form <x> = <y> // this node is of the form <x> = <y>
mp_parse_node_t pn0 = peek_result(parser, 1); mp_parse_node_t pn0 = peek_result(parser, 1);
if (MP_PARSE_NODE_IS_ID(pn0) if (MP_PARSE_NODE_IS_ID(pn0)
&& MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_power) && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_atom_expr_normal)
&& MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t*)pn1)->nodes[0]) && MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t*)pn1)->nodes[0])
&& MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn1)->nodes[0]) == MP_QSTR_const && MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn1)->nodes[0]) == MP_QSTR_const
&& MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t*)pn1)->nodes[1], RULE_trailer_paren) && MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t*)pn1)->nodes[1], RULE_trailer_paren)
&& MP_PARSE_NODE_IS_NULL(((mp_parse_node_struct_t*)pn1)->nodes[2])
) { ) {
// code to assign dynamic constants: id = const(value) // code to assign dynamic constants: id = const(value)
...@@ -599,13 +598,11 @@ STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args ...@@ -599,13 +598,11 @@ STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args
#endif #endif
#if MICROPY_COMP_MODULE_CONST #if MICROPY_COMP_MODULE_CONST
} else if (rule->rule_id == RULE_power) { } else if (rule->rule_id == RULE_atom_expr_normal) {
mp_parse_node_t pn0 = peek_result(parser, 2); mp_parse_node_t pn0 = peek_result(parser, 1);
mp_parse_node_t pn1 = peek_result(parser, 1); mp_parse_node_t pn1 = peek_result(parser, 0);
mp_parse_node_t pn2 = peek_result(parser, 0);
if (!(MP_PARSE_NODE_IS_ID(pn0) if (!(MP_PARSE_NODE_IS_ID(pn0)
&& MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period) && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period))) {
&& MP_PARSE_NODE_IS_NULL(pn2))) {
return false; return false;
} }
// id1.id2 // id1.id2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment