Skip to content

Properly explain all the analsys steps in CompilerStack#4327

Merged
chriseth merged 1 commit intodevelopfrom
document-internals
Aug 2, 2018
Merged

Properly explain all the analsys steps in CompilerStack#4327
chriseth merged 1 commit intodevelopfrom
document-internals

Conversation

@axic
Copy link
Copy Markdown
Contributor

@axic axic commented Jun 20, 2018

No description provided.

@axic axic requested a review from chriseth June 20, 2018 21:21
@axic
Copy link
Copy Markdown
Contributor Author

axic commented Jun 20, 2018

@chriseth this is not ready to be merged, but please comment on lines which has question marks (some of them were just placeholders because we talked about them)

/// @returns the metadata JSON as a compact string for the given contract.
std::string createMetadata(Contract const& _contract) const;

/// @returns the computer source mapping string.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

computer -> computed

virtual void endVisitNode(ASTNode&) { }
};

// Post visitor. endVisit ensure the child types are already visited
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Post visitor, or did you meant to write Const visitor? I don't understand the second sentence.

appendDelegatecallCheck();

initializeContext(_contract, _contracts);
// This generate the dispatch function for externally visible functions
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: generates

// and adds the function to the compilation (also internal functions,
// which are referenced directly or indirectly will be added to the same queue).
appendFunctionSelector(_contract);
// Compile functions listed in the above populated queue.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This processes the queue until it is empty.

return false;

// This is the main name and type resolution loop. Needs to be run for every contract, because
// the special variables "this" and "super" must be set appropriately.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change that at some point and move this logic into the resolver.

m_contracts[contract->fullyQualifiedName()].contract = contract;
}

// WHy cannot be this done in the above loop?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple answer: If we do it in the above loop, it is not possible to resolve the type of x in LibraryName.TypeName x; .

More detailed answer: It has been like that even before libraries (or cross-contract types) were introduced, so there needs to be another reason, but I cannot come up with an example right now. Perhaps it also has to do with inheritance.


if (noErrors)
{
// Explain?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks that can only be done when all types of all AST nodes are known.

shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimize, m_optimizeRuns);
compiledContract.compiler = compiler;

// create metadata
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move the metadata stuff into its own function.

}

/// Set the EVM version used before running compile.
/// When called without an argument it will revert to the default version (currently Byzantium).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not put the name into the comment, we will certainly forget to update it.

@axic axic force-pushed the document-internals branch 2 times, most recently from 403d2e3 to 65a9332 Compare June 25, 2018 21:45
@axic axic force-pushed the document-internals branch 3 times, most recently from 26ec44b to c2a26a1 Compare June 26, 2018 10:23
@axic
Copy link
Copy Markdown
Contributor Author

axic commented Jun 26, 2018

Updated some of the comments.

@axic axic force-pushed the document-internals branch 2 times, most recently from 5494faf to 1aaf49e Compare July 25, 2018 00:06
@axic axic changed the title [WIP] Improve documentation on internal APIs (in code) Properly explain all the analsys steps in CompilerStack Jul 25, 2018
@axic
Copy link
Copy Markdown
Contributor Author

axic commented Jul 25, 2018

@chriseth please review and merge this

if (!parseAndAnalyze())
return false;

// Explain?
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this one is missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 25, 2018

Codecov Report

Merging #4327 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #4327   +/-   ##
========================================
  Coverage    87.92%   87.92%           
========================================
  Files          312      312           
  Lines        30958    30958           
  Branches      3623     3622    -1     
========================================
  Hits         27221    27221           
  Misses        2504     2504           
  Partials      1233     1233
Flag Coverage Δ
#all 87.92% <ø> (ø) ⬆️
#type_checker 28.18% <ø> (ø) ⬆️
Impacted Files Coverage Δ
libsolidity/codegen/ContractCompiler.cpp 92.59% <ø> (ø) ⬆️
libsolidity/interface/CompilerStack.h 100% <ø> (ø) ⬆️
libsolidity/interface/CompilerStack.cpp 82.28% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc13365...f74cff6. Read the comment docs.


if (noErrors)
{
// Control flow graph: currently checks that variable is not used before it is assigned to.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But only for storage variables. Also I would not say what it currently does, because we almost certainly forget to update that, but rather that it for example does this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give a proposed example text?

@axic axic force-pushed the document-internals branch from 1aaf49e to f74cff6 Compare July 30, 2018 23:39
@axic
Copy link
Copy Markdown
Contributor Author

axic commented Jul 30, 2018

@chriseth please check the updated version

@chriseth chriseth merged commit 009a55c into develop Aug 2, 2018
@axic axic deleted the document-internals branch August 2, 2018 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants