Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "lib/error.h" | 5 #include "lib/error.h" |
| 6 | 6 |
| 7 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
| 8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 intptr_t line, column; | 96 intptr_t line, column; |
| 97 script.GetTokenLocation(fallthrough_pos, &line, &column); | 97 script.GetTokenLocation(fallthrough_pos, &line, &column); |
| 98 Exceptions::SetField(fallthrough_error, cls, "line", | 98 Exceptions::SetField(fallthrough_error, cls, "line", |
| 99 Smi::Handle(Smi::New(line))); | 99 Smi::Handle(Smi::New(line))); |
| 100 | 100 |
| 101 // Throw FallThroughError instance. | 101 // Throw FallThroughError instance. |
| 102 Exceptions::Throw(fallthrough_error); | 102 Exceptions::Throw(fallthrough_error); |
| 103 UNREACHABLE(); | 103 UNREACHABLE(); |
| 104 return Object::null(); | 104 return Object::null(); |
| 105 } | 105 } |
| 106 | 106 |
|
regis
2012/08/31 01:16:48
Missing blank line.
Also, missing comment document
hausner
2012/08/31 18:06:52
Done.
| |
| 107 DEFINE_NATIVE_ENTRY(AbstractClassInstantiationError_throwNew, 2) { | |
| 108 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0)); | |
| 109 GET_NATIVE_ARGUMENT(String, class_name, arguments->At(1)); | |
| 110 intptr_t error_pos = smi_pos.Value(); | |
| 111 | |
| 112 // Allocate a new instance of type AbstractClassInstantiationError. | |
| 113 const Instance& error = Instance::Handle(Exceptions::NewInstance( | |
| 114 "AbstractClassInstantiationErrorImplementation")); | |
| 115 ASSERT(!error.IsNull()); | |
| 116 | |
| 117 // Initialize 'url', 'line' and 'className' fields. | |
| 118 DartFrameIterator iterator; | |
| 119 iterator.NextFrame(); // Skip native call. | |
| 120 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); | |
| 121 const Class& cls = Class::Handle(error.clazz()); | |
| 122 Exceptions::SetField(error, cls, "url", String::Handle(script.url())); | |
| 123 intptr_t line, column; | |
| 124 script.GetTokenLocation(error_pos, &line, &column); | |
| 125 Exceptions::SetField(error, cls, "line", Smi::Handle(Smi::New(line))); | |
| 126 Exceptions::SetField(error, cls, "className", class_name); | |
| 127 | |
| 128 // Throw AbstractClassInstantiationError instance. | |
| 129 Exceptions::Throw(error); | |
| 130 UNREACHABLE(); | |
| 131 return Object::null(); | |
| 132 } | |
| 107 | 133 |
|
regis
2012/08/31 01:16:48
Missing blank line.
hausner
2012/08/31 18:06:52
Done.
| |
| 108 // Allocate and throw StaticResolutionException. | 134 // Allocate and throw StaticResolutionException. |
| 109 // Arg0: index of the static call that was not resolved at compile time. | 135 // Arg0: index of the static call that was not resolved at compile time. |
| 110 // Return value: none, throws an exception. | 136 // Return value: none, throws an exception. |
| 111 DEFINE_NATIVE_ENTRY(StaticResolutionException_throwNew, 1) { | 137 DEFINE_NATIVE_ENTRY(StaticResolutionException_throwNew, 1) { |
| 112 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0)); | 138 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0)); |
| 113 intptr_t call_pos = smi_pos.Value(); | 139 intptr_t call_pos = smi_pos.Value(); |
| 114 // Allocate a new instance of type StaticResolutionException. | 140 // Allocate a new instance of type StaticResolutionException. |
| 115 const Instance& resolution_exception = | 141 const Instance& resolution_exception = |
| 116 Instance::Handle(Exceptions::NewInstance("StaticResolutionException")); | 142 Instance::Handle(Exceptions::NewInstance("StaticResolutionException")); |
| 117 ASSERT(!resolution_exception.IsNull()); | 143 ASSERT(!resolution_exception.IsNull()); |
| 118 | 144 |
| 119 // Initialize 'url', 'line', and 'column' fields. | 145 // Initialize 'url', 'line', and 'column' fields. |
| 120 DartFrameIterator iterator; | 146 DartFrameIterator iterator; |
| 121 iterator.NextFrame(); // Skip native call. | 147 iterator.NextFrame(); // Skip native call. |
| 122 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); | 148 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); |
| 123 const Class& cls = Class::Handle(resolution_exception.clazz()); | 149 const Class& cls = Class::Handle(resolution_exception.clazz()); |
| 124 Exceptions::SetLocationFields(resolution_exception, cls, script, call_pos); | 150 Exceptions::SetLocationFields(resolution_exception, cls, script, call_pos); |
| 125 | 151 |
| 126 intptr_t line, column; | 152 intptr_t line, column; |
| 127 script.GetTokenLocation(call_pos, &line, &column); | 153 script.GetTokenLocation(call_pos, &line, &column); |
| 128 Exceptions::SetField(resolution_exception, cls, "failedResolutionLine", | 154 Exceptions::SetField(resolution_exception, cls, "failedResolutionLine", |
| 129 String::Handle(script.GetLine(line))); | 155 String::Handle(script.GetLine(line))); |
| 130 | 156 |
| 131 Exceptions::Throw(resolution_exception); | 157 Exceptions::Throw(resolution_exception); |
| 132 UNREACHABLE(); | 158 UNREACHABLE(); |
| 133 return Object::null(); | 159 return Object::null(); |
| 134 } | 160 } |
| 135 | 161 |
| 136 } // namespace dart | 162 } // namespace dart |
| OLD | NEW |