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

Implement a Data flow engine #12

Open
htrgouvea opened this issue Nov 9, 2023 · 4 comments
Open

Implement a Data flow engine #12

htrgouvea opened this issue Nov 9, 2023 · 4 comments

Comments

@htrgouvea
Copy link
Owner

htrgouvea commented Nov 9, 2023

Currently, ZARN performs a pseudo analysis of the data flow, it tries to identify the presence of a variable and looks for the possibility of its value being changed by the user.

This is not the ideal way to implement a Data Flow. I'm opening this issue to discuss the possibility of a new way and also how to do this.

After implementing this data flow engine, I hope that it will be possible to do alias analysis and also Multiple files context analysis.

@giovannism20
Copy link
Contributor

Hey @htrgouvea, would be great if we have a diagram of the actual data flow to discuss about it.

@htrgouvea
Copy link
Owner Author

Great ideia @giovannism20, i will make and share here.

@htrgouvea
Copy link
Owner Author

htrgouvea commented Feb 22, 2024

I find a module called Devel::Graph, which makes a very interesting analysis of the flow of a Perl script. Here is an example using Devel::Graph:

#!/usr/bin/env perl

use 5.018;
use strict;
use warnings;
use Devel::Graph;

sub main {
    my $file = $ARGV[0];

    if ($file) {
        my $grapher = Devel::Graph -> new();
        my $decompose   = $grapher -> decompose ($file);
       
        print $decompose -> as_ascii();
    }

    return 0;
}

exit main();

And a demo with the following code:

#!/usr/bin/env perl

use 5.018;
use strict;
use warnings;

sub main {
    my $name = $ARGV[0];

    if ($name) {
        system ("echo Hello World! $name");
        # system ("echo Hello World! $name");
    }

    return 0;
}

exit main();

The output is:

  #######################################
  #                start                #
  #######################################
    |
    |
    v
  +-------------------------------------+
  |             use 5.018;              |
  |             use strict;             |
  |            use warnings;            |
  |            exit main();             |
  +-------------------------------------+
+ - - - - - - - - - - - - - - - - - - - - +
' sub main:                               '
'                                         '
' +-------------------------------------+ '
' |        my $name = $ARGV[0];         | '
' +-------------------------------------+ '
'   |                                     '
'   |                                     '
'   |                                     '
'   |                                       - - - - - +
'   v                                                 '
' +-------------------------------------+             '
' |             if ($name)              | ---+        '
' +-------------------------------------+    |        '
'   |                                        |        '
'   | true                                   |        '
'   v                                        |        '
' +-------------------------------------+    |        '
' | system ("echo Hello World! $name"); |    | false  '
' +-------------------------------------+    |        '
'   |                                        |        '
'   |                                        |        '
'   v                                        |        '
' +-------------------------------------+    |        '
' |              return 0;              | <--+        '
' +-------------------------------------+             '
'                                                     '
+ - - - - - - - - - - - - - - - - - - - - - - - - - - +

@htrgouvea
Copy link
Owner Author

htrgouvea commented Feb 22, 2024

I think we can use logic similar to this module (maybe even it itself) to create the DataFlow Engine .

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

No branches or pull requests

2 participants