File tree Expand file tree Collapse file tree 4 files changed +40
-2
lines changed
test/libsolidity/semanticTests/inlineAssembly Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -3789,6 +3789,11 @@ TypeResult MappingType::interfaceType(bool _inLibrary) const
3789
3789
return this ;
3790
3790
}
3791
3791
3792
+ std::vector<std::tuple<std::string, Type const *>> MappingType::makeStackItems () const
3793
+ {
3794
+ return {std::make_tuple (" slot" , TypeProvider::uint256 ())};
3795
+ }
3796
+
3792
3797
string TypeType::richIdentifier () const
3793
3798
{
3794
3799
return " t_type" + identifierList (actualType ());
Original file line number Diff line number Diff line change @@ -1528,6 +1528,8 @@ class MappingType: public CompositeType
1528
1528
bool hasSimpleZeroValueInMemory () const override { solAssert (false , " " ); }
1529
1529
bool nameable () const override { return true ; }
1530
1530
1531
+ std::vector<std::tuple<std::string, Type const *>> makeStackItems () const override ;
1532
+
1531
1533
Type const * keyType () const { return m_keyType; }
1532
1534
Type const * valueType () const { return m_valueType; }
1533
1535
Original file line number Diff line number Diff line change @@ -173,10 +173,9 @@ struct CopyTranslate: public yul::ASTCopier
173
173
{
174
174
solAssert (suffix == " slot" || suffix == " offset" );
175
175
solAssert (varDecl->isLocalVariable ());
176
+ solAssert (!varDecl->type ()->isValueType ());
176
177
if (suffix == " slot" )
177
178
value = IRVariable{*varDecl}.part (" slot" ).name ();
178
- else if (varDecl->type ()->isValueType ())
179
- value = IRVariable{*varDecl}.part (" offset" ).name ();
180
179
else
181
180
{
182
181
solAssert (!IRVariable{*varDecl}.hasPart (" offset" ));
Original file line number Diff line number Diff line change
1
+ contract C {
2
+ mapping (uint => uint ) private m0;
3
+ mapping (uint => uint ) private m1;
4
+ mapping (uint => uint ) private m2;
5
+
6
+ function f (uint i ) public returns (uint slot , uint offset ) {
7
+ mapping (uint => uint ) storage m0Ptr = m0;
8
+ mapping (uint => uint ) storage m1Ptr = m1;
9
+ mapping (uint => uint ) storage m2Ptr = m2;
10
+
11
+ assembly {
12
+ switch i
13
+ case 1 {
14
+ slot := m1Ptr.slot
15
+ offset := m1Ptr.offset
16
+ }
17
+ case 2 {
18
+ slot := m2Ptr.slot
19
+ offset := m2Ptr.offset
20
+ }
21
+ default {
22
+ slot := m0Ptr.slot
23
+ offset := m0Ptr.offset
24
+ }
25
+ }
26
+ }
27
+ }
28
+
29
+ // ----
30
+ // f(uint256): 0 -> 0, 0
31
+ // f(uint256): 1 -> 1, 0
32
+ // f(uint256): 2 -> 2, 0
You can’t perform that action at this time.
0 commit comments