OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
| 11 #include "vm/flags.h" |
11 #include "vm/native_entry.h" | 12 #include "vm/native_entry.h" |
12 #include "vm/object.h" | 13 #include "vm/object.h" |
13 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
14 #include "vm/service.h" | 15 #include "vm/service.h" |
15 | 16 |
16 namespace dart { | 17 namespace dart { |
17 | 18 |
18 // Native implementations for the dart:developer library. | 19 // Native implementations for the dart:developer library. |
19 | 20 |
20 DEFINE_NATIVE_ENTRY(Developer_debugger, 2) { | 21 DEFINE_NATIVE_ENTRY(Developer_debugger, 2) { |
21 GET_NON_NULL_NATIVE_ARGUMENT(Bool, when, arguments->NativeArgAt(0)); | 22 GET_NON_NULL_NATIVE_ARGUMENT(Bool, when, arguments->NativeArgAt(0)); |
22 GET_NATIVE_ARGUMENT(String, msg, arguments->NativeArgAt(1)); | 23 GET_NATIVE_ARGUMENT(String, msg, arguments->NativeArgAt(1)); |
23 Debugger* debugger = isolate->debugger(); | 24 Debugger* debugger = isolate->debugger(); |
24 if (!debugger) { | 25 if (!FLAG_support_debugger || !debugger) { |
25 return when.raw(); | 26 return when.raw(); |
26 } | 27 } |
27 if (when.value()) { | 28 if (when.value()) { |
28 debugger->BreakHere(msg); | 29 debugger->BreakHere(msg); |
29 } | 30 } |
30 return when.raw(); | 31 return when.raw(); |
31 } | 32 } |
32 | 33 |
33 | 34 |
34 DEFINE_NATIVE_ENTRY(Developer_inspect, 1) { | 35 DEFINE_NATIVE_ENTRY(Developer_inspect, 1) { |
35 GET_NATIVE_ARGUMENT(Instance, inspectee, arguments->NativeArgAt(0)); | 36 GET_NATIVE_ARGUMENT(Instance, inspectee, arguments->NativeArgAt(0)); |
36 Service::SendInspectEvent(isolate, inspectee); | 37 if (FLAG_support_service) { |
| 38 Service::SendInspectEvent(isolate, inspectee); |
| 39 } |
37 return inspectee.raw(); | 40 return inspectee.raw(); |
38 } | 41 } |
39 | 42 |
40 | 43 |
41 DEFINE_NATIVE_ENTRY(Developer_log, 8) { | 44 DEFINE_NATIVE_ENTRY(Developer_log, 8) { |
| 45 if (!FLAG_support_service) { |
| 46 return Object::null(); |
| 47 } |
42 GET_NON_NULL_NATIVE_ARGUMENT(String, message, arguments->NativeArgAt(0)); | 48 GET_NON_NULL_NATIVE_ARGUMENT(String, message, arguments->NativeArgAt(0)); |
43 GET_NON_NULL_NATIVE_ARGUMENT(Integer, timestamp, arguments->NativeArgAt(1)); | 49 GET_NON_NULL_NATIVE_ARGUMENT(Integer, timestamp, arguments->NativeArgAt(1)); |
44 GET_NON_NULL_NATIVE_ARGUMENT(Integer, sequence, arguments->NativeArgAt(2)); | 50 GET_NON_NULL_NATIVE_ARGUMENT(Integer, sequence, arguments->NativeArgAt(2)); |
45 GET_NON_NULL_NATIVE_ARGUMENT(Smi, level, arguments->NativeArgAt(3)); | 51 GET_NON_NULL_NATIVE_ARGUMENT(Smi, level, arguments->NativeArgAt(3)); |
46 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(4)); | 52 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(4)); |
47 GET_NATIVE_ARGUMENT(Instance, dart_zone, arguments->NativeArgAt(5)); | 53 GET_NATIVE_ARGUMENT(Instance, dart_zone, arguments->NativeArgAt(5)); |
48 GET_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(6)); | 54 GET_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(6)); |
49 GET_NATIVE_ARGUMENT(Instance, stack_trace, arguments->NativeArgAt(7)); | 55 GET_NATIVE_ARGUMENT(Instance, stack_trace, arguments->NativeArgAt(7)); |
50 Service::SendLogEvent(isolate, | 56 Service::SendLogEvent(isolate, |
51 sequence.AsInt64Value(), | 57 sequence.AsInt64Value(), |
52 timestamp.AsInt64Value(), | 58 timestamp.AsInt64Value(), |
53 level.Value(), | 59 level.Value(), |
54 name, | 60 name, |
55 message, | 61 message, |
56 dart_zone, | 62 dart_zone, |
57 error, | 63 error, |
58 stack_trace); | 64 stack_trace); |
59 return Object::null(); | 65 return Object::null(); |
60 } | 66 } |
61 | 67 |
62 | 68 |
63 DEFINE_NATIVE_ENTRY(Developer_postEvent, 2) { | 69 DEFINE_NATIVE_ENTRY(Developer_postEvent, 2) { |
| 70 if (!FLAG_support_service) { |
| 71 return Object::null(); |
| 72 } |
64 GET_NON_NULL_NATIVE_ARGUMENT(String, event_kind, arguments->NativeArgAt(0)); | 73 GET_NON_NULL_NATIVE_ARGUMENT(String, event_kind, arguments->NativeArgAt(0)); |
65 GET_NON_NULL_NATIVE_ARGUMENT(String, event_data, arguments->NativeArgAt(1)); | 74 GET_NON_NULL_NATIVE_ARGUMENT(String, event_data, arguments->NativeArgAt(1)); |
66 Service::SendExtensionEvent(isolate, event_kind, event_data); | 75 Service::SendExtensionEvent(isolate, event_kind, event_data); |
67 return Object::null(); | 76 return Object::null(); |
68 } | 77 } |
69 | 78 |
70 | 79 |
71 DEFINE_NATIVE_ENTRY(Developer_lookupExtension, 1) { | 80 DEFINE_NATIVE_ENTRY(Developer_lookupExtension, 1) { |
| 81 if (!FLAG_support_service) { |
| 82 return Object::null(); |
| 83 } |
72 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0)); | 84 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0)); |
73 return isolate->LookupServiceExtensionHandler(name); | 85 return isolate->LookupServiceExtensionHandler(name); |
74 } | 86 } |
75 | 87 |
76 | 88 |
77 DEFINE_NATIVE_ENTRY(Developer_registerExtension, 2) { | 89 DEFINE_NATIVE_ENTRY(Developer_registerExtension, 2) { |
| 90 if (!FLAG_support_service) { |
| 91 return Object::null(); |
| 92 } |
78 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0)); | 93 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0)); |
79 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handler, arguments->NativeArgAt(1)); | 94 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handler, arguments->NativeArgAt(1)); |
80 isolate->RegisterServiceExtensionHandler(name, handler); | 95 isolate->RegisterServiceExtensionHandler(name, handler); |
81 return Object::null(); | 96 return Object::null(); |
82 } | 97 } |
83 | 98 |
84 } // namespace dart | 99 } // namespace dart |
OLD | NEW |