aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/CompilerStack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/CompilerStack.cpp')
-rw-r--r--libsolidity/CompilerStack.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp
index 70bb1b4c..e6b87264 100644
--- a/libsolidity/CompilerStack.cpp
+++ b/libsolidity/CompilerStack.cpp
@@ -27,6 +27,7 @@
#include <libsolidity/Parser.h>
#include <libsolidity/GlobalContext.h>
#include <libsolidity/NameAndTypeResolver.h>
+#include <libsolidity/TypeChecker.h>
#include <libsolidity/Compiler.h>
#include <libsolidity/CompilerStack.h>
#include <libsolidity/InterfaceHandler.h>
@@ -76,6 +77,7 @@ void CompilerStack::reset(bool _keepSources, bool _addStandardSources)
m_globalContext.reset();
m_sourceOrder.clear();
m_contracts.clear();
+ m_errors.clear();
}
bool CompilerStack::addSource(string const& _name, string const& _content, bool _isLibrary)
@@ -93,8 +95,10 @@ void CompilerStack::setSource(string const& _sourceCode)
addSource("", _sourceCode);
}
-void CompilerStack::parse()
+bool CompilerStack::parse()
{
+ m_errors.clear();
+
for (auto& sourcePair: m_sources)
{
sourcePair.second.scanner->reset();
@@ -116,6 +120,7 @@ void CompilerStack::parse()
resolver.resolveNamesAndTypes(*contract);
m_contracts[contract->name()].contract = contract;
}
+
InterfaceHandler interfaceHandler;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
@@ -123,18 +128,22 @@ void CompilerStack::parse()
{
m_globalContext->setCurrentContract(*contract);
resolver.updateDeclaration(*m_globalContext->currentThis());
- resolver.checkTypeRequirements(*contract);
+ TypeChecker typeChecker;
+ bool typesFine = typeChecker.checkTypeRequirements(*contract);
+ if (!typesFine)
+ m_errors += typeChecker.errors();
contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract));
contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract));
m_contracts[contract->name()].contract = contract;
}
- m_parseSuccessful = true;
+ m_parseSuccessful = m_errors.empty();
+ return m_parseSuccessful;
}
-void CompilerStack::parse(string const& _sourceCode)
+bool CompilerStack::parse(string const& _sourceCode)
{
setSource(_sourceCode);
- parse();
+ return parse();
}
vector<string> CompilerStack::contractNames() const
@@ -148,17 +157,18 @@ vector<string> CompilerStack::contractNames() const
}
-void CompilerStack::compile(bool _optimize, unsigned _runs)
+bool CompilerStack::compile(bool _optimize, unsigned _runs)
{
if (!m_parseSuccessful)
- parse();
+ if (!parse())
+ return false;
map<ContractDefinition const*, eth::Assembly const*> compiledContracts;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
- if (!contract->isFullyImplemented())
+ if (!contract->annotation().isFullyImplemented)
continue;
shared_ptr<Compiler> compiler = make_shared<Compiler>(_optimize, _runs);
compiler->compileContract(*contract, compiledContracts);
@@ -172,13 +182,12 @@ void CompilerStack::compile(bool _optimize, unsigned _runs)
cloneCompiler.compileClone(*contract, compiledContracts);
compiledContract.cloneObject = cloneCompiler.assembledObject();
}
+ return true;
}
-eth::LinkerObject const& CompilerStack::compile(string const& _sourceCode, bool _optimize)
+bool CompilerStack::compile(string const& _sourceCode, bool _optimize)
{
- parse(_sourceCode);
- compile(_optimize);
- return object();
+ return parse(_sourceCode) && compile(_optimize);
}
void CompilerStack::link(const std::map<string, h160>& _libraries)
@@ -317,12 +326,6 @@ size_t CompilerStack::functionEntryPoint(
return 0;
}
-eth::LinkerObject CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimize)
-{
- CompilerStack stack;
- return stack.compile(_sourceCode, _optimize);
-}
-
tuple<int, int, int, int> CompilerStack::positionFromSourceLocation(SourceLocation const& _sourceLocation) const
{
int startLine;