| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 // Create a new execution environment containing the built-in | 208 // Create a new execution environment containing the built-in |
| 209 // functions | 209 // functions |
| 210 v8::Handle<v8::Context> context = v8::Context::New(NULL, global); | 210 v8::Handle<v8::Context> context = v8::Context::New(NULL, global); |
| 211 // Enter the newly created execution environment. | 211 // Enter the newly created execution environment. |
| 212 v8::Context::Scope context_scope(context); | 212 v8::Context::Scope context_scope(context); |
| 213 | 213 |
| 214 #ifdef ENABLE_DEBUGGER_SUPPORT | 214 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 215 debug_message_context = v8::Persistent<v8::Context>::New(context); | 215 debug_message_context = v8::Persistent<v8::Context>::New(context); |
| 216 | 216 |
| 217 v8::Locker locker; | 217 v8::Locker locker(v8::Isolate::GetCurrent()); |
| 218 | 218 |
| 219 if (support_callback) { | 219 if (support_callback) { |
| 220 v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); | 220 v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); |
| 221 } | 221 } |
| 222 | 222 |
| 223 if (port_number != -1) { | 223 if (port_number != -1) { |
| 224 v8::Debug::EnableAgent("lineprocessor", port_number, wait_for_connection); | 224 v8::Debug::EnableAgent("lineprocessor", port_number, wait_for_connection); |
| 225 } | 225 } |
| 226 #endif // ENABLE_DEBUGGER_SUPPORT | 226 #endif // ENABLE_DEBUGGER_SUPPORT |
| 227 | 227 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 258 } else { | 258 } else { |
| 259 // All is already done. | 259 // All is already done. |
| 260 } | 260 } |
| 261 return 0; | 261 return 0; |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, | 265 bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, |
| 266 bool report_exceptions) { | 266 bool report_exceptions) { |
| 267 #ifdef ENABLE_DEBUGGER_SUPPORT | 267 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 268 v8::Locker lock; | 268 v8::Locker lock(v8::Isolate::GetCurrent()); |
| 269 #endif // ENABLE_DEBUGGER_SUPPORT | 269 #endif // ENABLE_DEBUGGER_SUPPORT |
| 270 | 270 |
| 271 v8::Handle<v8::String> fun_name = v8::String::New("ProcessLine"); | 271 v8::Handle<v8::String> fun_name = v8::String::New("ProcessLine"); |
| 272 v8::Handle<v8::Value> process_val = | 272 v8::Handle<v8::Value> process_val = |
| 273 v8::Context::GetCurrent()->Global()->Get(fun_name); | 273 v8::Context::GetCurrent()->Global()->Get(fun_name); |
| 274 | 274 |
| 275 // If there is no Process function, or if it is not a function, | 275 // If there is no Process function, or if it is not a function, |
| 276 // bail out | 276 // bail out |
| 277 if (!process_val->IsFunction()) { | 277 if (!process_val->IsFunction()) { |
| 278 printf("Error: Script does not declare 'ProcessLine' global function.\n"); | 278 printf("Error: Script does not declare 'ProcessLine' global function.\n"); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return ReadLine(); | 413 return ReadLine(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 v8::Handle<v8::String> ReadLine() { | 416 v8::Handle<v8::String> ReadLine() { |
| 417 const int kBufferSize = 1024 + 1; | 417 const int kBufferSize = 1024 + 1; |
| 418 char buffer[kBufferSize]; | 418 char buffer[kBufferSize]; |
| 419 | 419 |
| 420 char* res; | 420 char* res; |
| 421 { | 421 { |
| 422 #ifdef ENABLE_DEBUGGER_SUPPORT | 422 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 423 v8::Unlocker unlocker; | 423 v8::Unlocker unlocker(v8::Isolate::GetCurrent()); |
| 424 #endif // ENABLE_DEBUGGER_SUPPORT | 424 #endif // ENABLE_DEBUGGER_SUPPORT |
| 425 res = fgets(buffer, kBufferSize, stdin); | 425 res = fgets(buffer, kBufferSize, stdin); |
| 426 } | 426 } |
| 427 if (res == NULL) { | 427 if (res == NULL) { |
| 428 v8::Handle<v8::Primitive> t = v8::Undefined(); | 428 v8::Handle<v8::Primitive> t = v8::Undefined(); |
| 429 return v8::Handle<v8::String>(v8::String::Cast(*t)); | 429 return v8::Handle<v8::String>(v8::String::Cast(*t)); |
| 430 } | 430 } |
| 431 // Remove newline char | 431 // Remove newline char |
| 432 for (char* pos = buffer; *pos != '\0'; pos++) { | 432 for (char* pos = buffer; *pos != '\0'; pos++) { |
| 433 if (*pos == '\n') { | 433 if (*pos == '\n') { |
| 434 *pos = '\0'; | 434 *pos = '\0'; |
| 435 break; | 435 break; |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 return v8::String::New(buffer); | 438 return v8::String::New(buffer); |
| 439 } | 439 } |
| OLD | NEW |