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
GitLab 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
343266ea
Commit
343266ea
authored
Dec 27, 2014
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
showbc: Refactor to allow inline instruction printing.
parent
c55a4d82
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/bc.h
+2
-0
2 additions, 0 deletions
py/bc.h
py/showbc.c
+386
-377
386 additions, 377 deletions
py/showbc.c
with
388 additions
and
377 deletions
py/bc.h
+
2
−
0
View file @
343266ea
...
...
@@ -53,6 +53,8 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_o
void
mp_setup_code_state
(
mp_code_state
*
code_state
,
mp_obj_t
self_in
,
mp_uint_t
n_args
,
mp_uint_t
n_kw
,
const
mp_obj_t
*
args
);
void
mp_bytecode_print
(
const
void
*
descr
,
mp_uint_t
n_total_args
,
const
byte
*
code
,
mp_uint_t
len
);
void
mp_bytecode_print2
(
const
byte
*
code
,
mp_uint_t
len
);
const
byte
*
mp_bytecode_print_str
(
const
byte
*
ip
);
#define mp_bytecode_print_inst(code) mp_bytecode_print2(code, 1)
// Helper macros to access pointer with least significant bits holding flags
#define MP_TAGPTR_PTR(x) ((void*)((mp_uint_t)(x) & ~((mp_uint_t)3)))
...
...
This diff is collapsed.
Click to expand it.
py/showbc.c
+
386
−
377
View file @
343266ea
...
...
@@ -57,8 +57,10 @@
ip += sizeof(mp_uint_t); \
} while (0)
static
const
byte
*
ip_start
;
void
mp_bytecode_print
(
const
void
*
descr
,
mp_uint_t
n_total_args
,
const
byte
*
ip
,
mp_uint_t
len
)
{
const
byte
*
ip_start
=
ip
;
ip_start
=
ip
;
// get code info size
const
byte
*
code_info
=
ip
;
...
...
@@ -130,12 +132,10 @@ void mp_bytecode_print(const void *descr, mp_uint_t n_total_args, const byte *ip
mp_bytecode_print2
(
ip
,
len
-
0
);
}
void
mp_bytecode_print2
(
const
byte
*
ip
,
mp_uint_t
len
)
{
const
byte
*
ip_start
=
ip
;
const
byte
*
mp_bytecode_print_str
(
const
byte
*
ip
)
{
mp_uint_t
unum
;
qstr
qstr
;
while
(
ip
-
ip_start
<
len
)
{
printf
(
"%02u "
,
(
uint
)(
ip
-
ip_start
));
switch
(
*
ip
++
)
{
case
MP_BC_LOAD_CONST_FALSE
:
printf
(
"LOAD_CONST_FALSE"
);
...
...
@@ -513,10 +513,19 @@ void mp_bytecode_print2(const byte *ip, mp_uint_t len) {
}
else
{
printf
(
"code %p, byte code 0x%02x not implemented
\n
"
,
ip
,
ip
[
-
1
]);
assert
(
0
);
return
;
return
ip
;
}
break
;
}
return
ip
;
}
void
mp_bytecode_print2
(
const
byte
*
ip
,
mp_uint_t
len
)
{
ip_start
=
ip
;
while
(
ip
-
ip_start
<
len
)
{
printf
(
"%02u "
,
(
uint
)(
ip
-
ip_start
));
ip
=
mp_bytecode_print_str
(
ip
);
printf
(
"
\n
"
);
}
}
...
...
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