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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/string.dart » ('j') | runtime/lib/string.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
===================================================================
--- runtime/lib/string.cc (revision 6417)
+++ runtime/lib/string.cc (working copy)
@@ -117,6 +117,27 @@
}
+// TODO(hausner): Remove obsolete String_plus.
+DECLARE_FLAG(bool, allow_string_plus);
+DEFINE_NATIVE_ENTRY(String_plus, 2) {
+ const String& receiver = String::CheckedHandle(arguments->At(0));
+ GET_NATIVE_ARGUMENT(String, b, arguments->At(1));
+ if (!FLAG_allow_string_plus) {
+ // Throw a noSuchMethod exception if operator + is not supported.
+ const String& func_name = String::Handle(String::New("+"));
+ const Array& func_args = Array::Handle(Array::New(1));
+ func_args.SetAt(0, b);
+ GrowableArray<const Object*> dart_arguments(3);
+ dart_arguments.Add(&receiver);
+ dart_arguments.Add(&func_name);
+ dart_arguments.Add(&func_args);
+ Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments);
+ }
+ const String& result = String::Handle(String::Concat(receiver, b));
+ arguments->SetReturn(result);
+}
+
+
DEFINE_NATIVE_ENTRY(String_toLowerCase, 1) {
const String& receiver = String::CheckedHandle(arguments->At(0));
ASSERT(!receiver.IsNull());
« no previous file with comments | « no previous file | runtime/lib/string.dart » ('j') | runtime/lib/string.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698