Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
da1ce93d
Commit
da1ce93d
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
Implement "from module import *" construct.
parent
a8d404e0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
py/runtime.c
+11
-0
11 additions, 0 deletions
py/runtime.c
py/runtime.h
+1
-0
1 addition, 0 deletions
py/runtime.h
py/showbc.c
+4
-0
4 additions, 0 deletions
py/showbc.c
py/vm.c
+4
-0
4 additions, 0 deletions
py/vm.c
with
20 additions
and
0 deletions
py/runtime.c
+
11
−
0
View file @
da1ce93d
...
...
@@ -1016,6 +1016,17 @@ mp_obj_t rt_import_from(mp_obj_t module, qstr name) {
return
x
;
}
void
rt_import_all
(
mp_obj_t
module
)
{
DEBUG_printf
(
"import all %p
\n
"
,
module
);
mp_map_t
*
map
=
mp_obj_module_get_globals
(
module
);
for
(
uint
i
=
0
;
i
<
map
->
alloc
;
i
++
)
{
if
(
map
->
table
[
i
].
key
!=
MP_OBJ_NULL
)
{
rt_store_name
(
MP_OBJ_QSTR_VALUE
(
map
->
table
[
i
].
key
),
map
->
table
[
i
].
value
);
}
}
}
mp_map_t
*
rt_locals_get
(
void
)
{
return
map_locals
;
}
...
...
This diff is collapsed.
Click to expand it.
py/runtime.h
+
1
−
0
View file @
da1ce93d
...
...
@@ -39,6 +39,7 @@ mp_obj_t rt_getiter(mp_obj_t o);
mp_obj_t
rt_iternext
(
mp_obj_t
o
);
mp_obj_t
rt_import_name
(
qstr
name
,
mp_obj_t
fromlist
,
mp_obj_t
level
);
mp_obj_t
rt_import_from
(
mp_obj_t
module
,
qstr
name
);
void
rt_import_all
(
mp_obj_t
module
);
struct
_mp_map_t
;
struct
_mp_map_t
*
rt_locals_get
(
void
);
...
...
This diff is collapsed.
Click to expand it.
py/showbc.c
+
4
−
0
View file @
da1ce93d
...
...
@@ -390,6 +390,10 @@ void mp_byte_code_print(const byte *ip, int len) {
printf
(
"IMPORT_FROM %s"
,
qstr_str
(
qstr
));
break
;
case
MP_BC_IMPORT_STAR
:
printf
(
"IMPORT_STAR"
);
break
;
default:
printf
(
"code %p, byte code 0x%02x not implemented
\n
"
,
ip
,
op
);
assert
(
0
);
...
...
This diff is collapsed.
Click to expand it.
py/vm.c
+
4
−
0
View file @
da1ce93d
...
...
@@ -595,6 +595,10 @@ unwind_return:
PUSH
(
obj1
);
break
;
case
MP_BC_IMPORT_STAR
:
rt_import_all
(
TOP
());
break
;
default:
printf
(
"code %p, byte code 0x%02x not implemented
\n
"
,
ip
,
op
);
assert
(
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment