2 Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
9 * SpiderMonkey host environment
12 if(dojo.config["baseUrl"]){
13 dojo.baseUrl = dojo.config["baseUrl"];
18 dojo._name = 'spidermonkey';
21 dojo.isSpidermonkey = {
22 // summary: Detect spidermonkey
26 dojo.isSpidermonkey = true;
27 dojo.exit = function(exitcode){
31 if(typeof print == "function"){
32 console.debug = print;
35 if(typeof line2pc == 'undefined'){
36 throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global");
39 dojo._spidermonkeyCurrentFile = function(depth){
41 // This is a hack that determines the current script file by parsing a
42 // generated stack trace (relying on the non-standard "stack" member variable
43 // of the SpiderMonkey Error object).
45 // If param depth is passed in, it'll return the script file which is that far down
46 // the stack, but that does require that you know how deep your stack is when you are
51 throw Error("whatever");
55 // lines are like: bu_getCurrentScriptURI_spidermonkey("ScriptLoader.js")@burst/Runtime.js:101
56 var matches = s.match(/[^@]*\.js/gi);
58 throw Error("could not parse stack string: '" + s + "'");
60 var fname = (typeof depth != 'undefined' && depth) ? matches[depth + 1] : matches[matches.length - 1];
62 throw Error("could not find file name in stack string '" + s + "'");
64 //print("SpiderMonkeyRuntime got fname '" + fname + "' from stack string '" + s + "'");
68 // print(dojo._spidermonkeyCurrentFile(0));
70 dojo._loadUri = function(uri){
71 // spidermonkey load() evaluates the contents into the global scope (which
73 // TODO: sigh, load() does not return a useful value.
74 // Perhaps it is returning the value of the last thing evaluated?
76 // console.log("spidermonkey load(", uri, ") returned ", ok);
80 //Register any module paths set up in djConfig. Need to do this
81 //in the hostenvs since hostenv_browser can read djConfig from a
82 //script tag's attribute.
83 if(dojo.config["modulePaths"]){
84 for(var param in dojo.config["modulePaths"]){
85 dojo.registerModulePath(param, dojo.config["modulePaths"][param]);