-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop after parsing. #9364
Stop after parsing. #9364
Conversation
Would be deligted if someone took this over :) |
I am taking this over :) |
Pushed an update. this is still WIP, but feel free to give feedback on the current state. |
libsolidity/ast/Types.cpp
Outdated
@@ -3494,7 +3497,7 @@ string FunctionType::externalSignature() const | |||
} | |||
|
|||
// "inLibrary" is only relevant if this is not an event. | |||
bool const inLibrary = kind() != Kind::Event && dynamic_cast<ContractDefinition const&>(*m_declaration->scope()).isLibrary(); | |||
bool const inLibrary = kind() != Kind::Event && m_declaration->scope() && dynamic_cast<ContractDefinition const&>(*m_declaration->scope()).isLibrary(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether we should rather assign scopes during parsing - it should be a purely syntactic thing, so the parser should be able to do that easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally or for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because I'm randomly reading these comments: I actually thought the same when looking at #8834 - the m_free
member there could just be derived from the scope, if the parser did this stuff already...
Updated: now missing is the documentation update |
vector<string> contractNames; | ||
for (auto const& contract: m_contracts) | ||
contractNames.push_back(contract.first); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if I maybe should make this return value based on the imports instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you are suggesting here, but do you think it makes sense to just keep the code here and instead initialize m_contracts
already right after parsing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this change completely now. Turns out it was useless.
f9f3e11
to
0a24a29
Compare
Documentation is also updated now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be rebased and changelog moved to 0.7.1.
libsolidity/ast/ASTJsonConverter.cpp
Outdated
@@ -731,7 +736,7 @@ bool ASTJsonConverter::visit(FunctionCall const& _node) | |||
attributes.emplace_back("isStructConstructorCall", _node.annotation().kind == FunctionCallKind::StructConstructorCall); | |||
attributes.emplace_back("type_conversion", _node.annotation().kind == FunctionCallKind::TypeConversion); | |||
} | |||
else | |||
else if (_node.annotation().kind != FunctionCallKind::Unset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bugfix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it fixes a bug that happened as a result from the stop-after-parse change. I think usually you wouldn't get Unset
.
Updated |
Changelog.md
Outdated
@@ -6,6 +6,7 @@ Language Features: | |||
Compiler Features: | |||
* Standard JSON Interface: Do not run EVM bytecode code generation, if only Yul IR or EWasm output is requested. | |||
* Yul: Report error when using non-string literals for ``datasize()``, ``dataoffset()``, ``linkersymbol()``, ``loadimmutable()``, ``setimmutable()``. | |||
* New feature to stop compilation after parsing stage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also option the command line option for doing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean "mention"?
@@ -216,11 +217,11 @@ class CompilerStack: boost::noncopyable | |||
|
|||
/// Parses and analyzes all source units that were added | |||
/// @returns false on error. | |||
bool parseAndAnalyze(); | |||
bool parseAndAnalyze(State _stopAfter = State::CompilationSuccessful); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to my above comment, I think this function should not have that parameter, and callers that needs to stop after parse should then use compile(stopAfterStage)
or just call parse() directly?
68add90
to
9c241ac
Compare
6b488ed
to
bb3f942
Compare
"baseContracts": [], | ||
"contractDependencies": [], | ||
"contractKind": "contract", | ||
"fullyImplemented": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's totally fine that some members are missing, but I'm worried that wrong information might be very misleading.
The fuzzer somehow interprets a standard-json input as plain solidity. |
I think it really makes sense to use std::optional or SetOnce for all annotations. This will also help in other cases. |
53424d5
to
73aa7d7
Compare
Conflicts |
3c373bd
to
96f2605
Compare
Ready now. |
Update: Moved changelog entry to correct version |
Needs another rebase. |
Fixes #8739
Todo: