MetaScript.js
function __err2code(program, err) {
            if (typeof err.stack !== 'string')
                return indent(program, 4);
            var match = /<anonymous>:(\d+):(\d+)\)/.exec(err.stack);
            if (!match) {
                return indent(program, 4);
            }
            var line = parseInt(match[1], 10)-1,
                start = line - 3,
                end = line + 4,
                lines = program.split("\n");
            if (start < 0) start = 0;
            if (end > lines.length) end = lines.length;
            var code = [];
            start = 0; end = lines.length;
            while (start < end) {
                code.push(start === line ? "--> "+lines[start] : "    "+lines[start]);
                start++;
            }
            return indent(code.join('\n'), 4);
        }
function __err2code(program, err) {
            if (typeof err.stack !== 'string')
                return indent(program, 4);
            var match = /<anonymous>:(\d+):(\d+)\)/.exec(err.stack);
            if (!match) {
                return indent(program, 4);
            }
            var line = parseInt(match[1], 10)-1,
                start = line - 3,
                end = line + 4,
                lines = program.split("\n");
            if (start < 0) start = 0;
            if (end > lines.length) end = lines.length;
            var code = [];
            start = 0; end = lines.length;
            while (start < end) {
                code.push(start === line ? "--> "+lines[start] : "    "+lines[start]);
                start++;
            }
            return indent(code.join('\n'), 4);
        }
function __err2code ( program , err ) { if ( typeof err . stack !== 'string' ) return indent ( program , 4 ) ; var match = / <anonymous>:(\d+):(\d+)\) / . exec ( err . stack ) ; if ( ! match ) { return indent ( program , 4 ) ; } var line = parseInt ( match [ 1 ] , 10 ) - 1 , start = line - 3 , end = line + 4 , lines = program . split ( "\n" ) ; if ( start < 0 ) start = 0 ; if ( end > lines . length ) end = lines . length ; var code = [ ] ; start = 0 ; end = lines . length ; while ( start < end ) { code . push ( start === line ? "--> " + lines [ start ] : "    " + lines [ start ] ) ; start ++ ; } return indent ( code . join ( '\n' ) , 4 ) ; }
Generates a code view of eval'ed code from an Error.
@param {string} program Failed program
@param {!Error} err Error caught
@returns {string} Code view
@inner
@private
Generates a code view of eval ed code from an Error .