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

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

Issue 9960084: Introduce a flag to disable string operator + (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/string.dart » ('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 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 111
112 DEFINE_NATIVE_ENTRY(String_concat, 2) { 112 DEFINE_NATIVE_ENTRY(String_concat, 2) {
113 const String& receiver = String::CheckedHandle(arguments->At(0)); 113 const String& receiver = String::CheckedHandle(arguments->At(0));
114 GET_NATIVE_ARGUMENT(String, b, arguments->At(1)); 114 GET_NATIVE_ARGUMENT(String, b, arguments->At(1));
115 const String& result = String::Handle(String::Concat(receiver, b)); 115 const String& result = String::Handle(String::Concat(receiver, b));
116 arguments->SetReturn(result); 116 arguments->SetReturn(result);
117 } 117 }
118 118
119 119
120 // TODO(hausner): Remove obsolete String_plus.
121 DECLARE_FLAG(bool, allow_string_plus);
Ivan Posva 2012/04/11 12:03:57 Usually we try to declare flags at the top of the
122 DEFINE_NATIVE_ENTRY(String_plus, 2) {
123 const String& receiver = String::CheckedHandle(arguments->At(0));
124 GET_NATIVE_ARGUMENT(String, b, arguments->At(1));
125 if (!FLAG_allow_string_plus) {
126 // Throw a noSuchMethod exception if operator + is not supported.
127 const String& func_name = String::Handle(String::New("+"));
128 const Array& func_args = Array::Handle(Array::New(1));
129 func_args.SetAt(0, b);
130 GrowableArray<const Object*> dart_arguments(3);
131 dart_arguments.Add(&receiver);
132 dart_arguments.Add(&func_name);
133 dart_arguments.Add(&func_args);
134 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments);
135 }
136 const String& result = String::Handle(String::Concat(receiver, b));
137 arguments->SetReturn(result);
138 }
139
140
120 DEFINE_NATIVE_ENTRY(String_toLowerCase, 1) { 141 DEFINE_NATIVE_ENTRY(String_toLowerCase, 1) {
121 const String& receiver = String::CheckedHandle(arguments->At(0)); 142 const String& receiver = String::CheckedHandle(arguments->At(0));
122 ASSERT(!receiver.IsNull()); 143 ASSERT(!receiver.IsNull());
123 const String& result = String::Handle(String::ToLowerCase(receiver)); 144 const String& result = String::Handle(String::ToLowerCase(receiver));
124 arguments->SetReturn(result); 145 arguments->SetReturn(result);
125 } 146 }
126 147
127 148
128 DEFINE_NATIVE_ENTRY(String_toUpperCase, 1) { 149 DEFINE_NATIVE_ENTRY(String_toUpperCase, 1) {
129 const String& receiver = String::CheckedHandle(arguments->At(0)); 150 const String& receiver = String::CheckedHandle(arguments->At(0));
(...skipping 18 matching lines...) Expand all
148 GrowableArray<const Object*> args; 169 GrowableArray<const Object*> args;
149 args.Add(&elem); 170 args.Add(&elem);
150 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 171 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
151 } 172 }
152 } 173 }
153 const String& result = String::Handle(String::ConcatAll(strings)); 174 const String& result = String::Handle(String::ConcatAll(strings));
154 arguments->SetReturn(result); 175 arguments->SetReturn(result);
155 } 176 }
156 177
157 } // namespace dart 178 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698