Support a configurable language module#21
Open
Gazler wants to merge 1 commit into
Open
Conversation
Erlang has a constraint that ensures there is a mapping from filename to module name: ``` foo.erl => -module(foo) bar.erl => -module(bar) ``` This makes looking up a module based on a path name deterministic. This is not the case in other BEAM languages such as Elixir. In Elixir, there is no mapping between the file name and the module name. It is also possible for an Elixir file to contain multiple modules. In order to allow edb to be used in Elixir, we need a way to configure the mapping from path to module. However, instead of baking in support just for Elixir, it would be ideal to have this be generic. This commit introduces a configurable module which can be provided as start options for edb. This is implemented with a behaviour, and a default erlang implementation is provided which is just the code that previously existed. The behaviour implements `init/0` and `source_to_modules/3`. To allow passing this option through, the application config is required to be set before starting edb. This is should be handled by the caller. The intention here, is for other languages to wrap edb with their own escript which provides a language implementation. For example, an Elixir wrapper can use: ``` defmodule EdbElixir.CLI do @moduledoc false def main(args) do Application.put_env(:edb, :dap_language, EdbElixir.DapLanguage) :edb_main.main(args) end end ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Erlang has a constraint that ensures there is a mapping from filename to module name:
This makes looking up a module based on a path name deterministic. This is not the case in other BEAM languages such as Elixir. In Elixir, there is no mapping between the file name and the module name. It is also possible for an Elixir file to contain multiple modules.
In order to allow edb to be used in Elixir, we need a way to configure the mapping from path to module. However, instead of baking in support just for Elixir, it would be ideal to have this be generic.
This commit introduces a configurable module which can be provided as start options for edb. This is implemented with a behaviour, and a default erlang implementation is provided which is just the code that previously existed. The behaviour implements
init/0andsource_to_modules/3.To allow passing this option through, the application config is required to be set before starting edb. This is should be handled by the caller.
The intention here, is for other languages to wrap edb with their own escript which provides a language implementation.
For example, an Elixir wrapper can use: