Giter Site home page Giter Site logo

speco's Introduction

logo

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

mvn PDD status codecov Maven Central Hits-of-Code Lines of code License

Specialization of objects in EO programs.

Speco is a tool that is aimed to be launched on the EO program converted to a collection of .xmir files, which has undergone modifications performed by AOI tool.

Consider the following EO program:

[] > cat
  [] > talk
    QQ.io.stdout > @
      "Meow!"

[] > dog
  [] > talk
    QQ.io.stdout > @
      "Woof!"
  [] > eat
    QQ.io.stdout > @
      "I am eating"

[x] > pet1
  x.talk > @

[x] > pet2
  seq > @
    x.talk
    x.eat

The following block in the .xmir file of this program will be generated after AOI launch:

<aoi>
    <obj fqn="pet1.x">
       <inferred>
          <obj fqn="cat"/>
          <obj fqn="dog"/>
       </inferred>
    </obj>
    <obj fqn="pet2.x">
       <inferred>
          <obj fqn="dog"/>
       </inferred>
    </obj>
</aoi>

As we can see, object x from pet1 is only used with its talk attribute, therefore it can either be an instance of cat or dog. Whereas x located pet2 is used with both talk and eat, which lets us determine that x can only be an instance of dog.

Right now object pet1 has only one implementation, which looks like below in xmir format. It does not give any hints on what object x may be in this context.

<o abstract="" line="20" name="pet1" pos="0">
   <o line="20" name="x" pos="1"/>
   <o base="x" line="21" pos="2"/>
   <o base=".talk" line="21" name="@" pos="3"/>
</o>

Speco makes it obvious what x is in the provided context. For example, it will turn object pet1 into these two declarations of objects pet1_spec_x_cat and pet1_spec_x_dog, which are specific for cat and dog correspondingly.

<o abstract="" line="20" name="pet1_spec_x_cat" pos="0" spec="pet1">
   <o line="20" name="x" pos="1"/>
   <o base="x" line="21" pos="2"/>
   <o base=".talk" line="21" name="@" pos="3"/>
</o>
<o abstract="" line="20" name="pet1_spec_x_dog" pos="0" spec="pet1">
   <o line="20" name="x" pos="1"/>
   <o base="x" line="21" pos="2"/>
   <o base=".talk" line="21" name="@" pos="3"/>
</o>

It will generate a collection of modified .xmir files as an output.

Usage

Build the app locally:

$ make build

and run:

$ java -jar speco.jar --help

To run a transformation:

$ java -jar speco.jar --source=<input> --target=<output>

or use make command:

$ make trans

How it works

The tool works according to an algorithm consisting of 7 transformation rules.

Rule 1:

  • Create a <speco/> node consisting of specialized <versions/> nodes for all objects inferred by AOI;
  • Each node has attributes:
    • @name -- name of the polymorphic object,
    • @var -- name of the polymorphic attribute of this object,
    • @spec -- name of the object that specializes this attribute;
  • Each node consists of a single object copied from the <objects/> node by name @name, but also changed attributes:
    • @name replaced by @name_spec_@var_@spec
    • @spec equal version@spec
  • Copy all specialized objects (content of the <version/> node) to the <objects/> node.

Rule 2:

  • For all applications: if there is a polymorphic base object and a specialized version is uniquely determined, then a replacement to determined version occurs.

Rule 3:

  • For each object, for each of its specialized/polymorphic versions, create a with-* attribute that would returns a new object for the current version. The current state of the object should be deeply copied into the new object.

Rule 4:

  • Search for all fence attributes, that reference to the memory wrapper object;
  • Create copies of these attributes, modifying them so that tuple with the object it returned before and the "parent" object is returned.

Rule 5:

  • Replace accessing the "parent" object with creating an intermediate tuple object and getting its first element.

Rule 6:

  • Replace calls of the "parent" object (all except the first one) with calls of the second elements of intermediate tuples in the order in the program. Later this should be replaced by using EOG.

Rule 7:

  • Modify the *-as-tuple attribute so that it returns a new object instead of changing itself by using the with-* attribute.

How to Contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

You will need Maven 3.3+ and Java 8+.

speco's People

Contributors

advasileva avatar olesiasub avatar renovate[bot] avatar rultor avatar volodya-lombrozo avatar yegor256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

speco's Issues

clear `xax` tests

I think it will be nicer if we remove unnecessary objects (e.g. printers) and attributes (e.g. line and pos) in xax tests.

rm temp attributes

We need to add a transformation that would remove the intermediate attributes of the Speco (e.g. fence and fence_tuple).

builders creation

We need to create builders (based on AOI) for each attribute with cage. Example from the paper (modified):
source code:

[] > cartA
   cage' > p

specialized:

[] > cartA
  [m] > withMovie
    cartA-with-movie m > @
  [b] > withBook
    cartA-with-book b > @
[b] > cartA-with-book
  [m] > withMovie
    cartA-with-movie m > @
  [b] > withBook
    cartA-with-book b > @
[m] > cartA-with-movie
  [m] > withMovie
    cartA-with-movie m > @
  [b] > withBook
    cartA-with-book b > @

Fake EOG to Correct EOG

I hardcoded the order of dataization in rule 6 as the order of appearance applications in the program, since there is no EOG at the moment. After implementing EOG, we need to rewrite rule 6 using EOG.

SpecoTest.java:110-113: investigate problem with...

The puzzle 32-6813db68 from #32 has to be resolved:

* @todo #32:30min investigate problem with @DisableOnOs(OS.Windows),
* this is an issue of junit -- https://github.com/junit-team/junit5/issues/2811,
* maybe try to manually delete each created file or use a pat
* or get rid of the @TempDir.

The puzzle was created by @rultor on 15-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

SpecoEoTest.java:51-53: enable convertsFromEO test: we...

The puzzle 63-5b7f38a4 from #63 has to be resolved:

* @todo #63:30min enable convertsFromEO test:
* we need to remove @disable annotation for these test
* when we provide the rule 3 implementation and add an appropriate transformation.

The puzzle was created by @advasileva on 26-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Walk.java:36-38: refactor this interface and classes...

The puzzle 39-efbdd83b from #39 has to be resolved:

* @todo #39:60min refactor this interface and classes EoWalk and XmirWalk implementing it,
* to avoid code duplication. In particular, in the fields (input, output and speco),
* constructor and exec method.

The puzzle was created by @rultor on 13-Apr-23.

Estimate: 60 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

improve logging

Let's improve logging. Suggested items:

  • add a context of the errors, e.g.;
  • add intermediate logs to Speco* classes.

This was discussed in #103.

speco walk

Now speco can only process a directory consisting of files. It is necessary to add the ability to recursively process the subdirectories, e.g.:

in/
    app1.eo
    app2.eo
    some/
        app3.eo
        other/

MainTest.java:43-45: add separate unit-test for each...

The puzzle 22-db3865a1 from #22 has to be resolved:

* @todo #22:90min add separate unit-test for each transformation,
* which would run step by step and check the intermediate results,
* for example, use yml packs as in dejump.

The puzzle was created by @rultor on 17-Jan-23.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

SpecoXmirTest.java:41-43: enable convertsFromXmir test:...

The puzzle 63-ca0ca568 from #63 has to be resolved:

* @todo #63:30min enable convertsFromXmir test:
* we need to remove @disable annotation for these test
* when we provide the rule 3 implementation and add an appropriate transformation.

The puzzle was created by @advasileva on 26-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

rewrite readme

Current version README.md outdated, we need to update it in accordance with the paper

add rules tests

We need new rule-by-rule tests type with EO programs. Create directory rules/ in tests resources and add tests.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency com.qulice:qulice-maven-plugin to v0.23.0
  • chore(deps): update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.13.0
  • fix(deps): update dependency com.jcabi:jcabi-log to v0.24.1
  • chore(deps): update actions/cache action to v4
  • chore(deps): update actions/setup-java action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update codecov/codecov-action action to v4
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codecov.yml
  • actions/checkout v3
  • actions/setup-java v3
  • actions/cache v3
  • actions/setup-node v3
  • codecov/codecov-action v3
  • ubuntu 20.04
.github/workflows/mvn.yml
  • actions/checkout v3
  • actions/setup-java v3
  • actions/cache v3
  • actions/setup-node v3
  • ruby/setup-ruby 6cecb48364174b0952995175c55f9bf5527e6682
.github/workflows/pdd.yml
  • actions/checkout v3
  • ubuntu 20.04
.github/workflows/xcop.yml
  • actions/checkout v3
  • ubuntu 20.04
maven
pom.xml
  • com.jcabi:parent 0.65.0
  • org.eolang:eo-parser 0.29.3
  • org.eolang:aoi 0.0.3
  • org.eolang:jucs 0.2.0
  • com.yegor256:xsline 0.21.1
  • org.eolang:xax 0.0.5
  • org.junit.jupiter:junit-jupiter-api 5.9.2
  • org.junit.jupiter:junit-jupiter-params 5.9.2
  • com.jcabi:jcabi-xml 0.27.2
  • com.jcabi:jcabi-log 0.23.0
  • org.cactoos:cactoos 0.55.0
  • info.picocli:picocli 4.7.3
  • commons-io:commons-io 2.11.0
  • org.apache.maven.plugins:maven-compiler-plugin 3.11.0
  • org.apache.maven.plugins:maven-surefire-plugin 3.0.0
  • com.qulice:qulice-maven-plugin 0.22.0

  • Check this box to trigger a request for Renovate to run again on this repository

logging

It is necessary to clear the warnings in order to find the error that caused the PRs to fail. It is necessary to add simple logging to track the output of tests.

Wrong java version in `maven-compiler-plugin`

We expect that maven during compilation will use 8 version of Java:

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.10.1</version>
        <configuration combine.self="override">
          <source>8</source>
          <target>8</target>
        </configuration>
      </plugin>

But at the same time we use features from Java 11:

Files.readString(path);
...
Path.of(...);

I don't clearly understand why maven even build the project, but in my IDEA a see tons of warning and errors. Can we increase the version of Java for maven-compiler-plugin, at least to make it more clear?

directories cleaning

It will be convenient to add a command line option that will configure the deletion of temporary directories (like in_prs/ and in_prs_aoi/). For example, we can set a --clean flag for deletion and keep all directories by default.

skeleton

Let's create a command line tool, that can be executed as such:

$ java -jar speco.jar --help

Here, we should parse --help using some framework for parsing of command line options.

ctor specialization

Now speco should be able to specialize the simplest case of attribute polymorphism (construction) as in the core issue.
This consists of

  1. Сreating specialized versions of objects (in the <objects/> tag), e.g. adding a:
[x] > foo1
  x.boom > @
[x] > foo2
  x.boom > @
  1. Replacing the call in the application line, e.g.:

from

foo first
foo second

to

foo1 first
foo2 second

tests structure

We will have 4 types of tests, between which there is a very conditional division into unit and integration. They can be grouped by input data type (xmir/eo) or left at the same level, e.g. (current design):
packs/ -- from eo (done)
transformations/ -- from xmir (wip)
rules/ -- from eo (backlog)
xmir/ -- from xmir (maybe rename to integration/?) (done)

This is just a problem with putting tests into folders, because the current version (especially the name xmir/) seems illogical to me. At the current stage of the project, this is unprincipled, in fact a minor design issue.

2-1-substitute-applications.xsl:29-32: add unit-test for...

The puzzle 47-c539e2d9 from #47 has to be resolved:

@todo #47:30min add unit-test for transformation,
in which the input will be xmir with applications with polymorphic objects and
the expected result will be the same xmir with an applications with their
specialized versions.

The puzzle was created by @rultor on 15-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

1-1-coping.xsl:29-32: add unit-test for transformation,...

The puzzle 47-76b5d8f3 from #47 has to be resolved:

@todo #47:30min add unit-test for transformation,
in which the input will be xmir without a <speco/> section and
the expected result will be the same xmir with a <speco/> section
duplicating <aoi/>.

The puzzle was created by @rultor on 15-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

refactor transformations

The method of transformation has changed significantly, so it is necessary to change the structure of transformations in accordance with the rules from the paper

Maybe follow the principe "1 transformation -- 1 rule"

1-2-specialization.xsl:29-32: add unit-test for...

The puzzle 47-5318f6cb from #47 has to be resolved:

@todo #47:30min add unit-test for transformation,
in which the input will be xmir with a <speco/> section duplicating <aoi/> and
in the expected result will be the same xmir with a specialized objects
in the <speco/> section.

The puzzle was created by @rultor on 15-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

fix next-as-tuple attributes

In rule 7, Speco replaces write with with_* and choose first with_* attribute from current object. There is a bug. We need at least use with_* attribute in accordance to current object (return the same "type").

4-1-fence-tuples.xsl:28-31: add unit-test for...

The puzzle 68-f9ee8553 from #68 has to be resolved:

@todo #68:30min add unit-test for transformation,
in which the input will be xmir with object with fence attribute,
the expected result will be the same xmir with a *-as-tuple attribute
for this fence attribute.

The puzzle was created by @rultor on 28-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

add spec attribute

In #61 I need @spec for specialized versions with name of base polymorphic object. Let's implement it in separate issue

rules 4 and 7 are incorrect

TL;DR need to specialize next-as-tuple to avoid its polymorphism

According to rule 7, we must call one of the with-* attributes in the next-as-tuple attribute. According to rule 4, we have only one next-as-tuple. Also, we cannot create an analog of monitoring function (this requires reflection). Therefore, we cannot specialize more than one type in such conditions.

I suggest creating specialized versions of the next-as-tuple-* attribute, similar to with-*. This requires changing rules 4 (add specialization), 5 (we need to know the type of the argument) and 7 (to be more specific).

aoi removal

Let's add a command line option to configure the removal of the aoi section. I suggest using the --clear-aoi flag to remove this section:

$ java -jar speco.jar --dir=/tmp/xmir --target=/tmp/xmir2 --clear-aoi

The default behavior will save this section.

simple transformation

Let's implement a simple transformation. I should be able to run the tool like this:

$ java -jar speco.jar --dir=/tmp/xmir --target=/tmp/xmir2

Here, /tmp/xmir is the name of the directory with .xmir files, while /tmp/xmir2 is the name of the directory where modified files will be placed. The modification should do simple specialization.

rename dir

Now Speco executes with params:

$ java -jar speco.jar --dir=./tmp/xmir-in --target=./tmp/xmir-out

I think it would be more logical to rename --dir to --source

copy state in rule 3

In with-* attributes we need not only to create a new object, but also to copy the state of the current one. It is necessary to write tests for such cases and fix them.

3-1-add-with.xsl:28-31: add unit-test for transformation,...

The puzzle 64-2f390398 from #64 has to be resolved:

@todo #64:30min add unit-test for transformation,
in which the input will be xmir with polymorphic object and
the expected result will be the same xmir with a with-* attributes
for all specialized versions of this polymorphic object.

The puzzle was created by @rultor on 27-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

continuous integration

Let's add continuous integration using Github Actions. At each commit or PR, a job with the Maven build should be run:

$ mvn clean install -Pqulice

1-3-extension.xsl:29-31: add unit-test for...

The puzzle 47-276d8114 from #47 has to be resolved:

@todo #47:30min add unit-test for transformation,
in which the input will be xmir with a specialized objects in <speco/> section and
the expected result will be the same xmir with a specialized object in <objects/> section.

The puzzle was created by @rultor on 15-Feb-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

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.