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

Method analyzeLegacy

libsolidity/interface/CompilerStack.cpp:565–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563
564
565bool CompilerStack::analyzeLegacy(bool _noErrorsSoFar)
566{
567 bool noErrors = _noErrorsSoFar;
568
569 DeclarationTypeChecker declarationTypeChecker(m_errorReporter, m_evmVersion);
570 for (Source const* source: m_sourceOrder)
571 if (source->ast && !declarationTypeChecker.check(*source->ast))
572 return false;
573
574 // Requires DeclarationTypeChecker to have run
575 DocStringTagParser docStringTagParser(m_errorReporter);
576 for (Source const* source: m_sourceOrder)
577 if (source->ast && !docStringTagParser.validateDocStringsUsingTypes(*source->ast))
578 noErrors = false;
579
580 // Next, we check inheritance, overrides, function collisions and other things at
581 // contract or function level.
582 // This also calculates whether a contract is abstract, which is needed by the
583 // type checker.
584 ContractLevelChecker contractLevelChecker(m_errorReporter);
585
586 for (Source const* source: m_sourceOrder)
587 if (auto sourceAst = source->ast)
588 noErrors = contractLevelChecker.check(*sourceAst);
589
590 // Now we run full type checks that go down to the expression level. This
591 // cannot be done earlier, because we need cross-contract types and information
592 // about whether a contract is abstract for the `new` expression.
593 // This populates the `type` annotation for all expressions.
594 //
595 // Note: this does not resolve overloaded functions. In order to do that, types of arguments are needed,
596 // which is only done one step later.
597 TypeChecker typeChecker(m_evmVersion, m_eofVersion, m_errorReporter);
598 for (Source const* source: m_sourceOrder)
599 if (source->ast && !typeChecker.checkTypeRequirements(*source->ast))
600 noErrors = false;
601
602 if (noErrors)
603 {
604 // Requires ContractLevelChecker and TypeChecker
605 DocStringAnalyser docStringAnalyser(m_errorReporter);
606 for (Source const* source: m_sourceOrder)
607 if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast))
608 noErrors = false;
609 }
610
611 if (noErrors)
612 {
613 // Checks that can only be done when all types of all AST nodes are known.
614 PostTypeChecker postTypeChecker(m_errorReporter);
615 for (Source const* source: m_sourceOrder)
616 if (source->ast && !postTypeChecker.check(*source->ast))
617 noErrors = false;
618 if (!postTypeChecker.finalize())
619 noErrors = false;
620 }
621
622 // Create & assign callgraphs and check for contract dependency cycles

Callers

nothing calls this directly

Calls 15

ImmutableValidatorClass · 0.85
ViewPureCheckerClass · 0.85
applyMapFunction · 0.85
checkTypeRequirementsMethod · 0.80
analyseDocStringsMethod · 0.80
nodesMethod · 0.80
constructFlowMethod · 0.80
checkMethod · 0.45
finalizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected