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

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

Issue 2781893004: Remove definitions from Kernel canonical names. (Closed)
Patch Set: Update test expectations. Created 3 years, 8 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
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | tests/lib/lib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "vm/kernel_to_il.h" 9 #include "vm/kernel_to_il.h"
10 10
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 ParsedFunction* parsed_function = parsed_function_; 271 ParsedFunction* parsed_function = parsed_function_;
272 const dart::Function& function = parsed_function->function(); 272 const dart::Function& function = parsed_function->function();
273 273
274 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used 274 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used
275 // e.g. for type translation. 275 // e.g. for type translation.
276 const dart::Class& klass = 276 const dart::Class& klass =
277 dart::Class::Handle(zone_, parsed_function_->function().Owner()); 277 dart::Class::Handle(zone_, parsed_function_->function().Owner());
278 Function& outermost_function = Function::Handle(Z); 278 Function& outermost_function = Function::Handle(Z);
279 TreeNode* outermost_node = NULL; 279 TreeNode* outermost_node = NULL;
280 Class* kernel_klass = NULL; 280 Class* kernel_class = NULL;
281 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node, 281 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node,
282 &kernel_klass); 282 &kernel_class);
283 // Use [klass]/[kernel_klass] as active class. Type parameters will get 283 // Use [klass]/[kernel_class] as active class. Type parameters will get
284 // resolved via [kernel_klass] unless we are nested inside a static factory 284 // resolved via [kernel_class] unless we are nested inside a static factory
285 // in which case we will use [member]. 285 // in which case we will use [member].
286 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); 286 ActiveClassScope active_class_scope(&active_class_, kernel_class, &klass);
287 Member* member = ((outermost_node != NULL) && outermost_node->IsMember()) 287 Member* member = ((outermost_node != NULL) && outermost_node->IsMember())
288 ? Member::Cast(outermost_node) 288 ? Member::Cast(outermost_node)
289 : NULL; 289 : NULL;
290 ActiveMemberScope active_member(&active_class_, member); 290 ActiveMemberScope active_member(&active_class_, member);
291 291
292 292
293 LocalScope* enclosing_scope = NULL; 293 LocalScope* enclosing_scope = NULL;
294 if (function.IsLocalFunction()) { 294 if (function.IsLocalFunction()) {
295 enclosing_scope = LocalScope::RestoreOuterScope( 295 enclosing_scope = LocalScope::RestoreOuterScope(
296 ContextScope::Handle(Z, function.context_scope())); 296 ContextScope::Handle(Z, function.context_scope()));
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 } 1063 }
1064 1064
1065 1065
1066 dart::String& TranslationHelper::DartSymbol(String* content) const { 1066 dart::String& TranslationHelper::DartSymbol(String* content) const {
1067 return dart::String::ZoneHandle( 1067 return dart::String::ZoneHandle(
1068 Z, dart::Symbols::FromUTF8(thread_, content->buffer(), content->size())); 1068 Z, dart::Symbols::FromUTF8(thread_, content->buffer(), content->size()));
1069 } 1069 }
1070 1070
1071 1071
1072 const dart::String& TranslationHelper::DartClassName( 1072 const dart::String& TranslationHelper::DartClassName(
1073 CanonicalName* kernel_klass) { 1073 CanonicalName* kernel_class) {
1074 dart::String& name = DartString(kernel_klass->name()); 1074 ASSERT(kernel_class->IsClass());
1075 return ManglePrivateName(kernel_klass->parent(), &name); 1075 dart::String& name = DartString(kernel_class->name());
1076 return ManglePrivateName(kernel_class->parent(), &name);
1076 } 1077 }
1077 1078
1078 1079
1079 const dart::String& TranslationHelper::DartConstructorName(Constructor* node) { 1080 const dart::String& TranslationHelper::DartConstructorName(
1080 Class* klass = Class::Cast(node->parent()); 1081 CanonicalName* constructor) {
1081 return DartFactoryName(klass, node->name()); 1082 ASSERT(constructor->IsConstructor());
1083 return DartFactoryName(constructor);
1082 } 1084 }
1083 1085
1084 1086
1085 const dart::String& TranslationHelper::DartProcedureName(Procedure* procedure) { 1087 const dart::String& TranslationHelper::DartProcedureName(
1086 if (procedure->kind() == Procedure::kSetter) { 1088 CanonicalName* procedure) {
1087 return DartSetterName(procedure->name()); 1089 ASSERT(procedure->IsProcedure());
1088 } else if (procedure->kind() == Procedure::kGetter) { 1090 if (procedure->IsSetter()) {
1089 return DartGetterName(procedure->name()); 1091 return DartSetterName(procedure);
1090 } else if (procedure->kind() == Procedure::kFactory) { 1092 } else if (procedure->IsGetter()) {
1091 return DartFactoryName(Class::Cast(procedure->parent()), procedure->name()); 1093 return DartGetterName(procedure);
1094 } else if (procedure->IsFactory()) {
1095 return DartFactoryName(procedure);
1092 } else { 1096 } else {
1093 return DartMethodName(procedure->name()); 1097 return DartMethodName(procedure);
1094 } 1098 }
1095 } 1099 }
1096 1100
1097 1101
1098 const dart::String& TranslationHelper::DartSetterName(Name* kernel_name) { 1102 const dart::String& TranslationHelper::DartSetterName(CanonicalName* setter) {
1099 // The names flowing into [content] are coming from the Kernel file: 1103 return DartSetterName(setter->parent(), setter->name());
1104 }
1105
1106
1107 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) {
1108 return DartSetterName(setter_name->library(), setter_name->string());
1109 }
1110
1111
1112 const dart::String& TranslationHelper::DartSetterName(CanonicalName* parent,
1113 String* setter) {
1114 // The names flowing into [setter] are coming from the Kernel file:
1100 // * user-defined setters: `fieldname=` 1115 // * user-defined setters: `fieldname=`
1101 // * property-set expressions: `fieldname` 1116 // * property-set expressions: `fieldname`
1102 // 1117 //
1103 // The VM uses `get:fieldname` and `set:fieldname`. 1118 // The VM uses `get:fieldname` and `set:fieldname`.
1104 // 1119 //
1105 // => In order to be consistent, we remove the `=` always and adopt the VM 1120 // => In order to be consistent, we remove the `=` always and adopt the VM
1106 // conventions. 1121 // conventions.
1107 String* content = kernel_name->string(); 1122 ASSERT(setter->size() > 0);
1108 ASSERT(content->size() > 0);
1109 intptr_t skip = 0; 1123 intptr_t skip = 0;
1110 if (content->buffer()[content->size() - 1] == '=') { 1124 if (setter->buffer()[setter->size() - 1] == '=') {
1111 skip = 1; 1125 skip = 1;
1112 } 1126 }
1113 dart::String& name = dart::String::ZoneHandle( 1127 dart::String& name = dart::String::ZoneHandle(
1114 Z, dart::String::FromUTF8(content->buffer(), content->size() - skip, 1128 Z, dart::String::FromUTF8(setter->buffer(), setter->size() - skip,
1115 allocation_space_)); 1129 allocation_space_));
1116 ManglePrivateName(kernel_name->library_reference(), &name, false); 1130 ManglePrivateName(parent, &name, false);
1117 name = dart::Field::SetterSymbol(name); 1131 name = dart::Field::SetterSymbol(name);
1118 return name; 1132 return name;
1119 } 1133 }
1120 1134
1121 1135
1122 const dart::String& TranslationHelper::DartGetterName(Name* kernel_name) { 1136 const dart::String& TranslationHelper::DartGetterName(CanonicalName* getter) {
1123 dart::String& name = DartString(kernel_name->string()); 1137 return DartGetterName(getter->parent(), getter->name());
1124 ManglePrivateName(kernel_name->library_reference(), &name, false); 1138 }
1139
1140
1141 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) {
1142 return DartGetterName(getter_name->library(), getter_name->string());
1143 }
1144
1145
1146 const dart::String& TranslationHelper::DartGetterName(CanonicalName* parent,
1147 String* getter) {
1148 dart::String& name = DartString(getter);
1149 ManglePrivateName(parent, &name, false);
1125 name = dart::Field::GetterSymbol(name); 1150 name = dart::Field::GetterSymbol(name);
1126 return name; 1151 return name;
1127 } 1152 }
1128 1153
1129 1154
1130 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) { 1155 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) {
1131 dart::String& name = DartString(kernel_name->string()); 1156 dart::String& name = DartString(kernel_name->string());
1132 return ManglePrivateName(kernel_name->library_reference(), &name); 1157 return ManglePrivateName(kernel_name->library(), &name);
1133 } 1158 }
1134 1159
1135 1160
1136 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) { 1161 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) {
1137 // The [DartFieldName] will take care of mangling the name. 1162 // The [DartFieldName] will take care of mangling the name.
1138 dart::String& name = 1163 dart::String& name =
1139 dart::String::Handle(Z, DartFieldName(kernel_name).raw()); 1164 dart::String::Handle(Z, DartFieldName(kernel_name).raw());
1140 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name); 1165 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name);
1141 return name; 1166 return name;
1142 } 1167 }
1143 1168
1144 1169
1145 const dart::String& TranslationHelper::DartMethodName(Name* kernel_name) { 1170 const dart::String& TranslationHelper::DartMethodName(CanonicalName* method) {
1146 dart::String& name = DartString(kernel_name->string()); 1171 return DartMethodName(method->parent(), method->name());
1147 return ManglePrivateName(kernel_name->library_reference(), &name);
1148 } 1172 }
1149 1173
1150 1174
1151 const dart::String& TranslationHelper::DartFactoryName(Class* klass, 1175 const dart::String& TranslationHelper::DartMethodName(Name* method_name) {
1152 Name* method_name) { 1176 return DartMethodName(method_name->library(), method_name->string());
1177 }
1178
1179
1180 const dart::String& TranslationHelper::DartMethodName(CanonicalName* parent,
1181 String* method) {
1182 dart::String& name = DartString(method);
1183 return ManglePrivateName(parent, &name);
1184 }
1185
1186
1187 const dart::String& TranslationHelper::DartFactoryName(CanonicalName* factory) {
1188 ASSERT(factory->IsConstructor() || factory->IsFactory());
1189 GrowableHandlePtrArray<const dart::String> pieces(Z, 3);
1190 pieces.Add(DartClassName(factory->EnclosingName()));
1191 pieces.Add(Symbols::Dot());
1153 // [DartMethodName] will mangle the name. 1192 // [DartMethodName] will mangle the name.
1154 GrowableHandlePtrArray<const dart::String> pieces(Z, 3); 1193 pieces.Add(DartMethodName(factory));
1155 pieces.Add(DartClassName(klass->canonical_name()));
1156 pieces.Add(Symbols::Dot());
1157 pieces.Add(DartMethodName(method_name));
1158 return dart::String::ZoneHandle( 1194 return dart::String::ZoneHandle(
1159 Z, dart::Symbols::FromConcatAll(thread_, pieces)); 1195 Z, dart::Symbols::FromConcatAll(thread_, pieces));
1160 } 1196 }
1161 1197
1162 1198
1163 dart::RawLibrary* TranslationHelper::LookupLibraryByKernelLibrary( 1199 dart::RawLibrary* TranslationHelper::LookupLibraryByKernelLibrary(
1164 CanonicalName* kernel_library) { 1200 CanonicalName* kernel_library) {
1201 // We only use the name and don't rely on having any particular parent. This
1202 // ASSERT is just a sanity check.
1203 ASSERT(kernel_library->IsLibrary() ||
1204 kernel_library->parent()->IsAdministrative());
1165 const dart::String& library_name = DartSymbol(kernel_library->name()); 1205 const dart::String& library_name = DartSymbol(kernel_library->name());
1166 ASSERT(!library_name.IsNull()); 1206 ASSERT(!library_name.IsNull());
1167 dart::RawLibrary* library = 1207 dart::RawLibrary* library =
1168 dart::Library::LookupLibrary(thread_, library_name); 1208 dart::Library::LookupLibrary(thread_, library_name);
1169 ASSERT(library != Object::null()); 1209 ASSERT(library != Object::null());
1170 return library; 1210 return library;
1171 } 1211 }
1172 1212
1173 1213
1174 dart::RawClass* TranslationHelper::LookupClassByKernelClass( 1214 dart::RawClass* TranslationHelper::LookupClassByKernelClass(
1175 CanonicalName* kernel_klass) { 1215 CanonicalName* kernel_class) {
1216 ASSERT(kernel_class->IsClass());
1176 dart::RawClass* klass = NULL; 1217 dart::RawClass* klass = NULL;
1177 1218 const dart::String& class_name = DartClassName(kernel_class);
1178 const dart::String& class_name = DartClassName(kernel_klass); 1219 CanonicalName* kernel_library = kernel_class->parent();
1179 CanonicalName* kernel_library = kernel_klass->parent();
1180 dart::Library& library = 1220 dart::Library& library =
1181 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); 1221 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library));
1182 klass = library.LookupClassAllowPrivate(class_name); 1222 klass = library.LookupClassAllowPrivate(class_name);
1183 1223
1184 ASSERT(klass != Object::null()); 1224 ASSERT(klass != Object::null());
1185 return klass; 1225 return klass;
1186 } 1226 }
1187 1227
1188 1228
1189 dart::RawField* TranslationHelper::LookupFieldByKernelField( 1229 dart::RawField* TranslationHelper::LookupFieldByKernelField(
1190 Field* kernel_field) { 1230 CanonicalName* kernel_field) {
1191 TreeNode* node = kernel_field->parent(); 1231 ASSERT(kernel_field->IsField());
1232 CanonicalName* enclosing = kernel_field->EnclosingName();
1192 1233
1193 dart::Class& klass = dart::Class::Handle(Z); 1234 dart::Class& klass = dart::Class::Handle(Z);
1194 if (node->IsClass()) { 1235 if (enclosing->IsLibrary()) {
1195 klass = LookupClassByKernelClass(Class::Cast(node)->canonical_name()); 1236 dart::Library& library =
1237 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing));
1238 klass = library.toplevel_class();
1196 } else { 1239 } else {
1197 ASSERT(node->IsLibrary()); 1240 ASSERT(enclosing->IsClass());
1198 dart::Library& library = dart::Library::Handle( 1241 klass = LookupClassByKernelClass(enclosing);
1199 Z, LookupLibraryByKernelLibrary(Library::Cast(node)->canonical_name()));
1200 klass = library.toplevel_class();
1201 } 1242 }
1202 dart::RawField* field = 1243 dart::RawField* field =
1203 klass.LookupFieldAllowPrivate(DartSymbol(kernel_field->name()->string())); 1244 klass.LookupFieldAllowPrivate(DartSymbol(kernel_field->name()));
1204 ASSERT(field != Object::null()); 1245 ASSERT(field != Object::null());
1205 return field; 1246 return field;
1206 } 1247 }
1207 1248
1208 1249
1209 dart::RawFunction* TranslationHelper::LookupStaticMethodByKernelProcedure( 1250 dart::RawFunction* TranslationHelper::LookupStaticMethodByKernelProcedure(
1210 Procedure* procedure) { 1251 CanonicalName* procedure) {
1211 ASSERT(procedure->IsStatic());
1212 const dart::String& procedure_name = DartProcedureName(procedure); 1252 const dart::String& procedure_name = DartProcedureName(procedure);
1213 1253
1214 // The parent is either a library or a class (in which case the procedure is a 1254 // The parent is either a library or a class (in which case the procedure is a
1215 // static method). 1255 // static method).
1216 TreeNode* parent = procedure->parent(); 1256 CanonicalName* enclosing = procedure->EnclosingName();
1217 if (parent->IsClass()) { 1257 if (enclosing->IsLibrary()) {
1218 dart::Class& klass = dart::Class::Handle( 1258 dart::Library& library =
1219 Z, LookupClassByKernelClass(Class::Cast(parent)->canonical_name())); 1259 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing));
1260 dart::RawFunction* function =
1261 library.LookupFunctionAllowPrivate(procedure_name);
1262 ASSERT(function != Object::null());
1263 return function;
1264 } else {
1265 ASSERT(enclosing->IsClass());
1266 dart::Class& klass =
1267 dart::Class::Handle(Z, LookupClassByKernelClass(enclosing));
1220 dart::RawFunction* raw_function = 1268 dart::RawFunction* raw_function =
1221 klass.LookupFunctionAllowPrivate(procedure_name); 1269 klass.LookupFunctionAllowPrivate(procedure_name);
1222 ASSERT(raw_function != Object::null()); 1270 ASSERT(raw_function != Object::null());
1223 1271
1224 // TODO(27590): We can probably get rid of this after no longer using 1272 // TODO(27590): We can probably get rid of this after no longer using
1225 // core libraries from the source. 1273 // core libraries from the source.
1226 dart::Function& function = dart::Function::ZoneHandle(Z, raw_function); 1274 dart::Function& function = dart::Function::ZoneHandle(Z, raw_function);
1227 if (function.IsRedirectingFactory()) { 1275 if (function.IsRedirectingFactory()) {
1228 ClassFinalizer::ResolveRedirectingFactory(klass, function); 1276 ClassFinalizer::ResolveRedirectingFactory(klass, function);
1229 function = function.RedirectionTarget(); 1277 function = function.RedirectionTarget();
1230 } 1278 }
1231 return function.raw(); 1279 return function.raw();
1232 } else {
1233 ASSERT(parent->IsLibrary());
1234 dart::Library& library = dart::Library::Handle(
1235 Z,
1236 LookupLibraryByKernelLibrary(Library::Cast(parent)->canonical_name()));
1237 dart::RawFunction* function =
1238 library.LookupFunctionAllowPrivate(procedure_name);
1239 ASSERT(function != Object::null());
1240 return function;
1241 } 1280 }
1242 } 1281 }
1243 1282
1244 1283
1245 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( 1284 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor(
1246 Constructor* constructor) { 1285 CanonicalName* constructor) {
1247 Class* kernel_klass = Class::Cast(constructor->parent()); 1286 ASSERT(constructor->IsConstructor());
1248 dart::Class& klass = dart::Class::Handle( 1287 dart::Class& klass = dart::Class::Handle(
1249 Z, LookupClassByKernelClass(kernel_klass->canonical_name())); 1288 Z, LookupClassByKernelClass(constructor->EnclosingName()));
1250 return LookupConstructorByKernelConstructor(klass, constructor); 1289 return LookupConstructorByKernelConstructor(klass, constructor);
1251 } 1290 }
1252 1291
1253 1292
1254 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( 1293 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor(
1255 const dart::Class& owner, 1294 const dart::Class& owner,
1256 Constructor* constructor) { 1295 CanonicalName* constructor) {
1296 ASSERT(constructor->IsConstructor());
1257 dart::RawFunction* function = 1297 dart::RawFunction* function =
1258 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)); 1298 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor));
1259 ASSERT(function != Object::null()); 1299 ASSERT(function != Object::null());
1260 return function; 1300 return function;
1261 } 1301 }
1262 1302
1263 1303
1264 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) { 1304 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) {
1265 ASSERT(!klass.IsNull()); 1305 ASSERT(!klass.IsNull());
1266 // Note that if cls is _Closure, the returned type will be _Closure, 1306 // Note that if cls is _Closure, the returned type will be _Closure,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 1339
1300 va_list args; 1340 va_list args;
1301 va_start(args, format); 1341 va_start(args, format);
1302 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format, 1342 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format,
1303 args); 1343 args);
1304 va_end(args); 1344 va_end(args);
1305 UNREACHABLE(); 1345 UNREACHABLE();
1306 } 1346 }
1307 1347
1308 1348
1309 dart::String& TranslationHelper::ManglePrivateName( 1349 dart::String& TranslationHelper::ManglePrivateName(CanonicalName* parent,
1310 CanonicalName* kernel_library, 1350 dart::String* name_to_modify,
1311 dart::String* name_to_modify, 1351 bool symbolize) {
1312 bool symbolize) {
1313 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') { 1352 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') {
1314 const dart::Library& library = 1353 const dart::Library& library =
1315 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); 1354 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(parent));
1316 *name_to_modify = library.PrivateName(*name_to_modify); 1355 *name_to_modify = library.PrivateName(*name_to_modify);
1317 } else if (symbolize) { 1356 } else if (symbolize) {
1318 *name_to_modify = Symbols::New(thread_, *name_to_modify); 1357 *name_to_modify = Symbols::New(thread_, *name_to_modify);
1319 } 1358 }
1320 return *name_to_modify; 1359 return *name_to_modify;
1321 } 1360 }
1322 1361
1323 1362
1324 const Array& TranslationHelper::ArgumentNames(List<NamedExpression>* named) { 1363 const Array& TranslationHelper::ArgumentNames(List<NamedExpression>* named) {
1325 if (named->length() == 0) return Array::ZoneHandle(Z); 1364 if (named->length() == 0) return Array::ZoneHandle(Z);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 ASSERT(!function.IsNull()); 1712 ASSERT(!function.IsNull());
1674 1713
1675 // Run the method and canonicalize the result. 1714 // Run the method and canonicalize the result.
1676 const Object& result = RunFunction(function, kernel_arguments, &receiver); 1715 const Object& result = RunFunction(function, kernel_arguments, &receiver);
1677 result_ ^= result.raw(); 1716 result_ ^= result.raw();
1678 result_ = H.Canonicalize(result_); 1717 result_ = H.Canonicalize(result_);
1679 } 1718 }
1680 1719
1681 1720
1682 void ConstantEvaluator::VisitStaticGet(StaticGet* node) { 1721 void ConstantEvaluator::VisitStaticGet(StaticGet* node) {
1683 Member* member = node->target(); 1722 CanonicalName* target = node->target();
1684 if (member->IsField()) { 1723 if (target->IsField()) {
1685 Field* kernel_field = Field::Cast(member);
1686 const dart::Field& field = 1724 const dart::Field& field =
1687 dart::Field::Handle(Z, H.LookupFieldByKernelField(kernel_field)); 1725 dart::Field::Handle(Z, H.LookupFieldByKernelField(target));
1688 if (field.StaticValue() == Object::sentinel().raw() || 1726 if (field.StaticValue() == Object::sentinel().raw() ||
1689 field.StaticValue() == Object::transition_sentinel().raw()) { 1727 field.StaticValue() == Object::transition_sentinel().raw()) {
1690 field.EvaluateInitializer(); 1728 field.EvaluateInitializer();
1691 result_ = field.StaticValue(); 1729 result_ = field.StaticValue();
1692 result_ = H.Canonicalize(result_); 1730 result_ = H.Canonicalize(result_);
1693 field.SetStaticValue(result_, true); 1731 field.SetStaticValue(result_, true);
1694 } else { 1732 } else {
1695 result_ = field.StaticValue(); 1733 result_ = field.StaticValue();
1696 } 1734 }
1697 } else if (member->IsProcedure()) { 1735 } else if (target->IsProcedure()) {
1698 Procedure* procedure = Procedure::Cast(member); 1736 const Function& function =
1699 const Function& target = Function::ZoneHandle( 1737 Function::ZoneHandle(Z, H.LookupStaticMethodByKernelProcedure(target));
1700 Z, H.LookupStaticMethodByKernelProcedure(procedure));
1701 1738
1702 if (procedure->kind() == Procedure::kMethod) { 1739 if (target->IsMethod()) {
1703 ASSERT(procedure->IsStatic());
1704 Function& closure_function = 1740 Function& closure_function =
1705 Function::ZoneHandle(Z, target.ImplicitClosureFunction()); 1741 Function::ZoneHandle(Z, function.ImplicitClosureFunction());
1706 closure_function.set_kernel_function(target.kernel_function()); 1742 closure_function.set_kernel_function(function.kernel_function());
1707 result_ = closure_function.ImplicitStaticClosure(); 1743 result_ = closure_function.ImplicitStaticClosure();
1708 result_ = H.Canonicalize(result_); 1744 result_ = H.Canonicalize(result_);
1709 } else if (procedure->kind() == Procedure::kGetter) { 1745 } else if (target->IsGetter()) {
1710 UNIMPLEMENTED(); 1746 UNIMPLEMENTED();
1711 } else { 1747 } else {
1712 UNIMPLEMENTED(); 1748 UNIMPLEMENTED();
1713 } 1749 }
1714 } 1750 }
1715 } 1751 }
1716 1752
1717 1753
1718 void ConstantEvaluator::VisitVariableGet(VariableGet* node) { 1754 void ConstantEvaluator::VisitVariableGet(VariableGet* node) {
1719 // When we see a [VariableGet] the corresponding [VariableDeclaration] must've 1755 // When we see a [VariableGet] the corresponding [VariableDeclaration] must've
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 } 1843 }
1808 } 1844 }
1809 1845
1810 1846
1811 void ConstantEvaluator::VisitNot(Not* node) { 1847 void ConstantEvaluator::VisitNot(Not* node) {
1812 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); 1848 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw();
1813 } 1849 }
1814 1850
1815 1851
1816 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { 1852 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) {
1817 const intptr_t kLengthLen = strlen("length"); 1853 const intptr_t kLengthLen = sizeof("length") - 1;
1818 1854
1819 String* string = node->name()->string(); 1855 String* string = node->name()->string();
1820 if ((string->size() == kLengthLen) && 1856 if ((string->size() == kLengthLen) &&
1821 (memcmp(string->buffer(), "length", kLengthLen) == 0)) { 1857 (memcmp(string->buffer(), "length", kLengthLen) == 0)) {
1822 node->receiver()->AcceptExpressionVisitor(this); 1858 node->receiver()->AcceptExpressionVisitor(this);
1823 if (result_.IsString()) { 1859 if (result_.IsString()) {
1824 const dart::String& str = 1860 const dart::String& str =
1825 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); 1861 dart::String::Handle(Z, dart::String::RawCast(result_.raw()));
1826 result_ = Integer::New(str.Length()); 1862 result_ = Integer::New(str.Length());
1827 } else { 1863 } else {
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 2868
2833 instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6); 2869 instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6);
2834 // Leave "result" on the stack since callers expect it to be there (even 2870 // Leave "result" on the stack since callers expect it to be there (even
2835 // though the function will result in an exception). 2871 // though the function will result in an exception).
2836 2872
2837 return instructions; 2873 return instructions;
2838 } 2874 }
2839 2875
2840 2876
2841 dart::RawFunction* FlowGraphBuilder::LookupMethodByMember( 2877 dart::RawFunction* FlowGraphBuilder::LookupMethodByMember(
2842 Member* target, 2878 CanonicalName* target,
2843 const dart::String& method_name) { 2879 const dart::String& method_name) {
2844 Class* kernel_klass = Class::Cast(target->parent()); 2880 CanonicalName* kernel_class = target->EnclosingName();
2845 dart::Class& klass = dart::Class::Handle( 2881 dart::Class& klass =
2846 Z, H.LookupClassByKernelClass(kernel_klass->canonical_name())); 2882 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class));
2847 2883
2848 dart::RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); 2884 dart::RawFunction* function = klass.LookupFunctionAllowPrivate(method_name);
2849 ASSERT(function != Object::null()); 2885 ASSERT(function != Object::null());
2850 return function; 2886 return function;
2851 } 2887 }
2852 2888
2853 2889
2854 LocalVariable* FlowGraphBuilder::MakeTemporary() { 2890 LocalVariable* FlowGraphBuilder::MakeTemporary() {
2855 char name[64]; 2891 char name[64];
2856 intptr_t index = stack_->definition()->temp_index(); 2892 intptr_t index = stack_->definition()->temp_index();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 FlowGraph* FlowGraphBuilder::BuildGraph() { 3031 FlowGraph* FlowGraphBuilder::BuildGraph() {
2996 const dart::Function& function = parsed_function_->function(); 3032 const dart::Function& function = parsed_function_->function();
2997 3033
2998 if (function.IsConstructorClosureFunction()) return NULL; 3034 if (function.IsConstructorClosureFunction()) return NULL;
2999 3035
3000 dart::Class& klass = 3036 dart::Class& klass =
3001 dart::Class::Handle(zone_, parsed_function_->function().Owner()); 3037 dart::Class::Handle(zone_, parsed_function_->function().Owner());
3002 3038
3003 Function& outermost_function = Function::Handle(Z); 3039 Function& outermost_function = Function::Handle(Z);
3004 TreeNode* outermost_node = NULL; 3040 TreeNode* outermost_node = NULL;
3005 Class* kernel_klass = NULL; 3041 Class* kernel_class = NULL;
3006 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node, 3042 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node,
3007 &kernel_klass); 3043 &kernel_class);
3008 3044
3009 // Mark that we are using [klass]/[kernell_klass] as active class. Resolving 3045 // Mark that we are using [klass]/[kernell_klass] as active class. Resolving
3010 // of type parameters will get resolved via [kernell_klass] unless we are 3046 // of type parameters will get resolved via [kernell_klass] unless we are
3011 // nested inside a static factory in which case we will use [member]. 3047 // nested inside a static factory in which case we will use [member].
3012 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); 3048 ActiveClassScope active_class_scope(&active_class_, kernel_class, &klass);
3013 Member* member = ((outermost_node != NULL) && outermost_node->IsMember()) 3049 Member* member = ((outermost_node != NULL) && outermost_node->IsMember())
3014 ? Member::Cast(outermost_node) 3050 ? Member::Cast(outermost_node)
3015 : NULL; 3051 : NULL;
3016 ActiveMemberScope active_member(&active_class_, member); 3052 ActiveMemberScope active_member(&active_class_, member);
3017 3053
3018 // The IR builder will create its own local variables and scopes, and it 3054 // The IR builder will create its own local variables and scopes, and it
3019 // will not need an AST. The code generator will assume that there is a 3055 // will not need an AST. The code generator will assume that there is a
3020 // local variable stack slot allocated for the current context and (I 3056 // local variable stack slot allocated for the current context and (I
3021 // think) that the runtime will expect it to be at a fixed offset which 3057 // think) that the runtime will expect it to be at a fixed offset which
3022 // requires allocating an unused expression temporary variable. 3058 // requires allocating an unused expression temporary variable.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 body += StoreLocal(TokenPosition::kNoSource, parameter); 3155 body += StoreLocal(TokenPosition::kNoSource, parameter);
3120 body += Drop(); 3156 body += Drop();
3121 } 3157 }
3122 } 3158 }
3123 body += Drop(); // The context. 3159 body += Drop(); // The context.
3124 } 3160 }
3125 if (constructor != NULL) { 3161 if (constructor != NULL) {
3126 // TODO(27590): Currently the [VariableDeclaration]s from the 3162 // TODO(27590): Currently the [VariableDeclaration]s from the
3127 // initializers will be visible inside the entire body of the constructor. 3163 // initializers will be visible inside the entire body of the constructor.
3128 // We should make a separate scope for them. 3164 // We should make a separate scope for them.
3129 Class* kernel_klass = Class::Cast(constructor->parent()); 3165 Class* kernel_class = Class::Cast(constructor->parent());
3130 body += TranslateInitializers(kernel_klass, &constructor->initializers()); 3166 body += TranslateInitializers(kernel_class, &constructor->initializers());
3131 } 3167 }
3132 3168
3133 // The specification defines the result of `a == b` to be: 3169 // The specification defines the result of `a == b` to be:
3134 // 3170 //
3135 // a) if either side is `null` then the result is `identical(a, b)`. 3171 // a) if either side is `null` then the result is `identical(a, b)`.
3136 // b) else the result is `a.operator==(b)` 3172 // b) else the result is `a.operator==(b)`
3137 // 3173 //
3138 // For user-defined implementations of `operator==` we need therefore 3174 // For user-defined implementations of `operator==` we need therefore
3139 // implement the handling of a). 3175 // implement the handling of a).
3140 // 3176 //
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 } 3556 }
3521 3557
3522 3558
3523 FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor( 3559 FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor(
3524 Field* kernel_field, 3560 Field* kernel_field,
3525 LocalVariable* setter_value) { 3561 LocalVariable* setter_value) {
3526 const dart::Function& function = parsed_function_->function(); 3562 const dart::Function& function = parsed_function_->function();
3527 3563
3528 bool is_setter = function.IsImplicitSetterFunction(); 3564 bool is_setter = function.IsImplicitSetterFunction();
3529 bool is_method = !function.IsStaticFunction(); 3565 bool is_method = !function.IsStaticFunction();
3530 dart::Field& field = 3566 dart::Field& field = dart::Field::ZoneHandle(
3531 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); 3567 Z, H.LookupFieldByKernelField(kernel_field->canonical_name()));
3532 3568
3533 TargetEntryInstr* normal_entry = BuildTargetEntry(); 3569 TargetEntryInstr* normal_entry = BuildTargetEntry();
3534 graph_entry_ = new (Z) 3570 graph_entry_ = new (Z)
3535 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); 3571 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId);
3536 3572
3537 Fragment body(normal_entry); 3573 Fragment body(normal_entry);
3538 if (is_setter) { 3574 if (is_setter) {
3539 if (is_method) { 3575 if (is_method) {
3540 body += LoadLocal(scopes_->this_variable); 3576 body += LoadLocal(scopes_->this_variable);
3541 body += LoadLocal(setter_value); 3577 body += LoadLocal(setter_value);
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index); 4103 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index);
4068 } 4104 }
4069 4105
4070 4106
4071 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { 4107 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() {
4072 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); 4108 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex());
4073 } 4109 }
4074 4110
4075 4111
4076 Fragment FlowGraphBuilder::TranslateInitializers( 4112 Fragment FlowGraphBuilder::TranslateInitializers(
4077 Class* kernel_klass, 4113 Class* kernel_class,
4078 List<Initializer>* initializers) { 4114 List<Initializer>* initializers) {
4079 Fragment instructions; 4115 Fragment instructions;
4080 4116
4081 // These come from: 4117 // These come from:
4082 // class A { 4118 // class A {
4083 // var x = (expr); 4119 // var x = (expr);
4084 // } 4120 // }
4085 for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) { 4121 for (intptr_t i = 0; i < kernel_class->fields().length(); i++) {
4086 Field* kernel_field = kernel_klass->fields()[i]; 4122 Field* kernel_field = kernel_class->fields()[i];
4087 Expression* init = kernel_field->initializer(); 4123 Expression* init = kernel_field->initializer();
4088 if (!kernel_field->IsStatic() && init != NULL) { 4124 if (!kernel_field->IsStatic() && init != NULL) {
4089 dart::Field& field = 4125 dart::Field& field = dart::Field::ZoneHandle(
4090 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); 4126 Z, H.LookupFieldByKernelField(kernel_field->canonical_name()));
4091 4127
4092 EnterScope(kernel_field); 4128 EnterScope(kernel_field);
4093 instructions += LoadLocal(scopes_->this_variable); 4129 instructions += LoadLocal(scopes_->this_variable);
4094 instructions += TranslateExpression(init); 4130 instructions += TranslateExpression(init);
4095 instructions += StoreInstanceFieldGuarded(field, true); 4131 instructions += StoreInstanceFieldGuarded(field, true);
4096 ExitScope(kernel_field); 4132 ExitScope(kernel_field);
4097 } 4133 }
4098 } 4134 }
4099 4135
4100 // These to come from: 4136 // These to come from:
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 4511
4476 4512
4477 void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) { 4513 void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) {
4478 // NOTE: That an interface type like `T<A, B>` is considered to be 4514 // NOTE: That an interface type like `T<A, B>` is considered to be
4479 // malformed iff `T` is malformed. 4515 // malformed iff `T` is malformed.
4480 // => We therefore ignore errors in `A` or `B`. 4516 // => We therefore ignore errors in `A` or `B`.
4481 const TypeArguments& type_arguments = TranslateTypeArguments( 4517 const TypeArguments& type_arguments = TranslateTypeArguments(
4482 node->type_arguments().raw_array(), node->type_arguments().length()); 4518 node->type_arguments().raw_array(), node->type_arguments().length());
4483 4519
4484 4520
4485 dart::Object& klass = dart::Object::Handle( 4521 dart::Object& klass =
4486 Z, H.LookupClassByKernelClass(node->class_reference())); 4522 dart::Object::Handle(Z, H.LookupClassByKernelClass(node->klass()));
4487 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource); 4523 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource);
4488 if (finalize_) { 4524 if (finalize_) {
4489 ASSERT(active_class_->klass != NULL); 4525 ASSERT(active_class_->klass != NULL);
4490 result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_); 4526 result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_);
4491 } 4527 }
4492 } 4528 }
4493 4529
4494 4530
4495 void DartTypeTranslator::VisitDynamicType(DynamicType* node) { 4531 void DartTypeTranslator::VisitDynamicType(DynamicType* node) {
4496 result_ = Object::dynamic_type().raw(); 4532 result_ = Object::dynamic_type().raw();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4599 instructions = DebugStepCheck(node->position()) + instructions; 4635 instructions = DebugStepCheck(node->position()) + instructions;
4600 } 4636 }
4601 instructions += CheckVariableTypeInCheckedMode(node->variable()); 4637 instructions += CheckVariableTypeInCheckedMode(node->variable());
4602 instructions += 4638 instructions +=
4603 StoreLocal(node->position(), LookupVariable(node->variable())); 4639 StoreLocal(node->position(), LookupVariable(node->variable()));
4604 fragment_ = instructions; 4640 fragment_ = instructions;
4605 } 4641 }
4606 4642
4607 4643
4608 void FlowGraphBuilder::VisitStaticGet(StaticGet* node) { 4644 void FlowGraphBuilder::VisitStaticGet(StaticGet* node) {
4609 Member* target = node->target(); 4645 CanonicalName* target = node->target();
4610 if (target->IsField()) { 4646 if (target->IsField()) {
4611 Field* kernel_field = Field::Cast(target);
4612 const dart::Field& field = 4647 const dart::Field& field =
4613 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); 4648 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target));
4614 if (field.is_const()) { 4649 if (field.is_const()) {
4615 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node)); 4650 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node));
4616 } else { 4651 } else {
4617 const dart::Class& owner = dart::Class::Handle(Z, field.Owner()); 4652 const dart::Class& owner = dart::Class::Handle(Z, field.Owner());
4618 const dart::String& getter_name = H.DartGetterName(kernel_field->name()); 4653 const dart::String& getter_name = H.DartGetterName(target);
4619 const Function& getter = 4654 const Function& getter =
4620 Function::ZoneHandle(Z, owner.LookupStaticFunction(getter_name)); 4655 Function::ZoneHandle(Z, owner.LookupStaticFunction(getter_name));
4621 if (getter.IsNull() || !field.has_initializer()) { 4656 if (getter.IsNull() || !field.has_initializer()) {
4622 Fragment instructions = Constant(field); 4657 Fragment instructions = Constant(field);
4623 fragment_ = instructions + LoadStaticField(); 4658 fragment_ = instructions + LoadStaticField();
4624 } else { 4659 } else {
4625 fragment_ = StaticCall(node->position(), getter, 0); 4660 fragment_ = StaticCall(node->position(), getter, 0);
4626 } 4661 }
4627 } 4662 }
4628 } else { 4663 } else {
4629 Procedure* procedure = Procedure::Cast(target); 4664 const Function& function =
4630 const Function& target = Function::ZoneHandle( 4665 Function::ZoneHandle(Z, H.LookupStaticMethodByKernelProcedure(target));
4631 Z, H.LookupStaticMethodByKernelProcedure(procedure));
4632 4666
4633 if (procedure->kind() == Procedure::kGetter) { 4667 if (target->IsGetter()) {
4634 fragment_ = StaticCall(node->position(), target, 0); 4668 fragment_ = StaticCall(node->position(), function, 0);
4635 } else if (procedure->kind() == Procedure::kMethod) { 4669 } else if (target->IsMethod()) {
4636 ASSERT(procedure->IsStatic());
4637 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node)); 4670 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node));
4638 } else { 4671 } else {
4639 UNIMPLEMENTED(); 4672 UNIMPLEMENTED();
4640 } 4673 }
4641 } 4674 }
4642 } 4675 }
4643 4676
4644 4677
4645 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) { 4678 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) {
4646 Member* target = node->target(); 4679 CanonicalName* target = node->target();
4647 if (target->IsField()) { 4680 if (target->IsField()) {
4648 Field* kernel_field = Field::Cast(target);
4649 const dart::Field& field = 4681 const dart::Field& field =
4650 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); 4682 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target));
4651 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); 4683 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type());
4652 Fragment instructions = TranslateExpression(node->expression()); 4684 Fragment instructions = TranslateExpression(node->expression());
4653 if (NeedsDebugStepCheck(stack_, node->position())) { 4685 if (NeedsDebugStepCheck(stack_, node->position())) {
4654 instructions = DebugStepCheck(node->position()) + instructions; 4686 instructions = DebugStepCheck(node->position()) + instructions;
4655 } 4687 }
4656 instructions += CheckAssignableInCheckedMode( 4688 instructions += CheckAssignableInCheckedMode(
4657 dst_type, dart::String::ZoneHandle(Z, field.name())); 4689 dst_type, dart::String::ZoneHandle(Z, field.name()));
4658 LocalVariable* variable = MakeTemporary(); 4690 LocalVariable* variable = MakeTemporary();
4659 instructions += LoadLocal(variable); 4691 instructions += LoadLocal(variable);
4660 fragment_ = instructions + StoreStaticField(node->position(), field); 4692 fragment_ = instructions + StoreStaticField(node->position(), field);
4661 } else { 4693 } else {
4662 ASSERT(target->IsProcedure()); 4694 ASSERT(target->IsProcedure());
4663 4695
4664 // Evaluate the expression on the right hand side. 4696 // Evaluate the expression on the right hand side.
4665 Fragment instructions = TranslateExpression(node->expression()); 4697 Fragment instructions = TranslateExpression(node->expression());
4666 LocalVariable* variable = MakeTemporary(); 4698 LocalVariable* variable = MakeTemporary();
4667 4699
4668 // Prepare argument. 4700 // Prepare argument.
4669 instructions += LoadLocal(variable); 4701 instructions += LoadLocal(variable);
4670 instructions += PushArgument(); 4702 instructions += PushArgument();
4671 4703
4672 // Invoke the setter function. 4704 // Invoke the setter function.
4673 Procedure* procedure = Procedure::Cast(target); 4705 const Function& function =
4674 const Function& target = Function::ZoneHandle( 4706 Function::ZoneHandle(Z, H.LookupStaticMethodByKernelProcedure(target));
4675 Z, H.LookupStaticMethodByKernelProcedure(procedure)); 4707 instructions += StaticCall(node->position(), function, 1);
4676 instructions += StaticCall(node->position(), target, 1);
4677 4708
4678 // Drop the unused result & leave the stored value on the stack. 4709 // Drop the unused result & leave the stored value on the stack.
4679 fragment_ = instructions + Drop(); 4710 fragment_ = instructions + Drop();
4680 } 4711 }
4681 } 4712 }
4682 4713
4683 4714
4684 void FlowGraphBuilder::VisitPropertyGet(PropertyGet* node) { 4715 void FlowGraphBuilder::VisitPropertyGet(PropertyGet* node) {
4685 Fragment instructions = TranslateExpression(node->receiver()); 4716 Fragment instructions = TranslateExpression(node->receiver());
4686 instructions += PushArgument(); 4717 instructions += PushArgument();
(...skipping 13 matching lines...) Expand all
4700 instructions += PushArgument(); 4731 instructions += PushArgument();
4701 4732
4702 const dart::String& setter_name = H.DartSetterName(node->name()); 4733 const dart::String& setter_name = H.DartSetterName(node->name());
4703 instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2); 4734 instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2);
4704 fragment_ = instructions + Drop(); 4735 fragment_ = instructions + Drop();
4705 } 4736 }
4706 4737
4707 4738
4708 void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) { 4739 void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) {
4709 Function& target = Function::ZoneHandle(Z); 4740 Function& target = Function::ZoneHandle(Z);
4710 if (node->target()->IsProcedure()) { 4741 CanonicalName* kernel_name = node->target();
4711 Procedure* kernel_procedure = Procedure::Cast(node->target()); 4742 if (kernel_name->IsProcedure()) {
4712 Name* kernel_name = kernel_procedure->name(); 4743 if (kernel_name->IsGetter()) {
4713 if (kernel_procedure->kind() == Procedure::kGetter) { 4744 target = LookupMethodByMember(kernel_name, H.DartGetterName(kernel_name));
4714 target =
4715 LookupMethodByMember(kernel_procedure, H.DartGetterName(kernel_name));
4716 } else { 4745 } else {
4717 target = 4746 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name));
4718 LookupMethodByMember(kernel_procedure, H.DartMethodName(kernel_name));
4719 target = target.ImplicitClosureFunction(); 4747 target = target.ImplicitClosureFunction();
4720 ASSERT(!target.IsNull()); 4748 ASSERT(!target.IsNull());
4721 fragment_ = BuildImplicitClosureCreation(target); 4749 fragment_ = BuildImplicitClosureCreation(target);
4722 return; 4750 return;
4723 } 4751 }
4724 } else { 4752 } else {
4725 ASSERT(node->target()->IsField()); 4753 ASSERT(kernel_name->IsField());
4726 const dart::String& getter_name = H.DartGetterName(node->target()->name()); 4754 const dart::String& getter_name = H.DartGetterName(kernel_name);
4727 target = LookupMethodByMember(node->target(), getter_name); 4755 target = LookupMethodByMember(kernel_name, getter_name);
4728 ASSERT(target.IsGetterFunction() || target.IsImplicitGetterFunction()); 4756 ASSERT(target.IsGetterFunction() || target.IsImplicitGetterFunction());
4729 } 4757 }
4730 4758
4731 Fragment instructions = TranslateExpression(node->receiver()); 4759 Fragment instructions = TranslateExpression(node->receiver());
4732 instructions += PushArgument(); 4760 instructions += PushArgument();
4733 fragment_ = instructions + StaticCall(node->position(), target, 1); 4761 fragment_ = instructions + StaticCall(node->position(), target, 1);
4734 } 4762 }
4735 4763
4736 4764
4737 void FlowGraphBuilder::VisitDirectPropertySet(DirectPropertySet* node) { 4765 void FlowGraphBuilder::VisitDirectPropertySet(DirectPropertySet* node) {
4738 const dart::String& method_name = H.DartSetterName(node->target()->name()); 4766 const dart::String& method_name = H.DartSetterName(node->target());
4739 const Function& target = Function::ZoneHandle( 4767 const Function& target = Function::ZoneHandle(
4740 Z, LookupMethodByMember(node->target(), method_name)); 4768 Z, LookupMethodByMember(node->target(), method_name));
4741 ASSERT(target.IsSetterFunction() || target.IsImplicitSetterFunction()); 4769 ASSERT(target.IsSetterFunction() || target.IsImplicitSetterFunction());
4742 4770
4743 Fragment instructions(NullConstant()); 4771 Fragment instructions(NullConstant());
4744 LocalVariable* value = MakeTemporary(); 4772 LocalVariable* value = MakeTemporary();
4745 instructions += TranslateExpression(node->receiver()); 4773 instructions += TranslateExpression(node->receiver());
4746 instructions += PushArgument(); 4774 instructions += PushArgument();
4747 instructions += TranslateExpression(node->value()); 4775 instructions += TranslateExpression(node->value());
4748 instructions += StoreLocal(TokenPosition::kNoSource, value); 4776 instructions += StoreLocal(TokenPosition::kNoSource, value);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4920 } 4948 }
4921 4949
4922 4950
4923 void FlowGraphBuilder::VisitConstructorInvocation(ConstructorInvocation* node) { 4951 void FlowGraphBuilder::VisitConstructorInvocation(ConstructorInvocation* node) {
4924 if (node->is_const()) { 4952 if (node->is_const()) {
4925 fragment_ = 4953 fragment_ =
4926 Constant(constant_evaluator_.EvaluateConstructorInvocation(node)); 4954 Constant(constant_evaluator_.EvaluateConstructorInvocation(node));
4927 return; 4955 return;
4928 } 4956 }
4929 4957
4930 Class* kernel_class = Class::Cast(node->target()->parent());
4931
4932 dart::Class& klass = dart::Class::ZoneHandle( 4958 dart::Class& klass = dart::Class::ZoneHandle(
4933 Z, H.LookupClassByKernelClass(kernel_class->canonical_name())); 4959 Z, H.LookupClassByKernelClass(node->target()->EnclosingName()));
4934 4960
4935 Fragment instructions; 4961 Fragment instructions;
4936 4962
4937 // Check for malbounded-ness of type. 4963 // Check for malbounded-ness of type.
4938 if (I->type_checks()) { 4964 if (I->type_checks()) {
4939 List<DartType>& kernel_type_arguments = node->arguments()->types(); 4965 List<DartType>& kernel_type_arguments = node->arguments()->types();
4940 const TypeArguments& type_arguments = T.TranslateInstantiatedTypeArguments( 4966 const TypeArguments& type_arguments = T.TranslateInstantiatedTypeArguments(
4941 klass, kernel_type_arguments.raw_array(), 4967 klass, kernel_type_arguments.raw_array(),
4942 kernel_type_arguments.length()); 4968 kernel_type_arguments.length());
4943 4969
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
6463 thread->clear_sticky_error(); 6489 thread->clear_sticky_error();
6464 return error.raw(); 6490 return error.raw();
6465 } 6491 }
6466 } 6492 }
6467 6493
6468 6494
6469 } // namespace kernel 6495 } // namespace kernel
6470 } // namespace dart 6496 } // namespace dart
6471 6497
6472 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6498 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698