threadstack-691011: stack are now per 'thread' not 'class'
threadstack-691011: stack are now per 'thread' not 'class'

Previously asynchronous operations (particularly those in a loop) could
use the wrong stack data (used to explain where things went wrong).
In general we should clone class data when we go async, which makes the
class structure here a problem.

So this patch does a number of things:
* It converts function names from Templater.prototype._funcName to
  funcName, and removes the class structure which wasn't used properly
* It adds a 'state' parameter to the start of most functions which does
  the equivalent of 'this' but is easily cloned
* When we act asynchronously, the state is cloned for use in the callback
* It adds a cloneState function to help with this state cloning
* It inlines a number of regexp definitions which were just separated
  from where they were used, talking to JimB it seems that this is not a
  useful performance optimisation, and it made the code less readable.
* It adds a number of blank lines at the start to keep the error line
  numbers in sync with other implementations (i.e. firefox) which have
  a longer module header.

Signed-off-by: Joe Walker <7a17872fbb32c7d760c9a16ee3076daead11efcf@mozilla.com>

mozilla/gcli,mozilla/gcli,mozilla/gcli,joewalker/gcli,joewalker/gcli