Chromium Code Reviews| Index: runtime/vm/code_generator.cc |
| diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc |
| index 3082168307cae0439c17f58c3d0c774a39f692fc..4255d077dab0c1d61c45a3e1ddf5543d1e972d37 100644 |
| --- a/runtime/vm/code_generator.cc |
| +++ b/runtime/vm/code_generator.cc |
| @@ -91,6 +91,34 @@ DEFINE_RUNTIME_ENTRY(TraceFunctionExit, 1) { |
| } |
| +DEFINE_RUNTIME_ENTRY(RangeError, 2) { |
| + const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0)); |
| + const Instance& index = Instance::CheckedHandle(arguments.ArgAt(1)); |
| + if (!length.IsInteger()) { |
| + // Throw: new ArgumentError.value(length, "length", "is not an integer"); |
| + const Array& args = Array::Handle(Array::New(3)); |
| + args.SetAt(0, length); |
| + args.SetAt(1, Symbols::Length()); |
| + args.SetAt(2, String::Handle(String::New("is not an integer"))); |
| + Exceptions::ThrowByType(Exceptions::kArgumentValue, args); |
| + } |
| + if (!index.IsInteger()) { |
| + // Throw: new ArgumentError.value(length, "length", "is not an integer"); |
|
Vyacheslav Egorov (Google)
2016/07/14 09:35:59
comment should say index.
Florian Schneider
2016/07/14 17:05:21
Done.
|
| + const Array& args = Array::Handle(Array::New(3)); |
| + args.SetAt(0, index); |
| + args.SetAt(1, Symbols::Index()); |
| + args.SetAt(2, String::Handle(String::New("is not an integer"))); |
| + Exceptions::ThrowByType(Exceptions::kArgumentValue, args); |
| + } |
| + // Throw: new RangeError.range(index, 0, length, "length"); |
| + const Array& args = Array::Handle(Array::New(4)); |
| + args.SetAt(0, index); |
| + args.SetAt(1, Integer::Handle(Integer::New(0))); |
| + args.SetAt(2, length); |
| + args.SetAt(3, Symbols::Length()); |
| + Exceptions::ThrowByType(Exceptions::kRange, args); |
| +} |
| + |
|
Vyacheslav Egorov (Google)
2016/07/14 09:35:59
+1 empty line
Florian Schneider
2016/07/14 17:05:21
Done.
|
| // Allocation of a fixed length array of given element type. |
| // This runtime entry is never called for allocating a List of a generic type, |
| // because a prior run time call instantiates the element type if necessary. |