Review changes.

This commit is contained in:
chriseth 2017-05-19 20:12:12 +02:00
parent e2b21e1c96
commit 69413ae32a
2 changed files with 8 additions and 7 deletions

View File

@ -60,8 +60,9 @@ public:
/// Append a label reference. /// Append a label reference.
virtual void appendLabelReference(size_t _labelId) = 0; virtual void appendLabelReference(size_t _labelId) = 0;
/// Generate a new unique label. /// Generate a new unique label.
virtual size_t newLabel() = 0; virtual size_t newLabelId() = 0;
/// Append a reference to a to-be-linked symobl. /// Append a reference to a to-be-linked symobl.
/// Currently, we assume that the value is always a 20 byte number.
virtual void appendLinkerSymbol(std::string const& _name) = 0; virtual void appendLinkerSymbol(std::string const& _name) = 0;
}; };

View File

@ -87,7 +87,7 @@ public:
{ {
m_assembly.append(eth::AssemblyItem(eth::PushTag, _labelId)); m_assembly.append(eth::AssemblyItem(eth::PushTag, _labelId));
} }
virtual size_t newLabel() override virtual size_t newLabelId() override
{ {
return assemblyTagToIdentifier(m_assembly.newTag()); return assemblyTagToIdentifier(m_assembly.newTag());
} }
@ -241,7 +241,7 @@ public:
} }
void operator()(FunctionalAssignment const& _assignment) void operator()(FunctionalAssignment const& _assignment)
{ {
size_t height = m_assembly.stackHeight(); int height = m_assembly.stackHeight();
boost::apply_visitor(*this, *_assignment.value); boost::apply_visitor(*this, *_assignment.value);
expectDeposit(1, height); expectDeposit(1, height);
m_assembly.setSourceLocation(_assignment.location); m_assembly.setSourceLocation(_assignment.location);
@ -250,7 +250,7 @@ public:
} }
void operator()(assembly::VariableDeclaration const& _varDecl) void operator()(assembly::VariableDeclaration const& _varDecl)
{ {
size_t height = m_assembly.stackHeight(); int height = m_assembly.stackHeight();
boost::apply_visitor(*this, *_varDecl.value); boost::apply_visitor(*this, *_varDecl.value);
expectDeposit(1, height); expectDeposit(1, height);
auto& var = boost::get<Scope::Variable>(m_scope.identifiers.at(_varDecl.variable.name)); auto& var = boost::get<Scope::Variable>(m_scope.identifiers.at(_varDecl.variable.name));
@ -291,9 +291,9 @@ private:
/// Determines the stack height difference to the given variables. Automatically generates /// Determines the stack height difference to the given variables. Automatically generates
/// errors if it is not yet in scope or the height difference is too large. Returns 0 on /// errors if it is not yet in scope or the height difference is too large. Returns 0 on
/// errors and the (positive) stack height difference otherwise. /// errors and the (positive) stack height difference otherwise.
size_t variableHeightDiff(Scope::Variable const& _var, SourceLocation const& _location, bool _forSwap) int variableHeightDiff(Scope::Variable const& _var, SourceLocation const& _location, bool _forSwap)
{ {
size_t heightDiff = m_assembly.stackHeight() - _var.stackHeight; int heightDiff = m_assembly.stackHeight() - _var.stackHeight;
if (heightDiff <= (_forSwap ? 1 : 0) || heightDiff > (_forSwap ? 17 : 16)) if (heightDiff <= (_forSwap ? 1 : 0) || heightDiff > (_forSwap ? 17 : 16))
{ {
//@TODO move this to analysis phase. //@TODO move this to analysis phase.
@ -326,7 +326,7 @@ private:
void assignLabelIdIfUnset(Scope::Label& _label) void assignLabelIdIfUnset(Scope::Label& _label)
{ {
if (!_label.id) if (!_label.id)
_label.id.reset(m_assembly.newLabel()); _label.id.reset(m_assembly.newLabelId());
} }