private void addSpecMetadata(Spec spec) {
    AnnotationNode ann = new AnnotationNode(nodeCache.SpecMetadata);
    String pathname = spec.getAst().getModule().getContext().getName();
    String filename = new File(pathname).getName();
    ann.setMember(SpecMetadata.FILENAME, new ConstantExpression(filename));
    ann.setMember(SpecMetadata.LINE, primitiveConstExpression(spec.getAst().getLineNumber()));
    spec.getAst().addAnnotation(ann);
  }
Puts all spec information required at runtime into annotations
attached to class members.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/compiler/SpecAnnotator.java