diff --git a/libsolidity/Compiler.cpp b/libsolidity/Compiler.cpp index bd6571b9a..d86c939c8 100644 --- a/libsolidity/Compiler.cpp +++ b/libsolidity/Compiler.cpp @@ -34,11 +34,11 @@ using namespace std; namespace dev { namespace solidity { -void Compiler::compileContract(ContractDefinition const& _contract, vector const& _magicGlobals, +void Compiler::compileContract(ContractDefinition const& _contract, map const& _contracts) { m_context = CompilerContext(); // clear it just in case - initializeContext(_contract, _magicGlobals, _contracts); + initializeContext(_contract, _contracts); for (ASTPointer const& function: _contract.getDefinedFunctions()) if (function->getName() != _contract.getName()) // don't add the constructor here @@ -51,16 +51,14 @@ void Compiler::compileContract(ContractDefinition const& _contract, vector const& _magicGlobals, +void Compiler::initializeContext(ContractDefinition const& _contract, map const& _contracts) { m_context.setCompiledContracts(_contracts); - for (MagicVariableDeclaration const* variable: _magicGlobals) - m_context.addMagicGlobal(*variable); registerStateVariables(_contract); } diff --git a/libsolidity/Compiler.h b/libsolidity/Compiler.h index c229a7a8a..073721e06 100644 --- a/libsolidity/Compiler.h +++ b/libsolidity/Compiler.h @@ -32,15 +32,15 @@ class Compiler: private ASTConstVisitor public: explicit Compiler(bool _optimize = false): m_optimize(_optimize), m_context(), m_returnTag(m_context.newTag()) {} - void compileContract(ContractDefinition const& _contract, std::vector const& _magicGlobals, + void compileContract(ContractDefinition const& _contract, std::map const& _contracts); bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); } bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);} void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); } private: - /// Registers the global objects and the non-function objects inside the contract with the context. - void initializeContext(ContractDefinition const& _contract, std::vector const& _magicGlobals, + /// Registers the non-function objects inside the contract with the context. + void initializeContext(ContractDefinition const& _contract, std::map const& _contracts); /// Adds the code that is run at creation time. Should be run after exchanging the run-time context /// with a new and initialized context. diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 5532d74bc..790eb983a 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -113,10 +113,8 @@ void CompilerStack::compile(bool _optimize) for (ASTPointer const& node: source->ast->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - m_globalContext->setCurrentContract(*contract); shared_ptr compiler = make_shared(_optimize); - compiler->compileContract(*contract, m_globalContext->getMagicVariables(), - contractBytecode); + compiler->compileContract(*contract, contractBytecode); Contract& compiledContract = m_contracts[contract->getName()]; compiledContract.bytecode = compiler->getAssembledBytecode(); compiledContract.runtimeBytecode = compiler->getRuntimeBytecode(); diff --git a/libsolidity/GlobalContext.cpp b/libsolidity/GlobalContext.cpp index 92ca9548a..c7eea92dc 100644 --- a/libsolidity/GlobalContext.cpp +++ b/libsolidity/GlobalContext.cpp @@ -68,7 +68,7 @@ void GlobalContext::setCurrentContract(ContractDefinition const& _contract) vector GlobalContext::getDeclarations() const { vector declarations; - declarations.reserve(m_magicVariables.size() + 1); + declarations.reserve(m_magicVariables.size()); for (ASTPointer const& variable: m_magicVariables) declarations.push_back(variable.get()); return declarations; @@ -83,15 +83,5 @@ MagicVariableDeclaration const* GlobalContext::getCurrentThis() const } -vector GlobalContext::getMagicVariables() const -{ - vector declarations; - declarations.reserve(m_magicVariables.size() + 1); - for (ASTPointer const& variable: m_magicVariables) - declarations.push_back(variable.get()); - declarations.push_back(getCurrentThis()); - return declarations; -} - } } diff --git a/libsolidity/GlobalContext.h b/libsolidity/GlobalContext.h index c6e35f504..dfdc66623 100644 --- a/libsolidity/GlobalContext.h +++ b/libsolidity/GlobalContext.h @@ -49,8 +49,6 @@ public: void setCurrentContract(ContractDefinition const& _contract); MagicVariableDeclaration const* getCurrentThis() const; - /// @returns all magic variables. - std::vector getMagicVariables() const; /// @returns a vector of all implicit global declarations excluding "this". std::vector getDeclarations() const; diff --git a/test/SolidityCompiler.cpp b/test/SolidityCompiler.cpp index b4874e195..53daa9dfe 100644 --- a/test/SolidityCompiler.cpp +++ b/test/SolidityCompiler.cpp @@ -64,7 +64,7 @@ bytes compileContract(const string& _sourceCode) if (ContractDefinition* contract = dynamic_cast(node.get())) { Compiler compiler; - compiler.compileContract(*contract, {}, map{}); + compiler.compileContract(*contract, map{}); // debug //compiler.streamAssembly(cout);