From 1f77deada1abc9ca1e635ab13d45707e852a5628 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Thu, 3 May 2018 16:40:33 +0200 Subject: [050] Reserving and popping local vars in their scope --- libsolidity/codegen/CompilerContext.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libsolidity/codegen/CompilerContext.h') diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 5776b5d1..f3934615 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -71,7 +71,9 @@ public: void addStateVariable(VariableDeclaration const& _declaration, u256 const& _storageOffset, unsigned _byteOffset); void addVariable(VariableDeclaration const& _declaration, unsigned _offsetToCurrent = 0); - void removeVariable(VariableDeclaration const& _declaration); + void removeVariable(Declaration const& _declaration); + /// Removes all local variables currently allocated above _stackHeight. + void removeVariablesAboveStackHeight(unsigned _stackHeight); void setCompiledContracts(std::map const& _contracts) { m_compiledContracts = _contracts; } eth::Assembly const& compiledContract(ContractDefinition const& _contract) const; -- cgit v1.2.3 From 0c5e0e0d59dc55fcfe5b95a8c649a7a769ad3400 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Tue, 10 Jul 2018 18:39:26 +0200 Subject: Added assertion and tests suggestions --- libsolidity/codegen/CompilerContext.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libsolidity/codegen/CompilerContext.h') diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index f3934615..3f357821 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -74,6 +74,8 @@ public: void removeVariable(Declaration const& _declaration); /// Removes all local variables currently allocated above _stackHeight. void removeVariablesAboveStackHeight(unsigned _stackHeight); + /// Returns the number of currently allocated local variables. + unsigned numberOfLocalVariables() const; void setCompiledContracts(std::map const& _contracts) { m_compiledContracts = _contracts; } eth::Assembly const& compiledContract(ContractDefinition const& _contract) const; -- cgit v1.2.3 From 5e01d767d02d064a064a67dcf95ee299c46f741f Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 17 Jan 2018 12:05:43 +0100 Subject: Prevent externally used functions from being removed. --- libsolidity/codegen/CompilerContext.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libsolidity/codegen/CompilerContext.h') diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 3f357821..5bdc1d19 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -206,10 +206,12 @@ public: /// Appends inline assembly (strict mode). /// @a _replacements are string-matching replacements that are performed prior to parsing the inline assembly. /// @param _localVariables assigns stack positions to variables with the last one being the stack top + /// @param _externallyUsedFunctions a set of function names that are not to be renamed or removed. /// @param _system if true, this is a "system-level" assembly where all functions use named labels. void appendInlineAssembly( std::string const& _assembly, std::vector const& _localVariables = std::vector(), + std::set const& _externallyUsedFunctions = std::set(), bool _system = false ); -- cgit v1.2.3