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

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

Issue 24673003: Treat final variables initialized with a literal as constants. Also sneak in a small cleanup. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »
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 "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/native_entry.h" 8 #include "vm/native_entry.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 175
176 DEFINE_NATIVE_ENTRY(String_charAt, 2) { 176 DEFINE_NATIVE_ENTRY(String_charAt, 2) {
177 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); 177 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
178 GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); 178 GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1));
179 uint32_t value = StringValueAt(receiver, index); 179 uint32_t value = StringValueAt(receiver, index);
180 ASSERT(value <= 0x10FFFF); 180 ASSERT(value <= 0x10FFFF);
181 return Symbols::FromCharCode(value); 181 return Symbols::FromCharCode(value);
182 } 182 }
183 183
184
184 DEFINE_NATIVE_ENTRY(String_codeUnitAt, 2) { 185 DEFINE_NATIVE_ENTRY(String_codeUnitAt, 2) {
185 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); 186 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
186 GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); 187 GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1));
187 188
188 int32_t value = StringValueAt(receiver, index); 189 int32_t value = StringValueAt(receiver, index);
189 ASSERT(value >= 0); 190 ASSERT(value >= 0);
190 ASSERT(value <= 0xFFFF); 191 ASSERT(value <= 0xFFFF);
191 return Smi::New(value); 192 return Smi::New(value);
192 } 193 }
193 194
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) 246 ? String::Handle(OneByteString::New(length_value, Heap::kNew))
246 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); 247 : String::Handle(TwoByteString::New(length_value, Heap::kNew));
247 NoGCScope no_gc; 248 NoGCScope no_gc;
248 249
249 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); 250 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0));
250 String::Copy(result, 0, data_position, length_value); 251 String::Copy(result, 0, data_position, length_value);
251 return result.raw(); 252 return result.raw();
252 } 253 }
253 254
254 } // namespace dart 255 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698