@@ -109,16 +109,14 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json)
109
109
std::string name = getOrDefault<std::string>(_json, " name" , " " );
110
110
solAssert (!name.empty ());
111
111
112
- int begin = get<int >(_json, " begin" );
113
- int end = get<int >(_json, " end" );
112
+ SourceLocation location;
113
+ location.start = get<int >(_json, " begin" );
114
+ location.end = get<int >(_json, " end" );
114
115
int srcIndex = get<int >(_json, " source" );
115
116
size_t modifierDepth = static_cast <size_t >(getOrDefault<int >(_json, " modifierDepth" , 0 ));
116
117
std::string value = getOrDefault<std::string>(_json, " value" , " " );
117
118
std::string jumpType = getOrDefault<std::string>(_json, " jumpType" , " " );
118
119
119
- SourceLocation location;
120
- location.start = begin;
121
- location.end = end;
122
120
123
121
auto updateUsedTags = [&](u256 const & data) {
124
122
m_usedTags = max (m_usedTags, static_cast <unsigned >(data) + 1 );
@@ -142,10 +140,9 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json)
142
140
143
141
AssemblyItem result (0 );
144
142
145
- if (c_instructions.find (name) != c_instructions. end ( ))
143
+ if (c_instructions.count (name))
146
144
{
147
145
AssemblyItem item{c_instructions.at (name), location};
148
- item.m_modifierDepth = modifierDepth;
149
146
if (!jumpType.empty ())
150
147
item.setJumpType (jumpType);
151
148
result = item;
@@ -154,42 +151,42 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json)
154
151
{
155
152
if (name == " PUSH" )
156
153
{
157
- AssemblyItem item{AssemblyItemType::Push, u256 (" 0x" + value), location };
154
+ AssemblyItem item{AssemblyItemType::Push, u256 (" 0x" + value)};
158
155
if (!jumpType.empty ())
159
156
item.setJumpType (jumpType);
160
157
result = item;
161
158
}
162
159
else if (name == " PUSH [ErrorTag]" )
163
- result = {AssemblyItemType::PushTag, 0 , location };
160
+ result = {AssemblyItemType::PushTag, 0 };
164
161
else if (name == " PUSH [tag]" )
165
- result = {AssemblyItemType::PushTag, updateUsedTags (u256 (value)), location };
162
+ result = {AssemblyItemType::PushTag, updateUsedTags (u256 (value))};
166
163
else if (name == " PUSH [$]" )
167
- result = {AssemblyItemType::PushSub, u256 (" 0x" + value), location };
164
+ result = {AssemblyItemType::PushSub, u256 (" 0x" + value)};
168
165
else if (name == " PUSH #[$]" )
169
- result = {AssemblyItemType::PushSubSize, u256 (" 0x" + value), location };
166
+ result = {AssemblyItemType::PushSubSize, u256 (" 0x" + value)};
170
167
else if (name == " PUSHSIZE" )
171
- result = {AssemblyItemType::PushProgramSize, 0 , location };
168
+ result = {AssemblyItemType::PushProgramSize, 0 };
172
169
else if (name == " PUSHLIB" )
173
- result = {AssemblyItemType::PushLibraryAddress, libraryHash (value), location };
170
+ result = {AssemblyItemType::PushLibraryAddress, libraryHash (value)};
174
171
else if (name == " PUSHDEPLOYADDRESS" )
175
- result = {AssemblyItemType::PushDeployTimeAddress, 0 , location };
172
+ result = {AssemblyItemType::PushDeployTimeAddress, 0 };
176
173
else if (name == " PUSHIMMUTABLE" )
177
- result = {AssemblyItemType::PushImmutable, immutableHash (value), location };
174
+ result = {AssemblyItemType::PushImmutable, immutableHash (value)};
178
175
else if (name == " ASSIGNIMMUTABLE" )
179
- result = {AssemblyItemType::AssignImmutable, immutableHash (value), location };
176
+ result = {AssemblyItemType::AssignImmutable, immutableHash (value)};
180
177
else if (name == " tag" )
181
- result = {AssemblyItemType::Tag, updateUsedTags (u256 (value)), location };
178
+ result = {AssemblyItemType::Tag, updateUsedTags (u256 (value))};
182
179
else if (name == " PUSH data" )
183
- result = {AssemblyItemType::PushData, u256 (" 0x" + value), location };
180
+ result = {AssemblyItemType::PushData, u256 (" 0x" + value)};
184
181
else if (name == " VERBATIM" )
185
182
{
186
183
AssemblyItem item (fromHex (value), 0 , 0 );
187
- item.setLocation (location);
188
184
result = item;
189
185
}
190
186
else
191
187
assertThrow (false , InvalidOpcode, " " );
192
188
}
189
+ result.setLocation (location);
193
190
result.m_modifierDepth = modifierDepth;
194
191
return result;
195
192
}
0 commit comments