};
public static Instruction[] getFib(Ruby runtime, int n){
return new Instruction[] {
// local var n declared (argument)
new Instruction(YARVInstructions.PUTOBJECT, runtime.newFixnum(n)), // fib index
new Instruction(YARVInstructions.SETLOCAL, 0),
// method begins here
// local var i declared
new Instruction(YARVInstructions.PUTOBJECT, runtime.newFixnum(0)),
new Instruction(YARVInstructions.SETLOCAL, 1),
// local var j declared
new Instruction(YARVInstructions.PUTOBJECT, runtime.newFixnum(1)),
new Instruction(YARVInstructions.SETLOCAL, 2),
// local var cur declared
new Instruction(YARVInstructions.PUTOBJECT, runtime.newFixnum(1)),
new Instruction(YARVInstructions.SETLOCAL, 3),
// while begins here, instruction 8
new Instruction(YARVInstructions.GETLOCAL, 3),
new Instruction(YARVInstructions.GETLOCAL, 0),
new Instruction(YARVInstructions.SEND, "<=", 1, null, 0),
new Instruction(YARVInstructions.BRANCHUNLESS, 25),
// local var k declared, k = i
new Instruction(YARVInstructions.GETLOCAL, 1),
new Instruction(YARVInstructions.SETLOCAL, 4),
// i = j
new Instruction(YARVInstructions.GETLOCAL, 2),
new Instruction(YARVInstructions.SETLOCAL, 1),
// j = k + j
new Instruction(YARVInstructions.GETLOCAL, 4),
new Instruction(YARVInstructions.GETLOCAL, 2),
new Instruction(YARVInstructions.SEND, "+", 1, null, 0),
new Instruction(YARVInstructions.SETLOCAL, 2),
// cur = cur + 1
new Instruction(YARVInstructions.GETLOCAL, 3),
new Instruction(YARVInstructions.PUTOBJECT, runtime.newFixnum(1)),
new Instruction(YARVInstructions.SEND, "+", 1, null, 0),
new Instruction(YARVInstructions.SETLOCAL, 3),
// end while
new Instruction(YARVInstructions.JUMP, 8),
// return i, instruction 25
new Instruction(YARVInstructions.GETLOCAL, 1)
};
};