1 / 9

Implémentations de Junior

Implémentations de Junior. Rewrite : implémentation directe des règles de réécriture Replace : Rewrite + optimisation des créations de structures intermédiaires Storm, Simple : grand nombre d’événements …. b. t’, E’. t, E. STOP. Stop, E. Nothing, E. Réécritures.

ingrid
Download Presentation

Implémentations de Junior

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Implémentations de Junior • Rewrite : implémentation directe des règles de réécriture • Replace : Rewrite + optimisation des créations de structures intermédiaires • Storm, Simple : grand nombre d’événements • …

  2. b t’, E’ t, E STOP Stop, E Nothing, E Réécritures MicroState s = t.rewrite(E); b = s.flag; t’ = s.term; E’ est la nouvelle valeur de E public class Stop extends Instruction { public MicroState rewrite(EnvironmentImpl env){ return new MicroState(STOP,new Nothing()); } }

  3. TERM u’, E’’ u, E’ b t’, E’ t, E b b u’, E’’ t’, E’ b = STOP ou b = SUSP Seq(t,u), E t, E b Seq(t’,u), E’ Seq(t,u), E Séquence Création d’une nouvelle instruction public class Seq extends BinaryInstruction { public MicroState rewrite(EnvironmentImpl env){ MicroState s = left.rewrite(env); if (TERM == s.flag) return right.rewrite(env); return new MicroState(s.flag,new Seq(s.term,right)); } }

  4. Instant public class Instant extends UnaryInstruction { public MicroState rewrite(EnvironmentImpl env){ MicroState s = body.rewrite(env) ; if (s.flag != SUSP) return new MicroState(s.flag,new Instant(s.term)); if (env.move) env.move = false; else env.eoi = true; return new Instant(s.term).rewrite(env); } } b SUSP t’, E’ t, E Instant(t’), E’[eoi = vrai] move(E’) = faux u, E’’ b u, E’’ Instant(t), E

  5. b2 u’, E’ u, E C(b1,b2) Par d1,d2(t,u’), E’ Par b1,SUSP(t,u), E Parallélisme public class Par extends BinaryInstruction { final public byte leftFlag, rightFlag; public MicroState result(Instruction l, Instruction r, byte lf, byte rf){ byte b = SUSP, nlf = lf, nrf = rf; if (lf != SUSP && rf != SUSP){ b = (lf==TERM && rf==TERM) ? TERM : STOP; if (lf==STOP) nlf = SUSP; if (rf==STOP) nrf = SUSP; } return new MicroState(b, new Par(l,r,nlf,nrf)); }

  6. Parallélisme - 2 b1 t’, E’ t, E C(b1,b2) Par d1,d2(t’,u), E’ Par SUSP,b2(t,u), E public MicroState rewrite(EnvironmentImpl env){ if (leftFlag == SUSP && rightFlag != SUSP){ MicroState s = left.rewrite(env); return result (s.term,right,s.flag,rightFlag); } if (leftFlag != SUSP && rightFlag == SUSP){ MicroState s = right.rewrite(env); return result (left,s.term,leftFlag,s.flag); } MicroState ls = left.rewrite(env), rs = right.rewrite(env); return result (ls.term,rs.term,ls.flag,rs.flag); } b2 b1 u’, E’’ u, E’ t’, E’ t, E C(b1,b2) Par d1,d2(t’,u’), E’’ Par SUSP,SUSP(t,u), E

  7. Await public class Await extends Instruction { final public Config config; public MicroState rewrite(EnvironmentImpl env){ if (config.sat(env)) return new MicroState((env.eoi ? STOP : TERM), new Nothing()); if (config.unsat(env)) return new MicroState(STOP,this); return new MicroState(SUSP,this); } } Await(Not(S))

  8. Until public class Until extends BinaryInstruction { final public Config config; public MicroState rewrite(EnvironmentImpl env){ MicroState s = left.rewrite(env); if (STOP != s.flag) return new MicroState(s.flag, new Until(config,s.term,right)); return new UntilStar(config,s.term,right).rewrite(env); } } public class UntilStar extends BinaryInstruction { final public Config config; public MicroState rewrite(EnvironmentImpl env){ if (config.sat(env)){ if (! env.eoi) return right.rewrite(env); else return new MicroState(STOP,right); } if (config.unsat(env)) return new MicroState(STOP,new Until(config,left,right)); return new MicroState(SUSP,this); } }

  9. Conclusion • Rewrite = implémentation directe des règles de réécritures • Environ 500 lignes de code = implémentation de référence • Non optimisée : termes intermédiaires inutiles • Replace = Rewrite + changements d’états des instructions public class Stop extends Instruction { boolean b = false; public byte rewrite(){ if (b == false){ b = true; return STOP; } return TERM; } }

More Related