Logic-based program transformation in symbiosis with Eclipse

642 views

Published on

"Logic-based program transformation in symbiosis with Eclipse" as presented at the 2011 Seminar Series on Advanced Techniques & Tools for Software Evolution in Koblenz.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
642
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Logic-based program transformation in symbiosis with Eclipse

  1. 1. Coen De Roover Andy Kellens Carlos NogueraSoftware Languages Lab, Brussels Logic-based program transformation in symbiosis with Eclipse
  2. 2. Menu logic program queries ... ... in symbiosis with Eclipse. (Smalltalk intermezzo)logic-based program transformation.
  3. 3. Logic program queries... over an Eclipse project logic evaluator finds solutions program query quantifies over reified ASTs
  4. 4. Solutions to the logic program query... over a dummy Eclipse project single solution consists of variable bindings variable binding reified AST node
  5. 5. Why aren’t all tool builders using this?... prevalent reification encumbers exploiting query solutions node(a,[node(b,[]),node(c,[node(d,[])])). variable binding a b c d to be found in IDE
  6. 6. Facilitating adoption by tool builders... reify(ASTNode) = ASTNode example application: exploiting solutions to a query in Eclipse plugins
  7. 7. Facilitating adoption by tool builders... reify(ASTNode) = ASTNode example application: querying reified nodes for their context
  8. 8. } } public class SuperLogLeaf extends OnlyLoggingLeaf {Facilitating }, jtExpression(?instance){ public void acceptVisitor(ComponentVisitor v) { super.acceptVisitor(v); new ?singleton(?argList) }, v.visitSuperLogLeaf(this);adoption by absolutelyNot(?instance } equals: ?uniqueInstance) } public class MustAliasLeaf extends Component {developersif jtStatement(?s){ for(?initList; ?iterator.hasNext(); ?iterator.next(); public void acceptVisitor(ComponentVisitor v) { ?updList) temp = this; alias."); System.out.println("Must Component v.visitMustAliasLeaf(temp);... example-driven queries } } } public class MayAliasLeaf extends Component {if jtMethodDeclaration(?m){ public Object m(Object o) { public static void main(String[] args) { if(getInput() % 2 == 0) solutions java.util.Scanner(?argList); o; ?scanner := new include return else implementation variants ?scanner.close(); return new MayAliasLeaf(); found by consulting ?scanner.next(); } public void acceptVisitor(ComponentVisitor v) { } program analyses System.out.println("May alias."); v.visitMayAliasLeaf((MayAliasLeaf)m(this)); } } }if jtClassDeclaration(?class){ class !Composite extends* Component { ?modList ?type acceptVisitor(?t ?v) { System.out.println(?string); ?v.?visitMethod(this); } } exemplify through} familiar code templates
  9. 9. One more thing... for those who develop Java tools in Smalltalk all three of you ;) inspector on Smalltalk proxy for Java object
  10. 10. One morething Smalltalk FFI C call Java JNI... demystified S proxy J for J delegates to object object program Smalltalk program sends Java receives message message J proxy S delegates to for S object object Smalltalk Java native C callback callback handler method Smalltalk VM Java VM
  11. 11. One more thing... programming in a Smalltalk-Java hybridshowProgress: label complete: work while: block closure as an argument | job listener result promise | promise := Smalltalk.Promise new. job := self new_String: label asJavaValue creating a promise IBaristaRunnableWithProgressAndStatus: [:m | m beginTask_String: label asJavaValue int: work asJavaValue. result := [block value] on: Smalltalk.IncrementNotification do: [:ex | m worked_int: 1. resuming a Smalltalk exception ex resume]. m done. JavaWorld.org.eclipse.core.runtime.Status get_OK_STATUS]. listener := Smalltalk.BaristaJobListener new. listener doneBlock: [:event | promise value: result]. job addJobChangeListener_IJobChangeListener: listener. job setUser_boolean: true. job schedule. resolving the Smalltalk promise ^promise value when the Eclipse job finishes waiting for the value of the promise
  12. 12. Towards program transformation... by means of pattern-action rules a la CTs [Kniesel et al.]definition introduceExplicitThis(?e): jtExpression(?e){?message(?argList)}), [?e parentMethodDeclaration isStatic not], => ?e becomes: {this.?message(?argList)})execution if <introduceExplicitThis(?e)> execute for each transformation rule: actions are executed for each matching ast node variable bindings can be passed between rules changes are committed to the workspace after all rules have been executed Smalltalk side is notified of changes through a listener
  13. 13. Towards program transformation... by means of pattern-action rules in symbiosis with Eclipse rewriter of Eclispe records modifications when committed to workspace produces an undo action retains formatting
  14. 14. Towards program transformation... code manipulation actions in symbiosis with Eclipsetemplate ?e becomes: {this.?message(?argList)}new node ?this equals: [?e getAST newThisExpression], ?e equals: methodInvocation(?this, ?ta, ?name, ?args), ?e becomes: methodInvocation(?this, ?ta, ?name, ?args)compound term ?e equals: methodInvocation(?this, ?ta, ?name, ?args), ?e becomes: methodInvocation(thisExpression([nil]), ?ta, ?name, ?args)compound term with templates ?e equals: methodInvocation(?this, ?ta, ?name, ?args), ?e becomes:methodInvocation({this}, ?typeArguments, ?name, ?arguments) add:/2, insertBefore:/2, insertAfter:/2
  15. 15. Conclusions... and future workenabled by reification through symbiosis unique in logic program querying, but trivializes implementationfor now, just a proof of concept explore design space of transformation languageprogram transformation by example generalize from the identity transformation on a code snippetexploit analyses in transformations towards “refactoring” for parallelization
  16. 16. Freely available... website will be launched soon tabled logic evaluator regular path queries example-driven queries access to Soot analyses Eclipse extension points

×