console.log('impl Op {');
console.log(' pub fn args(&self) -> uint {');
console.log(' match *self {');
bops.forEach(function(bc, i) {
console.log(' Op_' + bc.name + ' => ' + bc.args + comma(i));
});
console.log(' }');
console.log(' }');
console.log(' pub fn stackpush(&self) -> uint {');
console.log(' match *self {');
bops.forEach(function(bc, i) {
console.log(' Op_' + bc.name + ' => ' + bc.stackpush() + comma(i));
});
console.log(' }');
console.log(' }');
console.log(' pub fn stackpop(&self, args: &[int]) -> uint {');
console.log(' match *self {');
bops.forEach(function(bc, i) {
var stackpop = bc.stackpop();
if (bc.name === 'invoke') {
stackpop = '(args[0] as uint) + 2';
}
console.log(' Op_' + bc.name + ' => ' + stackpop + comma(i));
});
console.log(' }');
console.log(' }');
console.log(' pub fn new_from_uint(val: uint) -> Op {');
console.log(' match val {');
bops.forEach(function(bc, i) {
console.log(' ' + i + ' => Op_' + bc.name + ',');
});
console.log(' _ => fail!()');
console.log(' }');
console.log(' }');
console.log('}');