dojo » _rhinoCurrentScriptViaJava
dojo._rhinoCurrentScriptViaJava
<script src="../../js/dojo.js"></script>
defined in dojo/_base/_loader/hostenv_rhino.js
Usage
function (depth) (view source)
var optLevel = Packages.org.mozilla.javascript.Context.getCurrentContext().getOptimizationLevel(); var caw = new java.io.CharArrayWriter(); var pw = new java.io.PrintWriter(caw); var exc = new java.lang.Exception(); var s = caw.toString(); // we have to exclude the ones with or without line numbers because they put double entries in: // at org.mozilla.javascript.gen.c3._c4(/Users/mda/Sites/burstproject/burst/Runtime.js:56) // at org.mozilla.javascript.gen.c3.call(/Users/mda/Sites/burstproject/burst/Runtime.js) var matches = s.match(/[^\(]*\.js\)/gi|>); if(!matches){ throw Error("cannot parse printStackTrace output: " + s); } // matches[0] is entire string, matches[1] is this function, matches[2] is caller, ... var fname = ((typeof depth != 'undefined')&&(depth)) ? matches[depth + 1] : matches[matches.length - 1]; var fname = matches[3]; if(!fname){ fname = matches[1]; } // print("got fname '" + fname + "' from stack string '" + s + "'"); if (!fname){ throw Error("could not find js file in printStackTrace output: " + s); } //print("Rhino getCurrentScriptURI returning '" + fname + "' from: " + s); return fname;
parameter | type | description |
---|---|---|
depth |