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

Method endVisit

libsolidity/codegen/ExpressionCompiler.cpp:2381–2446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2379}
2380
2381void ExpressionCompiler::endVisit(Identifier const& _identifier)
2382{
2383 CompilerContext::LocationSetter locationSetter(m_context, _identifier);
2384 Declaration const* declaration = _identifier.annotation().referencedDeclaration;
2385 if (MagicVariableDeclaration const* magicVar = dynamic_cast<MagicVariableDeclaration const*>(declaration))
2386 {
2387 switch (magicVar->type()->category())
2388 {
2389 case Type::Category::Contract:
2390 if (dynamic_cast<ContractType const*>(magicVar->type()))
2391 {
2392 solAssert(_identifier.name() == "this", "");
2393 m_context << Instruction::ADDRESS;
2394 }
2395 break;
2396 default:
2397 break;
2398 }
2399 }
2400 else if (FunctionDefinition const* functionDef = dynamic_cast<FunctionDefinition const*>(declaration))
2401 {
2402 solAssert(*_identifier.annotation().requiredLookup == VirtualLookup::Virtual, "");
2403 utils().pushCombinedFunctionEntryLabel(
2404 functionDef->resolveVirtual(m_context.mostDerivedContract()),
2405 // If we call directly, do not include the second (potential runtime) label.
2406 // Including the label might lead to the runtime code being included in the creation
2407 // code even though it is never executed.
2408 !_identifier.annotation().calledDirectly
2409 );
2410 }
2411 else if (auto variable = dynamic_cast<VariableDeclaration const*>(declaration))
2412 appendVariable(*variable, static_cast<Expression const&>(_identifier));
2413 else if (auto contract = dynamic_cast<ContractDefinition const*>(declaration))
2414 {
2415 if (contract->isLibrary())
2416 m_context.appendLibraryAddress(contract->fullyQualifiedName());
2417 }
2418 else if (dynamic_cast<EventDefinition const*>(declaration))
2419 {
2420 // no-op
2421 }
2422 else if (dynamic_cast<ErrorDefinition const*>(declaration))
2423 {
2424 // no-op
2425 }
2426 else if (dynamic_cast<EnumDefinition const*>(declaration))
2427 {
2428 // no-op
2429 }
2430 else if (dynamic_cast<UserDefinedValueTypeDefinition const*>(declaration))
2431 {
2432 // no-op
2433 }
2434 else if (dynamic_cast<StructDefinition const*>(declaration))
2435 {
2436 // no-op
2437 }
2438 else if (dynamic_cast<ImportDirective const*>(declaration))

Callers

nothing calls this directly

Calls 8

isLibraryMethod · 0.80
fullyQualifiedNameMethod · 0.80
categoryMethod · 0.45
typeMethod · 0.45
nameMethod · 0.45
appendLibraryAddressMethod · 0.45
literalValueMethod · 0.45

Tested by

no test coverage detected