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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 script->Run(); | 252 script->Run(); |
253 if (try_catch.HasCaught()) { | 253 if (try_catch.HasCaught()) { |
254 if (report_exceptions) | 254 if (report_exceptions) |
255 ReportException(isolate, &try_catch); | 255 ReportException(isolate, &try_catch); |
256 return 1; | 256 return 1; |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 if (cycle_type == CycleInCpp) { | 260 if (cycle_type == CycleInCpp) { |
261 bool res = RunCppCycle(script, | 261 bool res = RunCppCycle(script, |
262 v8::Context::GetCurrent(), | 262 isolate->GetCurrentContext(), |
263 report_exceptions); | 263 report_exceptions); |
264 return !res; | 264 return !res; |
265 } else { | 265 } else { |
266 // All is already done. | 266 // All is already done. |
267 } | 267 } |
268 return 0; | 268 return 0; |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 bool RunCppCycle(v8::Handle<v8::Script> script, | 272 bool RunCppCycle(v8::Handle<v8::Script> script, |
(...skipping 26 matching lines...) Expand all Loading... |
299 if (input_line == v8::Undefined()) { | 299 if (input_line == v8::Undefined()) { |
300 continue; | 300 continue; |
301 } | 301 } |
302 | 302 |
303 const int argc = 1; | 303 const int argc = 1; |
304 v8::Handle<v8::Value> argv[argc] = { input_line }; | 304 v8::Handle<v8::Value> argv[argc] = { input_line }; |
305 | 305 |
306 v8::Handle<v8::Value> result; | 306 v8::Handle<v8::Value> result; |
307 { | 307 { |
308 v8::TryCatch try_catch; | 308 v8::TryCatch try_catch; |
309 result = process_fun->Call(v8::Context::GetCurrent()->Global(), | 309 result = process_fun->Call(isolate->GetCurrentContext()->Global(), |
310 argc, argv); | 310 argc, argv); |
311 if (try_catch.HasCaught()) { | 311 if (try_catch.HasCaught()) { |
312 if (report_exceptions) | 312 if (report_exceptions) |
313 ReportException(isolate, &try_catch); | 313 ReportException(isolate, &try_catch); |
314 return false; | 314 return false; |
315 } | 315 } |
316 } | 316 } |
317 v8::String::Utf8Value str(result); | 317 v8::String::Utf8Value str(result); |
318 const char* cstr = ToCString(str); | 318 const char* cstr = ToCString(str); |
319 printf("%s\n", cstr); | 319 printf("%s\n", cstr); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 441 } |
442 // Remove newline char | 442 // Remove newline char |
443 for (char* pos = buffer; *pos != '\0'; pos++) { | 443 for (char* pos = buffer; *pos != '\0'; pos++) { |
444 if (*pos == '\n') { | 444 if (*pos == '\n') { |
445 *pos = '\0'; | 445 *pos = '\0'; |
446 break; | 446 break; |
447 } | 447 } |
448 } | 448 } |
449 return v8::String::New(buffer); | 449 return v8::String::New(buffer); |
450 } | 450 } |
OLD | NEW |