Exercise 0: Bootstrapping. ------------------------------------------------------------------------------- Ensure that you have the following software installed: - Java JDK 1.7 - Scala 2.10.2 - Apache Ant You may use other versions at your own risk :-) Download the source code and unpack the archive. Copy 'build.properties.example' to 'build.properties' and set your Scala path. Compile the analysis and create the 'defuse.jar' by running: $ ant build-jar On my machine this takes a few minutes and the created jar file is approximately 20 MB. Verify that the compilation was successful by running: $ java -jar defuse.jar This should produce information about command line options. Exercise 1: Analyzing a simple program. ------------------------------------------------------------------------------- Create the file 'helloworld.js' with the following content: function f(x, y) { return x + y; } var r = f(1, 2); __show__(r); Run the analysis on the program: $ java -jar defuse.jar helloworld.js What does the output tell you? Inspect the contents of the directory 'target/helloworld.js'. The __show__ function is a special analysis instruction useful for debugging. Find the 'JSGlobal' trait and look at the other analysis instructions. Exercise 2: The Polarity Domain. ------------------------------------------------------------------------------- Run the following program: var x = 0; while (__AnyBool__) { x = x + 2; } __show__(x); What result is printed? Why? Argue, that if equipped with the polarity lattice (ie. a lattice which tracks odd/even), the analysis can prove that x is always even. Find and carefully inspect the number type class (NumberClass) and its super classes (JoinLattice). Implement the Polarity lattice and equip the analysis with it by changing the 'Value' trait. You may use 'Polarity.scala.txt' as a starting point.