Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding source location support to AssemblyStack #8378

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

mijovic
Copy link
Contributor

@mijovic mijovic commented Feb 24, 2020

Fixes #7783

Description

Checklist

  • Code compiles correctly
  • All tests are passing
  • New tests have been created which fail without the change (if possible)
  • README / documentation was extended, if necessary
  • Changelog entry (if change is visible to the user)
  • Used meaningful commit messages

libyul/AssemblyStack.cpp Outdated Show resolved Hide resolved
Changelog.md Outdated Show resolved Hide resolved
libevmasm/AssemblyItem.h Outdated Show resolved Hide resolved
libyul/AssemblyStack.h Outdated Show resolved Hide resolved
@mijovic mijovic force-pushed the yulSourceLocations branch 2 times, most recently from 434f929 to aef75a0 Compare February 25, 2020 10:34
@@ -204,6 +204,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
compileEVM(adapter, false, m_optimiserSettings.optimizeStackAllocation);
object.bytecode = make_shared<evmasm::LinkerObject>(assembly.assemble());
object.assembly = assembly.assemblyString();
object.sourceMappings = make_unique<string>(evmasm::AssemblyItem::computeSourceMapping(assembly.items()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to pass {scanner().charStream()->name(), 0} as source indices here and remove the special case for empty source indices in computeSourceMapping.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(of course check that charStream() is not null and maybe use "" in that case for the source name).

@@ -98,6 +98,7 @@ class Scanner
std::string const& source() const noexcept { return m_source->source(); }

std::shared_ptr<CharStream> charStream() noexcept { return m_source; }
std::shared_ptr<CharStream> const& constCharStream() const noexcept { return m_source; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be

Suggested change
std::shared_ptr<CharStream> const& constCharStream() const noexcept { return m_source; }
std::shared_ptr<CharStream const> constCharStream() const noexcept { return m_source; }

instead?

@@ -98,6 +98,7 @@ class Scanner
std::string const& source() const noexcept { return m_source->source(); }

std::shared_ptr<CharStream> charStream() noexcept { return m_source; }
std::shared_ptr<CharStream> const& constCharStream() const noexcept { return m_source; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be

Suggested change
std::shared_ptr<CharStream> const& constCharStream() const noexcept { return m_source; }
std::shared_ptr<CharStream const> charStream() const noexcept { return m_source; }

instead?

@@ -98,6 +98,7 @@ class Scanner
std::string const& source() const noexcept { return m_source->source(); }

std::shared_ptr<CharStream> charStream() noexcept { return m_source; }
std::shared_ptr<CharStream> const& constCharStream() const noexcept { return m_source; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be

Suggested change
std::shared_ptr<CharStream> const& constCharStream() const noexcept { return m_source; }
std::shared_ptr<CharStream const> charStream() const noexcept { return m_source; }

instead?

@chriseth chriseth merged commit bb09787 into ethereum:develop Feb 25, 2020
@MrChico
Copy link
Member

MrChico commented Apr 29, 2020

can we make this option available in the cli as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Yul] output source locations
3 participants