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 27 matching lines...) Expand all Loading... |
38 #include "platform.h" | 38 #include "platform.h" |
39 #include "cctest.h" | 39 #include "cctest.h" |
40 | 40 |
41 using namespace v8::internal; | 41 using namespace v8::internal; |
42 | 42 |
43 // --- P r i n t E x t e n s i o n --- | 43 // --- P r i n t E x t e n s i o n --- |
44 | 44 |
45 class PrintExtension : public v8::Extension { | 45 class PrintExtension : public v8::Extension { |
46 public: | 46 public: |
47 PrintExtension() : v8::Extension("v8/print", kSource) { } | 47 PrintExtension() : v8::Extension("v8/print", kSource) { } |
48 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 48 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 49 v8::Isolate* isolate, |
49 v8::Handle<v8::String> name); | 50 v8::Handle<v8::String> name); |
50 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args); | 51 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args); |
51 private: | 52 private: |
52 static const char* kSource; | 53 static const char* kSource; |
53 }; | 54 }; |
54 | 55 |
55 | 56 |
56 const char* PrintExtension::kSource = "native function print();"; | 57 const char* PrintExtension::kSource = "native function print();"; |
57 | 58 |
58 | 59 |
59 v8::Handle<v8::FunctionTemplate> PrintExtension::GetNativeFunction( | 60 v8::Handle<v8::FunctionTemplate> PrintExtension::GetNativeFunctionTemplate( |
| 61 v8::Isolate* isolate, |
60 v8::Handle<v8::String> str) { | 62 v8::Handle<v8::String> str) { |
61 return v8::FunctionTemplate::New(PrintExtension::Print); | 63 return v8::FunctionTemplate::New(PrintExtension::Print); |
62 } | 64 } |
63 | 65 |
64 | 66 |
65 void PrintExtension::Print(const v8::FunctionCallbackInfo<v8::Value>& args) { | 67 void PrintExtension::Print(const v8::FunctionCallbackInfo<v8::Value>& args) { |
66 for (int i = 0; i < args.Length(); i++) { | 68 for (int i = 0; i < args.Length(); i++) { |
67 if (i != 0) printf(" "); | 69 if (i != 0) printf(" "); |
68 v8::HandleScope scope(args.GetIsolate()); | 70 v8::HandleScope scope(args.GetIsolate()); |
69 v8::String::Utf8Value str(args[i]); | 71 v8::String::Utf8Value str(args[i]); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 CompileRun("function f() { a = 12345678 }; f();"); | 438 CompileRun("function f() { a = 12345678 }; f();"); |
437 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 439 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
438 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 440 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
439 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 441 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
440 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 442 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
441 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 443 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
442 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 444 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
443 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 445 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
444 } | 446 } |
445 #endif | 447 #endif |
OLD | NEW |