anchor.diff:  
       // Call each global method once.
       for (int i = 0; i < globalMethods.length; i++) {
  -      emitLn('try {');
  -      indent += 2;
  -      emitLn("", newline: false);
  -      emitCall(1, "$methodName${i}", globalMethods[i]);
  -      emit(";", newline: true);
  -      indent -= 2;
  -      emitLn('} catch (exception, stackTrace) {');
  -      indent += 2;
  -      emitLn("print('$methodName$i throws');");
  -      indent -= 2;
  -      emitLn('}');
  +      emitTryCatchFinally(() {
  +        emitCall(1, "$methodName${i}", globalMethods[i]);
  +      }, () {
  +        emitLn("print('$methodName$i throws');");
  +      });
       }
   
       // Call each class method once.
       for (int i = 0; i < classMethods.length; i++) {
         for (int j = 0; j < classMethods[i].length; j++) {
  -        emitLn('try {');
  -        indent += 2;
  -        emitLn("", newline: false);
  -        emitCall(1, "X${i}().$methodName${i}_${j}", classMethods[i][j]);
  -        emit(";", newline: true);
  -        indent -= 2;
  -        emitLn('} catch (exception, stackTrace) {');
  -        indent += 2;
  -        emitLn("print('X${i}().$methodName${i}_${j}() throws');");
  -        indent -= 2;
  -        emitLn('}');
  -      }
  -    }
  -
  -    emitLn('try {');
  -    indent += 2;
  -    emitLn('X${classFields.length - 1}().run();');
  -    indent -= 2;
  -    emitLn('} catch (exception, stackTrace) {');
  -    indent += 2;
  -    emitLn("print('X${classFields.length - 1}().run() throws');");
  -    indent -= 2;
  -    emitLn('} finally {');
  -    indent += 2;
  -    emitLn("print('", newline: false);
  -    for (int i = 0; i < globalVars.length; i++) {
  -      emit('\$$varName$i\\n');
  -    }
  -    emit("');", newline: true);
  -    indent -= 2;
  -    emitLn('}');
  +        emitTryCatchFinally(() {
  +          emitCall(1, "X${i}().$methodName${i}_${j}", classMethods[i][j]);
  +        }, () {
  +          emitLn("print('X${i}().$methodName${i}_${j}() throws');");
  +        });
  +      }
  +      // Call each virtual class method once.
  +      int parentClass = classParents[i];
  +      while (parentClass >= 0) {
  +        if (virtualClassMethods[i].containsKey(parentClass)) {
  +          for (int j = 0; j < virtualClassMethods[i][parentClass].length; j++) {
  +            emitTryCatchFinally(() {
  +              emitCall(1, "X${i}().$methodName${parentClass}_${j}",
  +                  classMethods[parentClass][j]);
  +            }, () {
  +              emitLn(
  +                  "print('X${i}().$methodName${parentClass}_${j}() throws');");
  +            });
  +          }
  +        }
  +        parentClass = classParents[parentClass];
  +      }
  +    }
  +
  +    emitTryCatchFinally(() {
  +      emit('X${classFields.length - 1}().run()');
  +    }, () {
  +      emitLn("print('X${classFields.length - 1}().run() throws');");
  +    }, finallyBody: () {
  +      emitLn("print('", newline: false);
  +      for (int i = 0; i < globalVars.length; i++) {
  +        emit('\$$varName$i\\n');
  +      }
  +      emit("');", newline: true);
  +    });
       indent -= 2;
       emitLn('}');
     }
  
positive.code:   // Types of global variables.
    List<DartType> globalVars;
  
    // Names of currenty active iterator variables.
    // These are tracked to avoid modifications within the loop body,
    // which can lead to infinite loops.
    List<String> iterVars;
  
negative.code:       }
      }
      currentClass = currentClassTmp;
      virtualClassMethods.add(vcm);
    }
  
    void emitClasses() {
  