Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: runtime/lib/math.cc

Issue 1868803002: Use symbols when looking up fields in a class (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/lib/mirrors.cc » ('j') | runtime/vm/object.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <ctype.h> // isspace. 5 #include <ctype.h> // isspace.
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 Double, exponent_object, arguments->NativeArgAt(1)); 72 Double, exponent_object, arguments->NativeArgAt(1));
73 const double exponent = exponent_object.value(); 73 const double exponent = exponent_object.value();
74 return Double::New(pow(operand, exponent)); 74 return Double::New(pow(operand, exponent));
75 } 75 }
76 76
77 77
78 // Returns the typed-data array store in '_Random._state' field. 78 // Returns the typed-data array store in '_Random._state' field.
79 static RawTypedData* GetRandomStateArray(const Instance& receiver) { 79 static RawTypedData* GetRandomStateArray(const Instance& receiver) {
80 const Class& random_class = Class::Handle(receiver.clazz()); 80 const Class& random_class = Class::Handle(receiver.clazz());
81 const Field& state_field = 81 const Field& state_field =
82 Field::Handle(random_class.LookupField(Symbols::_state())); 82 Field::Handle(random_class.LookupFieldAllowPrivate(Symbols::_state()));
83 ASSERT(!state_field.IsNull()); 83 ASSERT(!state_field.IsNull());
84 const Instance& state_field_value = 84 const Instance& state_field_value =
85 Instance::Cast(Object::Handle(receiver.GetField(state_field))); 85 Instance::Cast(Object::Handle(receiver.GetField(state_field)));
86 ASSERT(!state_field_value.IsNull()); 86 ASSERT(!state_field_value.IsNull());
87 ASSERT(state_field_value.IsTypedData()); 87 ASSERT(state_field_value.IsTypedData());
88 const TypedData& array = TypedData::Cast(state_field_value); 88 const TypedData& array = TypedData::Cast(state_field_value);
89 ASSERT(array.Length() == 2); 89 ASSERT(array.Length() == 2);
90 ASSERT(array.ElementType() == kUint32ArrayElement); 90 ASSERT(array.ElementType() == kUint32ArrayElement);
91 return array.raw(); 91 return array.raw();
92 } 92 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 Exceptions::ThrowByType(Exceptions::kUnsupported, args); 214 Exceptions::ThrowByType(Exceptions::kUnsupported, args);
215 } 215 }
216 uint64_t result = 0; 216 uint64_t result = 0;
217 for (intptr_t i = 0; i < n; i++) { 217 for (intptr_t i = 0; i < n; i++) {
218 result = (result << 8) | buffer[i]; 218 result = (result << 8) | buffer[i];
219 } 219 }
220 return Integer::New(result); 220 return Integer::New(result);
221 } 221 }
222 222
223 } // namespace dart 223 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698