Lab for Automated Reasoning and Analysis LARA

Discussion of parsing homework

Problem 1: Branch Instruction

  • Translate the for-loop and if-condition to branch instructions.
  • Convert the function to byte code.
  • Use CafeBabe to generate the class file.
def bubblesort( xs : Array[Int]) : Array[Int] = {
  for( i <- 0 until (xs.length - 1))
    for( j <- 0 until (xs.length - i - 1))
      if( xs(j) > xs(j+1)) {
        var tmp = xs(j)
        xs(j) = xs(j + 1)
        xs(j + 1) = tmp
      }
  xs
}
 
cc10/exercises_09.txt · Last modified: 2010/11/29 02:17 by vkuncak
 
© EPFL 2018 - Legal notice