MCPcopy Create free account
hub / github.com/argotorg/solidity / initializeLocalVar

Method initializeLocalVar

libsolidity/codegen/ir/IRGeneratorForStatements.cpp:292–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292void IRGeneratorForStatements::initializeLocalVar(VariableDeclaration const& _varDecl)
293{
294 try
295 {
296 setLocation(_varDecl);
297
298 solAssert(m_context.isLocalVariable(_varDecl), "Must be a local variable.");
299
300 auto const* type = _varDecl.type();
301 if (dynamic_cast<MappingType const*>(type))
302 return;
303 else if (auto const* refType = dynamic_cast<ReferenceType const*>(type))
304 if (refType->dataStoredIn(DataLocation::Storage) && refType->isPointer())
305 return;
306
307 IRVariable zero = zeroValue(*type);
308 assign(m_context.localVariable(_varDecl), zero);
309 }
310 catch (langutil::UnimplementedFeatureError const& _error)
311 {
312 if (!boost::get_error_info<langutil::errinfo_sourceLocation>(_error))
313 _error << langutil::errinfo_sourceLocation(m_currentLocation);
314 BOOST_THROW_EXCEPTION(_error);
315 }
316}
317
318IRVariable IRGeneratorForStatements::evaluateExpression(Expression const& _expression, Type const& _targetType)
319{

Callers 1

Calls 6

zeroValueFunction · 0.85
isPointerMethod · 0.80
isLocalVariableMethod · 0.45
typeMethod · 0.45
dataStoredInMethod · 0.45
localVariableMethod · 0.45

Tested by

no test coverage detected