lib/coverage_apply.js
function countFunction () {
		var ret;
        if (isFirstLine) {
            isFirstLine = false;
            return ret;
        }
		if (this[0].start && analyzing.indexOf(this) < 0) {
			var defun = this[0].name === "defun";
			var lineId = this[0].start.line + lineOffset + ''; //this[0].name + ":" + this[0].start.line + ":" + this[0].start.pos;
			var fnName = this[1] || this[0].anonymousName || "(?)";
            var fnId = fnName + ':' + (this[0].start.line + lineOffset) + ":" + this[0].start.pos;
			var body = this[3];

			analyzing.push(this);

			// put a new function call inside the body, works also on empty functions
			if (options["function"]) {
				body.splice(0, 0, [ "stat",
					[ "call",
                        ["dot", ["name", "require"], "coverage_function"],
						[
							["string", moduleName],
							["string", fnId]
						]
					]
				]);
				// It would be great to instrument the 'exit' from a function
				// but it means tracking all return statements, maybe in the future...

				rememberFunction(fnId);
			}

			if (defun) {
				// 'defun' should also be remembered as statements
				rememberStatement(lineId);

				ret = [ "splice",
					[
						[ "stat",
							[ "call",
                                ["dot", ["name", "require"], "coverage_line"],
								[
									[ "string", moduleName],
									[ "string", lineId]
								]
							]
						],
						walker.walk(this)
					]
				];
			} else {
				ret = walker.walk(this);
			}

			analyzing.pop(this);

		}
		return ret;
	}
function countFunction () {
		var ret;
        if (isFirstLine) {
            isFirstLine = false;
            return ret;
        }
		if (this[0].start && analyzing.indexOf(this) < 0) {
			var defun = this[0].name === "defun";
			var lineId = this[0].start.line + lineOffset + ''; //this[0].name + ":" + this[0].start.line + ":" + this[0].start.pos;
			var fnName = this[1] || this[0].anonymousName || "(?)";
            var fnId = fnName + ':' + (this[0].start.line + lineOffset) + ":" + this[0].start.pos;
			var body = this[3];

			analyzing.push(this);

			// put a new function call inside the body, works also on empty functions
			if (options["function"]) {
				body.splice(0, 0, [ "stat",
					[ "call",
                        ["dot", ["name", "require"], "coverage_function"],
						[
							["string", moduleName],
							["string", fnId]
						]
					]
				]);
				// It would be great to instrument the 'exit' from a function
				// but it means tracking all return statements, maybe in the future...

				rememberFunction(fnId);
			}

			if (defun) {
				// 'defun' should also be remembered as statements
				rememberStatement(lineId);

				ret = [ "splice",
					[
						[ "stat",
							[ "call",
                                ["dot", ["name", "require"], "coverage_line"],
								[
									[ "string", moduleName],
									[ "string", lineId]
								]
							]
						],
						walker.walk(this)
					]
				];
			} else {
				ret = walker.walk(this);
			}

			analyzing.pop(this);

		}
		return ret;
	}
Instrumenting function strictly needed for statement coverage only in case of 'defun'
(function definition), however the block 'function' does not correspond to a new statement.
This method allows to track every function call (function coverage).

As far as I can tell, 'function' is different from 'defun' for the fact that 'defun'
refers to the global definition of a function
function something () {}    -> defun
something = function () {}  -> function
'function' doesn't need to be counted because the line is covered by 'name' or whatever
other block.

Strictly speaking full statement coverage does not imply function coverage only if there
are empty function, which however are empty!

The tracking for functions is also a bit different from countLine (except 'defun'). This
method assigns every function a name and tracks the history of every call throughout the
whole lifetime of the application, It's a sort of profiler.


The structure of 'this' is
'this[0]' node descriptor
'this[1]' string, name of the function or null
'this[2]' array of arguments names (string)
'this[3]' block with the function's body

As 'function' happens in the middle of a line, the instrumentation should be in the body.