| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 src_type_name.ToCString(), | 151 src_type_name.ToCString(), |
| 152 dst_type_name.ToCString(), | 152 dst_type_name.ToCString(), |
| 153 dst_name.ToCString()); | 153 dst_name.ToCString()); |
| 154 } | 154 } |
| 155 // Throw TypeError instance. | 155 // Throw TypeError instance. |
| 156 Exceptions::Throw(type_error); | 156 Exceptions::Throw(type_error); |
| 157 UNREACHABLE(); | 157 UNREACHABLE(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 // Allocate and throw a new TypeError. |
| 162 // Arg0: index of the token of the failed type check. |
| 163 // Arg1: src value. |
| 164 // Arg2: dst type name. |
| 165 // Arg3: dst name. |
| 166 // Return value: none, throws an exception. |
| 167 DEFINE_NATIVE_ENTRY(TypeError_throwNew, 4) { |
| 168 intptr_t location = Smi::CheckedHandle(arguments->At(0)).Value(); |
| 169 const Instance& src_value = Instance::CheckedHandle(arguments->At(1)); |
| 170 const String& dst_type_name = String::CheckedHandle(arguments->At(2)); |
| 171 const String& dst_name = String::CheckedHandle(arguments->At(3)); |
| 172 const String& src_type_name = |
| 173 String::Handle(Type::Handle(src_value.GetType()).Name()); |
| 174 ThrowTypeError(location, src_type_name, dst_type_name, dst_name); |
| 175 } |
| 176 |
| 177 |
| 161 // Allocate and throw a new FallThroughError. | 178 // Allocate and throw a new FallThroughError. |
| 162 // Arg0: index of the case clause token into which we fall through. | 179 // Arg0: index of the case clause token into which we fall through. |
| 163 // Return value: none, throws an exception. | 180 // Return value: none, throws an exception. |
| 164 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { | 181 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { |
| 165 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0)); | 182 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0)); |
| 166 intptr_t fallthrough_pos = smi_pos.Value(); | 183 intptr_t fallthrough_pos = smi_pos.Value(); |
| 167 | 184 |
| 168 // Allocate a new instance of type FallThroughError. | 185 // Allocate a new instance of type FallThroughError. |
| 169 const Instance& fallthrough_error = | 186 const Instance& fallthrough_error = |
| 170 Instance::Handle(NewInstance("FallThroughError")); | 187 Instance::Handle(NewInstance("FallThroughError")); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 dst_type_name = element_type.Name(); | 318 dst_type_name = element_type.Name(); |
| 302 } | 319 } |
| 303 const String& dst_name = String::Handle(String::New(buf)); | 320 const String& dst_name = String::Handle(String::New(buf)); |
| 304 ThrowTypeError(location, src_type_name, dst_type_name, dst_name); | 321 ThrowTypeError(location, src_type_name, dst_type_name, dst_name); |
| 305 UNREACHABLE(); | 322 UNREACHABLE(); |
| 306 } | 323 } |
| 307 } | 324 } |
| 308 } | 325 } |
| 309 | 326 |
| 310 } // namespace dart | 327 } // namespace dart |
| OLD | NEW |