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.
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
The tool works according to an algorithm consisting of 7 transformation rules.
Rule 1:
<speco/>
node consisting of specialized <versions/>
nodes for all objects inferred by AOI;@name
-- name of the polymorphic object,@var
-- name of the polymorphic attribute of this object,@spec
-- name of the object that specializes this attribute;<objects/>
node by name @name
, but also changed attributes:
@name
replaced by @name_spec_@var_@spec
@spec
equal version@spec
<version/>
node) to the <objects/>
node.Rule 2:
Rule 3:
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:
memory
wrapper object;Rule 5:
Rule 6:
Rule 7:
*-as-tuple
attribute so that it returns a new object instead of changing itself by using the with-*
attribute.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+.