| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 40f29dd commit 1c7cd4a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,9 @@ | |||
| 35 | 35 | if (!x) throw new Error(msg || 'assertion error'); | |
| 36 | 36 | }; | |
| 37 | 37 | ||
| 38 | - var evals = process.binding('evals'); | ||
| 38 | + var Script = process.binding('evals').Script; | ||
| 39 | + var runInThisContext = Script.runInThisContext; | ||
| 40 | + var runInNewContext = Script.runInNewContext; | ||
| 39 | 41 | ||
| 40 | 42 | // lazy loaded. | |
| 41 | 43 | var constants; | |
@@ -86,7 +88,7 @@ | |||
| 86 | 88 | if (internalModuleCache[id]) return internalModuleCache[id].exports; | |
| 87 | 89 | if (!natives[id]) throw new Error('No such native module ' + id); | |
| 88 | 90 | ||
| 89 | - var fn = evals.Script.runInThisContext( | ||
| 91 | + var fn = runInThisContext( | ||
| 90 | 92 | '(function (module, exports, require) {' + natives[id] + '\n})', | |
| 91 | 93 | id + '.js'); | |
| 92 | 94 | var m = {id: id, exports: {}}; | |
@@ -332,7 +334,7 @@ | |||
| 332 | 334 | sandbox.global = sandbox; | |
| 333 | 335 | sandbox.root = root; | |
| 334 | 336 | ||
| 335 | - return evals.Script.runInNewContext(content, sandbox, filename); | ||
| 337 | + return runInNewContext(content, sandbox, filename); | ||
| 336 | 338 | } else { | |
| 337 | 339 | debug('load root module'); | |
| 338 | 340 | // root module | |
@@ -342,7 +344,7 @@ | |||
| 342 | 344 | global.__dirname = dirname; | |
| 343 | 345 | global.module = self; | |
| 344 | 346 | ||
| 345 | - return evals.Script.runInThisContext(content, filename); | ||
| 347 | + return runInThisContext(content, filename); | ||
| 346 | 348 | } | |
| 347 | 349 | ||
| 348 | 350 | } else { | |
@@ -352,7 +354,7 @@ | |||
| 352 | 354 | content + | |
| 353 | 355 | '\n});'; | |
| 354 | 356 | ||
| 355 | - var compiledWrapper = evals.Script.runInThisContext(wrapper, filename); | ||
| 357 | + var compiledWrapper = runInThisContext(wrapper, filename); | ||
| 356 | 358 | if (filename === process.argv[1] && global.v8debug) { | |
| 357 | 359 | global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0); | |
| 358 | 360 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -280,6 +280,14 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) { | |||
| 280 | 280 | ? args[filename_index]->ToString() | |
| 281 | 281 | : String::New("evalmachine.<anonymous>"); | |
| 282 | 282 | ||
| 283 | + const int display_error_index = args.Length() - 1; | ||
| 284 | + bool display_error = false; | ||
| 285 | + if (args.Length() > display_error_index && | ||
| 286 | + args[display_error_index]->IsBoolean() && | ||
| 287 | + args[display_error_index]->BooleanValue() == true) { | ||
| 288 | + display_error = true; | ||
| 289 | + } | ||
| 290 | + | ||
| 283 | 291 | Persistent<Context> context; | |
| 284 | 292 | ||
| 285 | 293 | Local<Array> keys; | |
@@ -325,7 +333,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) { | |||
| 325 | 333 | : Script::New(code, filename); | |
| 326 | 334 | if (script.IsEmpty()) { | |
| 327 | 335 | // FIXME UGLY HACK TO DISPLAY SYNTAX ERRORS. | |
| 328 | - DisplayExceptionLine(try_catch); | ||
| 336 | + if (display_error) DisplayExceptionLine(try_catch); | ||
| 329 | 337 | ||
| 330 | 338 | // Hack because I can't get a proper stacktrace on SyntaxError | |
| 331 | 339 | return try_catch.ReThrow(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments