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
e6ce10a3
Commit
e6ce10a3
authored
Sep 6, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Native emitter now supports delete name & global, and end finally.
parent
17598d49
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/emitnative.c
+21
-23
21 additions, 23 deletions
py/emitnative.c
py/nativeglue.c
+2
-0
2 additions, 0 deletions
py/nativeglue.c
py/runtime0.h
+2
-0
2 additions, 0 deletions
py/runtime0.h
with
25 additions
and
23 deletions
py/emitnative.c
+
21
−
23
View file @
e6ce10a3
...
...
@@ -531,7 +531,7 @@ STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int re
}
}
STATIC
void
emit_pre_pop_discard
(
emit_t
*
emit
,
vtype_kind_t
*
vtype
)
{
STATIC
void
emit_pre_pop_discard
(
emit_t
*
emit
)
{
emit
->
last_emit_was_return_value
=
false
;
adjust_stack
(
emit
,
-
1
);
}
...
...
@@ -1040,34 +1040,32 @@ STATIC void emit_native_store_subscr(emit_t *emit) {
emit_call
(
emit
,
MP_F_OBJ_SUBSCR
);
}
STATIC
void
emit_native_delete_fast
(
emit_t
*
emit
,
qstr
qst
r
,
int
local_num
)
{
//
not
implement
ed
STATIC
void
emit_native_delete_fast
(
emit_t
*
emit
,
qstr
qst
,
int
local_num
)
{
//
TODO
implement
me!
// could support for Python types, just set to None (so GC can reclaim it)
assert
(
0
);
}
STATIC
void
emit_native_delete_deref
(
emit_t
*
emit
,
qstr
qstr
,
int
local_num
)
{
// not supported
assert
(
0
);
STATIC
void
emit_native_delete_deref
(
emit_t
*
emit
,
qstr
qst
,
int
local_num
)
{
// TODO implement me!
}
STATIC
void
emit_native_delete_name
(
emit_t
*
emit
,
qstr
qst
r
)
{
// not implemented
// use mp_delete_name
assert
(
0
);
STATIC
void
emit_native_delete_name
(
emit_t
*
emit
,
qstr
qst
)
{
emit_native_pre
(
emit
);
emit_call_with_imm_arg
(
emit
,
MP_F_DELETE_NAME
,
qst
,
REG_ARG_1
);
emit_post
(
emit
);
}
STATIC
void
emit_native_delete_global
(
emit_t
*
emit
,
qstr
qst
r
)
{
// not implemented
// use mp_delete_global
assert
(
0
);
STATIC
void
emit_native_delete_global
(
emit_t
*
emit
,
qstr
qst
)
{
emit_native_pre
(
emit
);
emit_call_with_imm_arg
(
emit
,
MP_F_DELETE_GLOBAL
,
qst
,
REG_ARG_1
);
emit_post
(
emit
);
}
STATIC
void
emit_native_delete_attr
(
emit_t
*
emit
,
qstr
qst
r
)
{
STATIC
void
emit_native_delete_attr
(
emit_t
*
emit
,
qstr
qst
)
{
vtype_kind_t
vtype_base
;
emit_pre_pop_reg
(
emit
,
&
vtype_base
,
REG_ARG_1
);
// arg1 = base
assert
(
vtype_base
==
VTYPE_PYOBJ
);
emit_call_with_2_imm_args
(
emit
,
MP_F_STORE_ATTR
,
qst
r
,
REG_ARG_2
,
(
mp_uint_t
)
MP_OBJ_NULL
,
REG_ARG_3
);
// arg2 = attribute name, arg3 = value (null for delete)
emit_call_with_2_imm_args
(
emit
,
MP_F_STORE_ATTR
,
qst
,
REG_ARG_2
,
(
mp_uint_t
)
MP_OBJ_NULL
,
REG_ARG_3
);
// arg2 = attribute name, arg3 = value (null for delete)
emit_post
(
emit
);
}
...
...
@@ -1092,8 +1090,7 @@ STATIC void emit_native_dup_top_two(emit_t *emit) {
}
STATIC
void
emit_native_pop_top
(
emit_t
*
emit
)
{
vtype_kind_t
vtype
;
emit_pre_pop_discard
(
emit
,
&
vtype
);
emit_pre_pop_discard
(
emit
);
emit_post
(
emit
);
}
...
...
@@ -1243,11 +1240,12 @@ STATIC void emit_native_setup_except(emit_t *emit, uint label) {
}
STATIC
void
emit_native_setup_finally
(
emit_t
*
emit
,
uint
label
)
{
assert
(
0
);
emit_native_setup_except
(
emit
,
label
);
}
STATIC
void
emit_native_end_finally
(
emit_t
*
emit
)
{
//assert(0);
emit_pre_pop_discard
(
emit
);
emit_post
(
emit
);
}
STATIC
void
emit_native_get_iter
(
emit_t
*
emit
)
{
...
...
@@ -1608,12 +1606,12 @@ STATIC void emit_native_start_except_handler(emit_t *emit) {
adjust_stack
(
emit
,
2
);
vtype_kind_t
vtype_nlr
;
emit_pre_pop_reg
(
emit
,
&
vtype_nlr
,
REG_ARG_1
);
// get the thrown value
emit_pre_pop_discard
(
emit
,
&
vtype_nlr
);
// discard the linked-list pointer in the nlr_buf
emit_pre_pop_discard
(
emit
);
// discard the linked-list pointer in the nlr_buf
emit_post_push_reg_reg_reg
(
emit
,
VTYPE_PYOBJ
,
REG_ARG_1
,
VTYPE_PYOBJ
,
REG_ARG_1
,
VTYPE_PYOBJ
,
REG_ARG_1
);
// push the 3 exception items
}
STATIC
void
emit_native_end_except_handler
(
emit_t
*
emit
)
{
adjust_stack
(
emit
,
-
3
);
// stack adjust (not sure why it's this much...)
adjust_stack
(
emit
,
-
2
);
}
const
emit_method_table_t
EXPORT_FUN
(
method_table
)
=
{
...
...
This diff is collapsed.
Click to expand it.
py/nativeglue.c
+
2
−
0
View file @
e6ce10a3
...
...
@@ -125,6 +125,8 @@ void *const mp_fun_table[MP_F_NUMBER_OF] = {
#endif
mp_unpack_sequence
,
mp_unpack_ex
,
mp_delete_name
,
mp_delete_global
,
};
/*
...
...
This diff is collapsed.
Click to expand it.
py/runtime0.h
+
2
−
0
View file @
e6ce10a3
...
...
@@ -145,6 +145,8 @@ typedef enum {
#endif
MP_F_UNPACK_SEQUENCE
,
MP_F_UNPACK_EX
,
MP_F_DELETE_NAME
,
MP_F_DELETE_GLOBAL
,
MP_F_NUMBER_OF
,
}
mp_fun_kind_t
;
...
...
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