Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 return; | 1168 return; |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 // Eliminate the test if it can be performed successfully at compile time. | 1171 // Eliminate the test if it can be performed successfully at compile time. |
| 1172 if ((node->left() != NULL) && | 1172 if ((node->left() != NULL) && |
| 1173 node->left()->IsLiteralNode() && | 1173 node->left()->IsLiteralNode() && |
| 1174 type.IsInstantiated()) { | 1174 type.IsInstantiated()) { |
| 1175 const Instance& literal_value = node->left()->AsLiteralNode()->literal(); | 1175 const Instance& literal_value = node->left()->AsLiteralNode()->literal(); |
| 1176 const Class& cls = Class::Handle(literal_value.clazz()); | 1176 const Class& cls = Class::Handle(literal_value.clazz()); |
| 1177 ConstantInstr* result = NULL; | 1177 ConstantInstr* result = NULL; |
| 1178 if (cls.IsNullClass()) { | 1178 if (cls.IsNullClass()) { |
|
rmacnak
2013/08/14 16:25:30
This doesn't need to be a special case. The else c
Lasse Reichstein Nielsen
2013/08/15 12:24:44
Done.
| |
| 1179 // A null object is only an instance of Object and dynamic, which has | 1179 // A null object is only an instance of Object, dynamic and Null, the |
| 1180 // already been checked above (if the type is instantiated). So we can | 1180 // first two of which has already been checked above (if the type is |
| 1181 // return false here if the instance is null (and if the type is | |
| 1182 // instantiated). | 1181 // instantiated). |
| 1183 result = new ConstantInstr(negate_result ? Bool::True() : Bool::False()); | 1182 const bool is_type = type.IsNullType(); |
| 1183 result = new ConstantInstr((is_type != negate_result) ? Bool::True() | |
| 1184 : Bool::False()); | |
| 1184 } else { | 1185 } else { |
| 1185 Error& malformed_error = Error::Handle(); | 1186 Error& malformed_error = Error::Handle(); |
| 1186 if (literal_value.IsInstanceOf(type, | 1187 if (literal_value.IsInstanceOf(type, |
| 1187 TypeArguments::Handle(), | 1188 TypeArguments::Handle(), |
| 1188 &malformed_error)) { | 1189 &malformed_error)) { |
| 1189 result = new ConstantInstr(negate_result ? | 1190 result = new ConstantInstr(negate_result ? |
| 1190 Bool::False() : Bool::True()); | 1191 Bool::False() : Bool::True()); |
| 1191 } else { | 1192 } else { |
| 1192 result = new ConstantInstr(negate_result ? | 1193 result = new ConstantInstr(negate_result ? |
| 1193 Bool::True() : Bool::False()); | 1194 Bool::True() : Bool::False()); |
| (...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3626 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3627 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3627 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3628 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3628 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3629 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3629 const Error& error = Error::Handle( | 3630 const Error& error = Error::Handle( |
| 3630 LanguageError::New(String::Handle(String::New(chars)))); | 3631 LanguageError::New(String::Handle(String::New(chars)))); |
| 3631 Isolate::Current()->long_jump_base()->Jump(1, error); | 3632 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3632 } | 3633 } |
| 3633 | 3634 |
| 3634 | 3635 |
| 3635 } // namespace dart | 3636 } // namespace dart |
| OLD | NEW |