Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
747c0ad1
Commit
747c0ad1
authored
Aug 02, 2016
by
Kevin Modzelewski
Committed by
GitHub
Aug 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1302 from sizeoftank/literals_order_issue1191
Fix evaluation order for dict operations
parents
84b0c7be
7895da83
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
9 deletions
+29
-9
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-1
src/core/cfg.cpp
src/core/cfg.cpp
+28
-6
test/tests/literals_order.py
test/tests/literals_order.py
+0
-2
No files found.
src/codegen/irgen/irgenerator.cpp
View file @
747c0ad1
...
...
@@ -1253,8 +1253,8 @@ private:
static
BoxedString
*
setitem_str
=
getStaticString
(
"__setitem__"
);
CompilerVariable
*
setitem
=
rtn
->
getattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
setitem_str
,
true
);
for
(
int
i
=
0
;
i
<
node
->
keys
.
size
();
i
++
)
{
CompilerVariable
*
key
=
evalExpr
(
node
->
keys
[
i
],
unw_info
);
CompilerVariable
*
value
=
evalExpr
(
node
->
values
[
i
],
unw_info
);
CompilerVariable
*
key
=
evalExpr
(
node
->
keys
[
i
],
unw_info
);
assert
(
key
);
assert
(
value
);
...
...
src/core/cfg.cpp
View file @
747c0ad1
...
...
@@ -622,6 +622,24 @@ private:
return
compare
;
}
AST_Index
*
makeIndex
(
AST_expr
*
value
)
{
auto
index
=
new
AST_Index
();
index
->
value
=
value
;
index
->
lineno
=
value
->
lineno
;
index
->
col_offset
=
value
->
col_offset
;
return
index
;
}
AST_Subscript
*
makeSubscript
(
AST_TYPE
::
AST_TYPE
ctx_type
,
AST_expr
*
value
,
AST_slice
*
slice
)
{
auto
subscript
=
new
AST_Subscript
();
subscript
->
ctx_type
=
ctx_type
;
subscript
->
value
=
value
;
subscript
->
slice
=
slice
;
subscript
->
lineno
=
slice
->
lineno
;
subscript
->
col_offset
=
slice
->
col_offset
;
return
subscript
;
}
void
pushAssign
(
AST_expr
*
target
,
AST_expr
*
val
)
{
AST_Assign
*
assign
=
new
AST_Assign
();
assign
->
value
=
val
;
...
...
@@ -980,14 +998,18 @@ private:
rtn
->
lineno
=
node
->
lineno
;
rtn
->
col_offset
=
node
->
col_offset
;
for
(
auto
k
:
node
->
keys
)
{
rtn
->
keys
.
push_back
(
remapExpr
(
k
));
}
for
(
auto
v
:
node
->
values
)
{
rtn
->
values
.
push_back
(
remapExpr
(
v
));
InternedString
dict_name
=
nodeName
();
pushAssign
(
dict_name
,
rtn
);
for
(
int
i
=
0
;
i
<
node
->
keys
.
size
();
i
++
)
{
AST_expr
*
value
=
remapExpr
(
node
->
values
[
i
]);
AST_Index
*
index
=
makeIndex
(
node
->
keys
[
i
]);
AST_Subscript
*
subscript
=
makeSubscript
(
AST_TYPE
::
Store
,
makeLoad
(
dict_name
,
node
,
false
),
index
);
pushAssign
(
remapSubscript
(
subscript
),
value
);
}
return
rtn
;
return
makeLoad
(
dict_name
,
node
,
true
)
;
}
AST_slice
*
remapEllipsis
(
AST_Ellipsis
*
node
)
{
return
node
;
}
...
...
test/tests/literals_order.py
View file @
747c0ad1
# expected: fail
# - the CFG expands to the wrong code here
class
H
(
object
):
def
__init__
(
self
,
n
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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