Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
708c0732
Commit
708c0732
authored
Apr 27, 2014
by
Damien George
Browse files
py: Add '*' qstr for 'import *'; use blank qstr for comprehension arg.
parent
968bf34c
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/compile.c
View file @
708c0732
...
...
@@ -1416,7 +1416,7 @@ void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
#if MICROPY_EMIT_CPYTHON
EMIT_ARG
(
load_const_verbatim_str
,
"('*',)"
);
#else
EMIT_ARG
(
load_const_str
,
QSTR_
FROM_STR_STATIC
(
"*"
)
,
false
);
EMIT_ARG
(
load_const_str
,
MP_
QSTR_
_star_
,
false
);
EMIT_ARG
(
build_tuple
,
1
);
#endif
...
...
@@ -3040,7 +3040,15 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
assert
(
MP_PARSE_NODE_IS_STRUCT_KIND
(
pns
->
nodes
[
1
],
PN_comp_for
));
mp_parse_node_struct_t
*
pns_comp_for
=
(
mp_parse_node_struct_t
*
)
pns
->
nodes
[
1
];
// We need a unique name for the comprehension argument (the iterator).
// CPython uses .0, but we should be able to use anything that won't
// clash with a user defined variable. Best to use an existing qstr,
// so we use the blank qstr.
#if MICROPY_EMIT_CPYTHON
qstr
qstr_arg
=
QSTR_FROM_STR_STATIC
(
".0"
);
#else
qstr
qstr_arg
=
MP_QSTR_
;
#endif
if
(
comp
->
pass
==
PASS_1
)
{
bool
added
;
id_info_t
*
id_info
=
scope_find_or_add_id
(
comp
->
scope_cur
,
qstr_arg
,
&
added
);
...
...
py/makeqstrdata.py
View file @
708c0732
...
...
@@ -20,6 +20,7 @@ codepoint2name[ord('%')] = 'percent'
codepoint2name
[
ord
(
'#'
)]
=
'hash'
codepoint2name
[
ord
(
'{'
)]
=
'brace_open'
codepoint2name
[
ord
(
'}'
)]
=
'brace_close'
codepoint2name
[
ord
(
'*'
)]
=
'star'
# this must match the equivalent function in qstr.c
def
compute_hash
(
qstr
):
...
...
py/qstrdefs.h
View file @
708c0732
...
...
@@ -2,6 +2,9 @@
// All the qstr definitions in this file are available as constants.
// That is, they are in ROM and you can reference them simply as MP_QSTR_xxxx.
// TODO probably should add Python keywords, eg if, def, etc
Q
(
*
)
Q
(
__build_class__
)
Q
(
__class__
)
Q
(
__doc__
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment