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
bcbeea0a
Commit
bcbeea0a
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Fix bug where == and != not handled for small_ints.
parent
cf11c961
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/runtime.c
+29
-29
29 additions, 29 deletions
py/runtime.c
with
29 additions
and
29 deletions
py/runtime.c
+
29
−
29
View file @
bcbeea0a
...
@@ -467,6 +467,35 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
...
@@ -467,6 +467,35 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
// then fail
// then fail
// note that list does not implement + or +=, so that inplace_concat is reached first for +=
// note that list does not implement + or +=, so that inplace_concat is reached first for +=
// deal with == and != for all types
if
(
op
==
RT_COMPARE_OP_EQUAL
||
op
==
RT_COMPARE_OP_NOT_EQUAL
)
{
if
(
mp_obj_equal
(
lhs
,
rhs
))
{
if
(
op
==
RT_COMPARE_OP_EQUAL
)
{
return
mp_const_true
;
}
else
{
return
mp_const_false
;
}
}
else
{
if
(
op
==
RT_COMPARE_OP_EQUAL
)
{
return
mp_const_false
;
}
else
{
return
mp_const_true
;
}
}
}
// deal with exception_match for all types
if
(
op
==
RT_COMPARE_OP_EXCEPTION_MATCH
)
{
// TODO properly! at the moment it just compares the exception identifier for equality
if
(
MP_OBJ_IS_TYPE
(
lhs
,
&
exception_type
)
&&
MP_OBJ_IS_TYPE
(
rhs
,
&
exception_type
))
{
if
(
mp_obj_exception_get_type
(
lhs
)
==
mp_obj_exception_get_type
(
rhs
))
{
return
mp_const_true
;
}
else
{
return
mp_const_false
;
}
}
}
if
(
MP_OBJ_IS_SMALL_INT
(
lhs
))
{
if
(
MP_OBJ_IS_SMALL_INT
(
lhs
))
{
mp_small_int_t
lhs_val
=
MP_OBJ_SMALL_INT_VALUE
(
lhs
);
mp_small_int_t
lhs_val
=
MP_OBJ_SMALL_INT_VALUE
(
lhs
);
if
(
MP_OBJ_IS_SMALL_INT
(
rhs
))
{
if
(
MP_OBJ_IS_SMALL_INT
(
rhs
))
{
...
@@ -530,35 +559,6 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
...
@@ -530,35 +559,6 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
return
mp_obj_complex_binary_op
(
op
,
lhs_val
,
0
,
rhs
);
return
mp_obj_complex_binary_op
(
op
,
lhs_val
,
0
,
rhs
);
}
}
}
else
{
}
else
{
// deal with == and !=
if
(
op
==
RT_COMPARE_OP_EQUAL
||
op
==
RT_COMPARE_OP_NOT_EQUAL
)
{
if
(
mp_obj_equal
(
lhs
,
rhs
))
{
if
(
op
==
RT_COMPARE_OP_EQUAL
)
{
return
mp_const_true
;
}
else
{
return
mp_const_false
;
}
}
else
{
if
(
op
==
RT_COMPARE_OP_EQUAL
)
{
return
mp_const_false
;
}
else
{
return
mp_const_true
;
}
}
}
// deal with exception_match
if
(
op
==
RT_COMPARE_OP_EXCEPTION_MATCH
)
{
// TODO properly! at the moment it just compares the exception identifier for equality
if
(
MP_OBJ_IS_TYPE
(
lhs
,
&
exception_type
)
&&
MP_OBJ_IS_TYPE
(
rhs
,
&
exception_type
))
{
if
(
mp_obj_exception_get_type
(
lhs
)
==
mp_obj_exception_get_type
(
rhs
))
{
return
mp_const_true
;
}
else
{
return
mp_const_false
;
}
}
}
if
(
MP_OBJ_IS_OBJ
(
lhs
))
{
if
(
MP_OBJ_IS_OBJ
(
lhs
))
{
mp_obj_base_t
*
o
=
lhs
;
mp_obj_base_t
*
o
=
lhs
;
if
(
o
->
type
->
binary_op
!=
NULL
)
{
if
(
o
->
type
->
binary_op
!=
NULL
)
{
...
...
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