Let's add @Impure annotation to some atoms, such as EOposix$EOφ and EOfile$EOsize.
Then, let's create new decorator PhSticky that should decorate all objects created by new in the code we generate by to-java.xsl.
Let's modify the signature of the Phi.take(String) method. It should return a tuple:
<Phi, Boolean> take(String);
Before calling take() of the decoratee, PhSticky should call toφ() (new method) on it and get φ-expression of the object, for example:
new PhSticky(
new PhWith(
new PhMethod(new Random(), "plus"),
42
)
).take("times")
This should lead to calculating this expression:
Then, it should try to find the expression in a static hash map. If it's found, PhSticky should return the object the expression maps to. If not, it should call take(String).
Then, when take(String) returns the result, PhSticky, should save it to the hash map, if the second part of the tuple (boolean) is true.
Let's add
@Impureannotation to some atoms, such asEOposix$EOφandEOfile$EOsize.Then, let's create new decorator
PhStickythat should decorate all objects created bynewin the code we generate byto-java.xsl.Let's modify the signature of the
Phi.take(String)method. It should return a tuple:Before calling
take()of the decoratee,PhStickyshould calltoφ()(new method) on it and get φ-expression of the object, for example:This should lead to calculating this expression:
Then, it should try to find the expression in a static hash map. If it's found,
PhStickyshould return the object the expression maps to. If not, it should calltake(String).Then, when
take(String)returns the result,PhSticky, should save it to the hash map, if the second part of the tuple (boolean) is true.