A Self-Replication Algorithm to Flexibly Match Join Point Traces - - PowerPoint PPT Presentation

a self replication algorithm to flexibly match join point
SMART_READER_LITE
LIVE PREVIEW

A Self-Replication Algorithm to Flexibly Match Join Point Traces - - PowerPoint PPT Presentation

A Self-Replication Algorithm to Flexibly Match Join Point Traces Paul Leger and ric Tanter Department of Computer Science University of Chile Stateful Aspects In a Nutshell An aspect can only match a single join point A stateful aspect can


slide-1
SLIDE 1

A Self-Replication Algorithm to Flexibly Match Join Point Traces

Paul Leger and Éric Tanter Department of Computer Science University of Chile

slide-2
SLIDE 2

2

Stateful Aspects In a Nutshell

An aspect can only match a single join point A stateful aspect can match a join point trace

[Douence+2005]

Stateful aspects are used in security flaws, application errors, and crosscutting concerns

a b c d

slide-3
SLIDE 3

3

Algorithms to Match Join Point Traces

a a b a b

Single Match Sequence Join Point Trace Or this Single Match Multiple Matches

V 1 1

Multiple Matches with v=1

The matches of a sequence depend on the matching semantics of the algorithm

slide-4
SLIDE 4

4

Fixed Semantics to Match Traces

tracematch() { sym edit after: call(Editor.edit()); edit edit edit { Editor.save(); } } sym save after: call(Editor.save());

To adapt the matching semantics of an algorithm, developers code around it

Autosave feature: the document is automatically saved every three editions

Tracematches support multiple matches An artificial symbol is added to support single match

edit → edit → edit → edit → edit → edit edit → edit → edit → save → edit → edit → edit → save

slide-5
SLIDE 5

Matcher Cells

An algorithm to flexibly match join point traces, where developers can define their own semantics Based on self-replication behavior

slide-6
SLIDE 6

6

Self-Replicating Behavior In a Nutshell

creation nothing death

Reactions of biological cells into a solution to a reagent trace

Cell solution reagent

slide-7
SLIDE 7

7

Matcher Cells

C0 = { }

a1 b

R = {…} Match cell Seed

a b

v

A cell contains a sequence and bound variables, and a reagent corresponds to a join point

a b

v

a b

v

b v=1 b v=1 a b

v

v=1

slide-8
SLIDE 8

Examples of Matching Semantics with Matcher Cells

With simple reaction rules, Matcher Cells makes it possible to express a wide range of matching semantics

slide-9
SLIDE 9

9

Multiple Matches R = {apply reaction} C0 = { }

b

a b b

a

a b a b b a b b

a

b a b b

slide-10
SLIDE 10

10

Single Match R = {apply reaction, kill creators} C0 = { }

b

a

a b

a

b

b

a b

slide-11
SLIDE 11

11

Single Match at a Time

(the autosave feature solution)

R = {apply reaction, kill creators, add seed} C0 = { }

b

a

a b

a

b

b

a b a b

slide-12
SLIDE 12

12

Life-time for a Match

R = {apply reaction, kill creators, trace life-time, add seed}

C0 = { }

b

a

a b a b

Δt > time

a b

slide-13
SLIDE 13

13

Only the First Match

R = {apply reaction, kill all cells after match}

C0 = { }

a b

v z

v=z

a b

v z

v=z

a1

a b

v z

v=z

b

v=1

v=z

a2

a b

v z

v=z

b

v=1

v=z

b

v=2

v=z

b2

v=2, z =2

a2 b2

slide-14
SLIDE 14

An implementation of Matcher Cells

Matching semantics is defined by the composition of rules (small functions)

slide-15
SLIDE 15

15

Reaction of a Cell

react: Cell x JP → Cell

  • returns a new cell if matches
  • returns the same cell if does not match the join point
slide-16
SLIDE 16

16

Rules

rule: List<Cell> x JP → List<Cell>

var applyReaction = function (cells, jp) { return removeDuplicates(append(cells, map(cells, react, jp))); } var killCreators = function(rule) { return function (cells, jp) { var nextCells = rule (cells, jp); return difference(nextCells, getCreators(nextCells, cells)); } } var addSeed = function(sequence) { return function (rule) { return function (cells, jp) { var nextCells = rule(cells, jp); return length(nextCells) == 0 || onlyMatchCells(nextCells)? append(nextCells,[createSeed(sequence)]): nextCells; }}}

The elemental rule Rule designators allow rule composition Rule designators can be parametrized

slide-17
SLIDE 17

17

Multiple Matches

b a b b a a b b a b b a b a b b

var multipleMatches = applyReaction;

slide-18
SLIDE 18

18

Single Match

var singleMatch = killCreators(applyReaction);

b a a b a b b

slide-19
SLIDE 19

19

Single Match at a Time

var singleMatchAtATime = addSeed(sequence)(killCreators(applyReaction));

b a a b a b b a b

slide-20
SLIDE 20

20

Life-time for a Match

b a a b …

Δt > time

a b

var lifeTimeForAMatch = addSeed(sequence)(traceLifeTime(delta)(killCreators(applyReaction)));

slide-21
SLIDE 21

21

Only the First Match

var onlyTheFirstMatch = killAllCellsAfterMatch(applyReaction);

a b v z v=z a1 a b v z v=z b v=1 v=z a2 a b v z v=z b v=1 v=z b v=2 v=z a2

b2

v=2, z =2

b2

slide-22
SLIDE 22

22

Conclusions

The Matcher Cells algorithm

  • allows developers to define their own matching semantics
  • using the composition of reaction rules of self-replication

algorithms Application We implement an expressive and open stateful aspect language using Matcher Cells (http://pleiad.cl/otm)

Try it on-line: http://pleiad.cl/otm/matchercells

slide-23
SLIDE 23

23

Adding Customized Information to Cells

react: Cell x JP x [Seq x Env → Cell] → Cell

Some rules require that all cells contain

customized information

For example, the lifeTimeForAMatch rule requires a cell time

function (seq, env) { env = env.bind(“time”, getTime()); return env; };

slide-24
SLIDE 24

24

Independence between Sequence Language and Matcher Cells

  • The reaction of a cell strongly depends on the sequence

language used

  • When a cell matches a join point and/or binds a variable,

the reaction of a cell has to return the next step in the matching

  • Apart from the previous restriction, Matcher Cells

does not impose another restriction to the sequence language