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

Unified Diff: runtime/lib/string.dart

Issue 8648003: Fix bug 557: Disallow user side allocation of ImmutableArray. Also added "instantiation-checks" f... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « runtime/lib/integers.dart ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.dart
===================================================================
--- runtime/lib/string.dart (revision 1806)
+++ runtime/lib/string.dart (working copy)
@@ -8,6 +8,11 @@
*/
class StringBase {
+ factory StringBase._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "StringBase can't be instaniated");
+ }
+
int hashCode() native "String_hashCode";
/**
@@ -385,6 +390,11 @@
class OneByteString extends StringBase implements String {
+ factory OneByteString._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "OneByteString can only be allocated by the VM");
+ }
+
// Checks for one-byte whitespaces only.
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces for one byte strings.
@@ -398,6 +408,11 @@
class TwoByteString extends StringBase implements String {
+ factory TwoByteString._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "TwoByteString can only be allocated by the VM");
+ }
+
// Checks for one-byte whitespaces only.
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces. Add checking for multi-byte whitespace codepoints.
@@ -410,6 +425,11 @@
class FourByteString extends StringBase implements String {
+ factory FourByteString._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "FourByteString can only be allocated by the VM");
+ }
+
// Checks for one-byte whitespaces only.
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces. Add checking for multi-byte whitespace codepoints.
@@ -422,6 +442,11 @@
class ExternalOneByteString extends StringBase implements String {
+ factory ExternalOneByteString._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "ExternalOneByteString can only be allocated by the VM");
+ }
+
// Checks for one-byte whitespaces only.
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces for one byte strings.
@@ -434,6 +459,11 @@
class ExternalTwoByteString extends StringBase implements String {
+ factory ExternalTwoByteString._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "ExternalTwoByteString can only be allocated by the VM");
+ }
+
// Checks for one-byte whitespaces only.
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces. Add checking for multi-byte whitespace codepoints.
@@ -446,6 +476,11 @@
class ExternalFourByteString extends StringBase implements String {
+ factory ExternalFourByteString._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "ExternalFourByteString can only be allocated by the VM");
+ }
+
// Checks for one-byte whitespaces only.
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces. Add checking for multi-byte whitespace codepoints.
« no previous file with comments | « runtime/lib/integers.dart ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698