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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Extracts a C string from a V8 Utf8Value. | 91 // Extracts a C string from a V8 Utf8Value. |
92 const char* ToCString(const v8::String::Utf8Value& value) { | 92 const char* ToCString(const v8::String::Utf8Value& value) { |
93 return *value ? *value : "<string conversion failed>"; | 93 return *value ? *value : "<string conversion failed>"; |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 // Creates a new execution environment containing the built-in | 97 // Creates a new execution environment containing the built-in |
98 // functions. | 98 // functions. |
99 v8::Handle<v8::Context> CreateShellContext(v8::Isolate* isolate) { | 99 v8::Handle<v8::Context> CreateShellContext(v8::Isolate* isolate) { |
100 // Create a template for the global object. | 100 // Create a template for the global object. |
101 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); | 101 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); |
102 // Bind the global 'print' function to the C++ Print callback. | 102 // Bind the global 'print' function to the C++ Print callback. |
103 global->Set(v8::String::NewFromUtf8(isolate, "print"), | 103 global->Set(v8::String::NewFromUtf8(isolate, "print"), |
104 v8::FunctionTemplate::New(isolate, Print)); | 104 v8::FunctionTemplate::New(isolate, Print)); |
105 // Bind the global 'read' function to the C++ Read callback. | 105 // Bind the global 'read' function to the C++ Read callback. |
106 global->Set(v8::String::NewFromUtf8(isolate, "read"), | 106 global->Set(v8::String::NewFromUtf8(isolate, "read"), |
107 v8::FunctionTemplate::New(isolate, Read)); | 107 v8::FunctionTemplate::New(isolate, Read)); |
108 // Bind the global 'load' function to the C++ Load callback. | 108 // Bind the global 'load' function to the C++ Load callback. |
109 global->Set(v8::String::NewFromUtf8(isolate, "load"), | 109 global->Set(v8::String::NewFromUtf8(isolate, "load"), |
110 v8::FunctionTemplate::New(isolate, Load)); | 110 v8::FunctionTemplate::New(isolate, Load)); |
111 // Bind the 'quit' function | 111 // Bind the 'quit' function |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 fprintf(stderr, "^"); | 362 fprintf(stderr, "^"); |
363 } | 363 } |
364 fprintf(stderr, "\n"); | 364 fprintf(stderr, "\n"); |
365 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 365 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
366 if (stack_trace.length() > 0) { | 366 if (stack_trace.length() > 0) { |
367 const char* stack_trace_string = ToCString(stack_trace); | 367 const char* stack_trace_string = ToCString(stack_trace); |
368 fprintf(stderr, "%s\n", stack_trace_string); | 368 fprintf(stderr, "%s\n", stack_trace_string); |
369 } | 369 } |
370 } | 370 } |
371 } | 371 } |
OLD | NEW |