+ All Categories
Home > Documents > Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT -...

Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT -...

Date post: 12-Sep-2020
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
13
SWAT - Software Analysis and Transformation Tips & Tricks for TUE students doing Architecture Reconstruction with Rascal Jurgen Vinju Davy Landman https://gist.github.com/jurgenvinju/8972255 http://update.rascal-mpl.org/{un,}stable See peach assignment 0 for install instruction And assignment 2 and Tonella & Potrich
Transcript
Page 1: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - Software Analysis and Transformation

Tips & Tricks for TUE students

doing Architecture Reconstruction with Rascal

Jurgen Vinju Davy Landman

https://gist.github.com/jurgenvinju/8972255 http://update.rascal-mpl.org/{un,}stable

!See peach assignment 0 for install instruction

And assignment 2 and Tonella & Potrich

Page 2: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Code

Model

Picture

GenerationExtraction

FormalizationVisualization

Transformation

Conversion

Analysis

Execution

Rendering

(Brueghel, Tower of Babel)

Rascal is a DSL for

meta programming

Page 3: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Extract Analyze SYnthesize

Source Code

Java project Eclipse JDT

Projects

Parser

Name resolver

Type

Rascal M3

AST

Model

loc

Your Rascal code

comprehensions visitors

functions patterns

relational operators string templates

Figure

Rascal Eclipse Lib

Editors

Image in Eclipse

View GraphViz

DOT

Page 4: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

UML & Object FlowSource Code

Rascal M3

AST

Model

loc

abstract

Flow ProgramYour code

not executable but flow is the same

as the original -

only handful of constructs

queries the flow program and the M3

model.

rel[loc,loc]Flow graph

builds basic UML diagram

& uses flow graph

to add/filter edges

Your code

UML Diagrams render

extract

filter &!propagate generate

Page 5: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Identifying code• Source code locations: loc type

• |project://MyProj/src/org/myproj/Fruit.java|!

• Structured names: loc type

• |java+class://java/util/List|

• |java+class://java/util/List| + “this” == |java+class://java/util/List/this|

• Back to code

• hyperlinks (if you extracted a full M3 model)

• IO::readFile(loc) produces a str with the contents

Page 6: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Getting facts• First have a compileable Eclipse project “eLib”

• import lang::java::jdt::m3::Core; import lang::java::jdt::m3::AST;

• m = createM3FromEclipseProject(|project://eLib|);

• import lang::ofg::ast::Java2OFG; import lang::ofg::ast::FlowLanguage;

• p = createOFG(|project://eLib|);

• Now you have:

• an M3 model in m

• a flow program in p

• hyperlinks

Page 7: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

src

m3 flow program???

Page 8: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

src

m3 flow program???

Page 9: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Initial flow graph

• a relation as a graph

• uses generators and matching to project out of program

• uses “+” on locs to build new implicit identifiers

• uses “index” from List to pair formal/actual parameters

Page 10: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Flow propagation sketch

• use “solve” for fixed point

• projection “g[n]” is succ, revert and project “g<to,from>[n]” is pred

• comprehensions for next solution

Page 11: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Debugging• IO::println, iprintln,

• util::ValueUI::text,tree,graph

• interactive debugger (just put a breakpoint)

• online manual?! http://tutor.rascal-mpl.org, also in Eclipse Tutor View

• online questions?! http://ask.rascal-mpl.org

• Issue tracker at github.org

Page 12: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Caveats

• No type checker (coming soon)

• No incremental parsing (one error at a time)

• Slowness (compiler coming soon)

• But: consider doing this from scratch :-)

Page 13: Tips & Tricks for TUE students doing Architecture ...aserebre/2IS55/2013-2014/TipsAndTricks...SWAT - SoftWare Analysis and Transformation Extract Analyze SYnthesize Source Code Java

SWAT - SoftWare Analysis and Transformation

Demo• Inheritance diagram from Eclipse Java project

• Get code into an Eclipse Java project

• Start a Rascal project

• Start a Rascal console

• Browse library code and tutorial

• Script the tool

• https://gist.github.com/jurgenvinju/4999479


Recommended