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

Unified Diff: runtime/lib/integers.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/immutable_map.dart ('k') | runtime/lib/string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/integers.dart
===================================================================
--- runtime/lib/integers.dart (revision 1806)
+++ runtime/lib/integers.dart (working copy)
@@ -5,6 +5,10 @@
// TODO(srdjan): fix limitations.
// - shift amount must be a Smi.
class IntegerImplementation {
+ factory IntegerImplementation._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "IntegerImplementation can only be allocated by the VM");
+ }
num operator +(num other) {
return other.addFromInteger(this);
}
@@ -156,6 +160,10 @@
}
class Smi extends IntegerImplementation implements int {
+ factory Smi._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "Smi can only be allocated by the VM");
+ }
int hashCode() {
return this;
}
@@ -166,6 +174,10 @@
// Represents integers that cannot be represented by Smi but fit into 64bits.
class Mint extends IntegerImplementation implements int {
+ factory Mint._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "Mint can only be allocated by the VM");
+ }
int hashCode() {
return this;
}
@@ -175,6 +187,10 @@
// A number that can be represented as Smi or Mint will never be represented as
// Bigint.
class Bigint extends IntegerImplementation implements int {
+ factory Bigint._uninstantiable() {
+ throw const UnsupportedOperationException(
+ "Bigint can only be allocated by the VM");
+ }
int hashCode() {
return this;
}
« no previous file with comments | « runtime/lib/immutable_map.dart ('k') | runtime/lib/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698