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

Side by Side Diff: runtime/vm/class_finalizer.cc

Issue 23012003: Add Null class to dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Made VM not fail on x is Null tests. Created 7 years, 4 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/flow_graph_builder.cc » ('j') | runtime/vm/object.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 String::Handle(cls.Name()).ToCString()); 1852 String::Handle(cls.Name()).ToCString());
1853 } 1853 }
1854 1854
1855 interface_class = super_type.type_class(); 1855 interface_class = super_type.type_class();
1856 // If cls belongs to core lib or to core lib's implementation, restrictions 1856 // If cls belongs to core lib or to core lib's implementation, restrictions
1857 // about allowed interfaces are lifted. 1857 // about allowed interfaces are lifted.
1858 if (!cls_belongs_to_core_lib) { 1858 if (!cls_belongs_to_core_lib) {
1859 // Prevent extending core implementation classes. 1859 // Prevent extending core implementation classes.
1860 bool is_error = false; 1860 bool is_error = false;
1861 switch (interface_class.id()) { 1861 switch (interface_class.id()) {
1862 case kNullCid:
1862 case kNumberCid: 1863 case kNumberCid:
1863 case kIntegerCid: // Class Integer, not int. 1864 case kIntegerCid: // Class Integer, not int.
1864 case kSmiCid: 1865 case kSmiCid:
1865 case kMintCid: 1866 case kMintCid:
1866 case kBigintCid: 1867 case kBigintCid:
1867 case kDoubleCid: // Class Double, not double. 1868 case kDoubleCid: // Class Double, not double.
1868 case kOneByteStringCid: 1869 case kOneByteStringCid:
1869 case kTwoByteStringCid: 1870 case kTwoByteStringCid:
1870 case kExternalOneByteStringCid: 1871 case kExternalOneByteStringCid:
1871 case kExternalTwoByteStringCid: 1872 case kExternalTwoByteStringCid:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 "'dynamic' may not be used as interface"); 1920 "'dynamic' may not be used as interface");
1920 } 1921 }
1921 interface_class = interface.type_class(); 1922 interface_class = interface.type_class();
1922 if (interface_class.IsSignatureClass()) { 1923 if (interface_class.IsSignatureClass()) {
1923 const Script& script = Script::Handle(cls.script()); 1924 const Script& script = Script::Handle(cls.script());
1924 ReportError(script, cls.token_pos(), 1925 ReportError(script, cls.token_pos(),
1925 "'%s' is used where an interface or class name is expected", 1926 "'%s' is used where an interface or class name is expected",
1926 String::Handle(interface_class.Name()).ToCString()); 1927 String::Handle(interface_class.Name()).ToCString());
1927 } 1928 }
1928 // Verify that unless cls belongs to core lib, it cannot extend or implement 1929 // Verify that unless cls belongs to core lib, it cannot extend or implement
1929 // any of bool, num, int, double, String, Function, dynamic. 1930 // any of Null, bool, num, int, double, String, Function, dynamic.
1930 // The exception is signature classes, which are compiler generated and 1931 // The exception is signature classes, which are compiler generated and
1931 // represent a function type, therefore implementing the Function interface. 1932 // represent a function type, therefore implementing the Function interface.
1932 if (!cls_belongs_to_core_lib) { 1933 if (!cls_belongs_to_core_lib) {
1933 if (interface.IsBoolType() || 1934 if (interface.IsNullType() ||
1935 interface.IsBoolType() ||
1934 interface.IsNumberType() || 1936 interface.IsNumberType() ||
1935 interface.IsIntType() || 1937 interface.IsIntType() ||
1936 interface.IsDoubleType() || 1938 interface.IsDoubleType() ||
1937 interface.IsStringType() || 1939 interface.IsStringType() ||
1938 (interface.IsFunctionType() && !cls.IsSignatureClass()) || 1940 (interface.IsFunctionType() && !cls.IsSignatureClass()) ||
1939 interface.IsDynamicType()) { 1941 interface.IsDynamicType()) {
1940 const Script& script = Script::Handle(cls.script()); 1942 const Script& script = Script::Handle(cls.script());
1941 ReportError(script, cls.token_pos(), 1943 ReportError(script, cls.token_pos(),
1942 "'%s' is not allowed to extend or implement '%s'", 1944 "'%s' is not allowed to extend or implement '%s'",
1943 String::Handle(cls.Name()).ToCString(), 1945 String::Handle(cls.Name()).ToCString(),
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 expected_name ^= String::New("_offset"); 2168 expected_name ^= String::New("_offset");
2167 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 2169 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2168 field ^= fields_array.At(2); 2170 field ^= fields_array.At(2);
2169 ASSERT(field.Offset() == TypedDataView::length_offset()); 2171 ASSERT(field.Offset() == TypedDataView::length_offset());
2170 name ^= field.name(); 2172 name ^= field.name();
2171 ASSERT(name.Equals("length")); 2173 ASSERT(name.Equals("length"));
2172 #endif 2174 #endif
2173 } 2175 }
2174 2176
2175 } // namespace dart 2177 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698