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

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

Issue 23012003: Add Null class to dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Marked test failing due to new dart2js mirror bug. 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/code_descriptors.h" 10 #include "vm/code_descriptors.h"
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 ReturnDefinition(new ConstantInstr(negate_result ? 1215 ReturnDefinition(new ConstantInstr(negate_result ?
1216 Bool::False() : Bool::True())); 1216 Bool::False() : Bool::True()));
1217 return; 1217 return;
1218 } 1218 }
1219 1219
1220 // Eliminate the test if it can be performed successfully at compile time. 1220 // Eliminate the test if it can be performed successfully at compile time.
1221 if ((node->left() != NULL) && 1221 if ((node->left() != NULL) &&
1222 node->left()->IsLiteralNode() && 1222 node->left()->IsLiteralNode() &&
1223 type.IsInstantiated()) { 1223 type.IsInstantiated()) {
1224 const Instance& literal_value = node->left()->AsLiteralNode()->literal(); 1224 const Instance& literal_value = node->left()->AsLiteralNode()->literal();
1225 const Class& cls = Class::Handle(literal_value.clazz());
1226 ConstantInstr* result = NULL; 1225 ConstantInstr* result = NULL;
1227 if (cls.IsNullClass()) { 1226
1228 // A null object is only an instance of Object and dynamic, which has 1227 Error& malformed_error = Error::Handle();
1229 // already been checked above (if the type is instantiated). So we can 1228 if (literal_value.IsInstanceOf(type,
1230 // return false here if the instance is null (and if the type is 1229 TypeArguments::Handle(),
1231 // instantiated). 1230 &malformed_error)) {
1232 result = new ConstantInstr(negate_result ? Bool::True() : Bool::False()); 1231 result = new ConstantInstr(negate_result ?
1232 Bool::False() : Bool::True());
1233 } else { 1233 } else {
1234 Error& malformed_error = Error::Handle(); 1234 result = new ConstantInstr(negate_result ?
1235 if (literal_value.IsInstanceOf(type, 1235 Bool::True() : Bool::False());
1236 TypeArguments::Handle(),
1237 &malformed_error)) {
1238 result = new ConstantInstr(negate_result ?
1239 Bool::False() : Bool::True());
1240 } else {
1241 result = new ConstantInstr(negate_result ?
1242 Bool::True() : Bool::False());
1243 }
1244 ASSERT(malformed_error.IsNull());
1245 } 1236 }
1237 ASSERT(malformed_error.IsNull());
1238
1246 ReturnDefinition(result); 1239 ReturnDefinition(result);
1247 return; 1240 return;
1248 } 1241 }
1249 1242
1250 ValueGraphVisitor for_left_value(owner(), temp_index()); 1243 ValueGraphVisitor for_left_value(owner(), temp_index());
1251 node->left()->Visit(&for_left_value); 1244 node->left()->Visit(&for_left_value);
1252 Append(for_left_value); 1245 Append(for_left_value);
1253 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1246 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1254 PushArgumentInstr* push_instantiator = NULL; 1247 PushArgumentInstr* push_instantiator = NULL;
1255 PushArgumentInstr* push_type_args = NULL; 1248 PushArgumentInstr* push_type_args = NULL;
(...skipping 2421 matching lines...) Expand 10 before | Expand all | Expand 10 after
3677 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3670 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3678 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3671 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3679 OS::SNPrint(chars, len, kFormat, function_name, reason); 3672 OS::SNPrint(chars, len, kFormat, function_name, reason);
3680 const Error& error = Error::Handle( 3673 const Error& error = Error::Handle(
3681 LanguageError::New(String::Handle(String::New(chars)))); 3674 LanguageError::New(String::Handle(String::New(chars))));
3682 Isolate::Current()->long_jump_base()->Jump(1, error); 3675 Isolate::Current()->long_jump_base()->Jump(1, error);
3683 } 3676 }
3684 3677
3685 3678
3686 } // namespace dart 3679 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698