Giter Club home page Giter Club logo

Comments (3)

andytill avatar andytill commented on July 18, 2024 1

Thanks @olafura! Yes the return should be a flat list of binding names, it is very difficult to take this apart in Java, like an untyped XML DOM. The function clause combinations do get very complex. In the example case we can get the binding names from the dialyzer spec initially, and then use the function clause to fill in the blanks.

So for example, in this function.

myfunc(0, Acc) -> Acc
myfunc(Index, _) -> myfunc(Index-1, 2).

The list of returned arguments should be ["Index", "Acc"]. If there were two different names for the same argument e.g.

myfunc(0, Acc) -> Acc
myfunc(Index, X) -> myfunc(Index-1, X+1).

Then we could return ["Index", "Acc|X"]. Names in the dialyzer spec should probably override this, unless we don't trust that the spec is being kept upto date!? Maybe we should return that too if it is different to the names in the clause.

from erlyberly.

olafura avatar olafura commented on July 18, 2024

So I have an initial results, I have yet to convert the params from their ast form. But in their lies the crux, we have complex params like process_info2 on line 79, size_to_bytes on line 118 and record fields on line 155.

Here is a diff:

diff --git a/src/main/resources/erlyberly/beam/erlyberly.erl b/src/main/resources/erlyberly/beam/erlyberly.erl
index 633d35c..bb9a4b0 100644
--- a/src/main/resources/erlyberly/beam/erlyberly.erl
+++ b/src/main/resources/erlyberly/beam/erlyberly.erl
@@ -26,6 +26,7 @@
 -export([get_source_code/1]).
 -export([load_modules_on_path/1]).
 -export([load_module_records/1]).
+-export([load_module_functions/1]).
 -export([module_functions/0]).
 -export([process_info/0]).
 -export([saleyn_fun_src/1]).
@@ -174,6 +175,13 @@ load_module_records(Mod) ->
     Records = [{Tag, record_fields(Fields)} || {attribute,_,record,{Tag,Fields}} <- Forms],
     {ok, Records}.
 
+load_module_functions(Mod) ->
+    {ok, Forms} = load_module_forms(Mod),
+    Functions = [
+     {Function,Params} || {function,_,Function,_,FunctionBody} <- Forms,
+                          {clause,_,Params, _Guard, _Body} <- FunctionBody],
+    {ok, Functions}.
+
 %%% ============================================================================
 %%% module function tree
 %%% ============================================================================

from erlyberly.

olafura avatar olafura commented on July 18, 2024

I can of course just extract the vars, if you want ;)

from erlyberly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.