| 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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 ReturnDefinition(new ConstantInstr(negate_result ? | 1166 ReturnDefinition(new ConstantInstr(negate_result ? |
| 1167 Bool::False() : Bool::True())); | 1167 Bool::False() : Bool::True())); |
| 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()); | |
| 1177 ConstantInstr* result = NULL; | 1176 ConstantInstr* result = NULL; |
| 1178 if (cls.IsNullClass()) { | 1177 Error& malformed_error = Error::Handle(); |
| 1179 // A null object is only an instance of Object and dynamic, which has | 1178 if (literal_value.IsInstanceOf(type, |
| 1180 // already been checked above (if the type is instantiated). So we can | 1179 TypeArguments::Handle(), |
| 1181 // return false here if the instance is null (and if the type is | 1180 &malformed_error)) { |
| 1182 // instantiated). | 1181 result = new ConstantInstr(negate_result ? |
| 1183 result = new ConstantInstr(negate_result ? Bool::True() : Bool::False()); | 1182 Bool::False() : Bool::True()); |
| 1184 } else { | 1183 } else { |
| 1185 Error& malformed_error = Error::Handle(); | 1184 result = new ConstantInstr(negate_result ? |
| 1186 if (literal_value.IsInstanceOf(type, | 1185 Bool::True() : Bool::False()); |
| 1187 TypeArguments::Handle(), | |
| 1188 &malformed_error)) { | |
| 1189 result = new ConstantInstr(negate_result ? | |
| 1190 Bool::False() : Bool::True()); | |
| 1191 } else { | |
| 1192 result = new ConstantInstr(negate_result ? | |
| 1193 Bool::True() : Bool::False()); | |
| 1194 } | |
| 1195 ASSERT(malformed_error.IsNull()); | |
| 1196 } | 1186 } |
| 1187 ASSERT(malformed_error.IsNull()); |
| 1197 ReturnDefinition(result); | 1188 ReturnDefinition(result); |
| 1198 return; | 1189 return; |
| 1199 } | 1190 } |
| 1200 | 1191 |
| 1201 ValueGraphVisitor for_left_value(owner(), temp_index()); | 1192 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 1202 node->left()->Visit(&for_left_value); | 1193 node->left()->Visit(&for_left_value); |
| 1203 Append(for_left_value); | 1194 Append(for_left_value); |
| 1204 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); | 1195 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
| 1205 PushArgumentInstr* push_instantiator = NULL; | 1196 PushArgumentInstr* push_instantiator = NULL; |
| 1206 PushArgumentInstr* push_type_args = NULL; | 1197 PushArgumentInstr* push_type_args = NULL; |
| (...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3626 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3617 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3627 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3618 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3628 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3619 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3629 const Error& error = Error::Handle( | 3620 const Error& error = Error::Handle( |
| 3630 LanguageError::New(String::Handle(String::New(chars)))); | 3621 LanguageError::New(String::Handle(String::New(chars)))); |
| 3631 Isolate::Current()->long_jump_base()->Jump(1, error); | 3622 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3632 } | 3623 } |
| 3633 | 3624 |
| 3634 | 3625 |
| 3635 } // namespace dart | 3626 } // namespace dart |
| OLD | NEW |