aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-05-08 22:24:47 +0800
committerchriseth <c@ethdev.com>2016-05-12 18:30:48 +0800
commit67ca3bb4b9b43faadb1d6a07f868c94bae146c1e (patch)
tree9ca400548764845c9d9977ed0ac3dc6ac4ffde9c /libsolidity/inlineasm
parent1ab0f25dffe19f2cc9e1a0e2fa03a1091679f5a0 (diff)
downloaddexon-solidity-67ca3bb4b9b43faadb1d6a07f868c94bae146c1e.tar.gz
dexon-solidity-67ca3bb4b9b43faadb1d6a07f868c94bae146c1e.tar.zst
dexon-solidity-67ca3bb4b9b43faadb1d6a07f868c94bae146c1e.zip
Allow access to functions in inline assembly.
Diffstat (limited to 'libsolidity/inlineasm')
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp20
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.h2
2 files changed, 17 insertions, 5 deletions
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index d571ce0d..53d19b0a 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -36,7 +36,8 @@ using namespace dev::solidity::assembly;
struct GeneratorState
{
- explicit GeneratorState(ErrorList& _errors): errors(_errors) {}
+ GeneratorState(ErrorList& _errors, eth::Assembly& _assembly):
+ errors(_errors), assembly(_assembly) {}
void addError(Error::Type _type, std::string const& _description, SourceLocation const& _location = SourceLocation())
{
@@ -66,10 +67,10 @@ struct GeneratorState
return label != labels.end() ? &label->second : nullptr;
}
- eth::Assembly assembly;
map<string, eth::AssemblyItem> labels;
vector<pair<string, int>> variables; ///< name plus stack height
ErrorList& errors;
+ eth::Assembly& assembly;
};
/**
@@ -267,7 +268,8 @@ private:
bool assembly::CodeGenerator::typeCheck(assembly::CodeGenerator::IdentifierAccess const& _identifierAccess)
{
size_t initialErrorLen = m_errors.size();
- GeneratorState state(m_errors);
+ eth::Assembly assembly;
+ GeneratorState state(m_errors, assembly);
(LabelOrganizer(state))(m_parsedData);
(CodeTransform(state, _identifierAccess))(m_parsedData);
return m_errors.size() == initialErrorLen;
@@ -275,9 +277,17 @@ bool assembly::CodeGenerator::typeCheck(assembly::CodeGenerator::IdentifierAcces
eth::Assembly assembly::CodeGenerator::assemble(assembly::CodeGenerator::IdentifierAccess const& _identifierAccess)
{
- GeneratorState state(m_errors);
+ eth::Assembly assembly;
+ GeneratorState state(m_errors, assembly);
+ (LabelOrganizer(state))(m_parsedData);
+ (CodeTransform(state, _identifierAccess))(m_parsedData);
+ return assembly;
+}
+
+void assembly::CodeGenerator::assemble(eth::Assembly& _assembly, assembly::CodeGenerator::IdentifierAccess const& _identifierAccess)
+{
+ GeneratorState state(m_errors, _assembly);
(LabelOrganizer(state))(m_parsedData);
(CodeTransform(state, _identifierAccess))(m_parsedData);
- return state.assembly;
}
diff --git a/libsolidity/inlineasm/AsmCodeGen.h b/libsolidity/inlineasm/AsmCodeGen.h
index aaabda45..b1fafe15 100644
--- a/libsolidity/inlineasm/AsmCodeGen.h
+++ b/libsolidity/inlineasm/AsmCodeGen.h
@@ -55,6 +55,8 @@ public:
bool typeCheck(IdentifierAccess const& _identifierAccess = IdentifierAccess());
/// Performs code generation and @returns the result.
eth::Assembly assemble(IdentifierAccess const& _identifierAccess = IdentifierAccess());
+ /// Performs code generation and appends generated to to _assembly.
+ void assemble(eth::Assembly& _assembly, IdentifierAccess const& _identifierAccess = IdentifierAccess());
private:
Block const& m_parsedData;