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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1410313005: Move most codegen registrations into WorldImpact. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../closure.dart' show 9 import '../../closure.dart' show
10 ClosureClassElement; 10 ClosureClassElement;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 js.Expression visitThis(tree_ir.This node) { 353 js.Expression visitThis(tree_ir.This node) {
354 return new js.This(); 354 return new js.This();
355 } 355 }
356 356
357 @override 357 @override
358 js.Expression visitTypeOperator(tree_ir.TypeOperator node) { 358 js.Expression visitTypeOperator(tree_ir.TypeOperator node) {
359 js.Expression value = visitExpression(node.value); 359 js.Expression value = visitExpression(node.value);
360 List<js.Expression> typeArguments = visitExpressionList(node.typeArguments); 360 List<js.Expression> typeArguments = visitExpressionList(node.typeArguments);
361 DartType type = node.type; 361 DartType type = node.type;
362 if (type is InterfaceType) { 362 if (type is InterfaceType) {
363 glue.registerIsCheck(type, registry); 363 registry.registerIsCheck(type);
364 //glue.registerIsCheck(type, registry);
364 ClassElement clazz = type.element; 365 ClassElement clazz = type.element;
365 366
366 if (glue.isStringClass(clazz)) { 367 if (glue.isStringClass(clazz)) {
367 if (node.isTypeTest) { 368 if (node.isTypeTest) {
368 return js.js(r'typeof # === "string"', <js.Expression>[value]); 369 return js.js(r'typeof # === "string"', <js.Expression>[value]);
369 } 370 }
370 // TODO(sra): Implement fast cast via calling 'stringTypeCast'. 371 // TODO(sra): Implement fast cast via calling 'stringTypeCast'.
371 } else if (glue.isBoolClass(clazz)) { 372 } else if (glue.isBoolClass(clazz)) {
372 if (node.isTypeTest) { 373 if (node.isTypeTest) {
373 return js.js(r'typeof # === "boolean"', <js.Expression>[value]); 374 return js.js(r'typeof # === "boolean"', <js.Expression>[value]);
(...skipping 24 matching lines...) Expand all
398 : new js.LiteralNull(); 399 : new js.LiteralNull();
399 400
400 js.Expression asT = glue.hasStrictSubtype(clazz) 401 js.Expression asT = glue.hasStrictSubtype(clazz)
401 ? js.quoteName(glue.getTypeSubstitutionTag(clazz)) 402 ? js.quoteName(glue.getTypeSubstitutionTag(clazz))
402 : new js.LiteralNull(); 403 : new js.LiteralNull();
403 404
404 return buildStaticHelperInvocation( 405 return buildStaticHelperInvocation(
405 function, 406 function,
406 <js.Expression>[value, isT, typeArgumentArray, asT]); 407 <js.Expression>[value, isT, typeArgumentArray, asT]);
407 } else if (type is TypeVariableType || type is FunctionType) { 408 } else if (type is TypeVariableType || type is FunctionType) {
408 glue.registerIsCheck(type, registry); 409 registry.registerIsCheck(type);
410 //glue.registerIsCheck(type, registry);
409 411
410 Element function = node.isTypeTest 412 Element function = node.isTypeTest
411 ? glue.getCheckSubtypeOfRuntimeType() 413 ? glue.getCheckSubtypeOfRuntimeType()
412 : glue.getSubtypeOfRuntimeTypeCast(); 414 : glue.getSubtypeOfRuntimeTypeCast();
413 415
414 // The only type argument is the type held in the type variable. 416 // The only type argument is the type held in the type variable.
415 js.Expression typeValue = typeArguments.single; 417 js.Expression typeValue = typeArguments.single;
416 418
417 return buildStaticHelperInvocation( 419 return buildStaticHelperInvocation(
418 function, 420 function,
419 <js.Expression>[value, typeValue]); 421 <js.Expression>[value, typeValue]);
420 } 422 }
421 return giveup(node, 'type check unimplemented for $type.'); 423 return giveup(node, 'type check unimplemented for $type.');
422 } 424 }
423 425
424 @override 426 @override
425 js.Expression visitGetTypeTestProperty(tree_ir.GetTypeTestProperty node) { 427 js.Expression visitGetTypeTestProperty(tree_ir.GetTypeTestProperty node) {
426 js.Expression object = visitExpression(node.object); 428 js.Expression object = visitExpression(node.object);
427 DartType dartType = node.dartType; 429 DartType dartType = node.dartType;
428 assert(dartType.isInterfaceType); 430 assert(dartType.isInterfaceType);
429 glue.registerIsCheck(dartType, registry); 431 registry.registerIsCheck(dartType);
432 //glue.registerIsCheck(dartType, registry);
430 js.Expression property = glue.getTypeTestTag(dartType); 433 js.Expression property = glue.getTypeTestTag(dartType);
431 return js.js(r'#.#', [object, property]); 434 return js.js(r'#.#', [object, property]);
432 } 435 }
433 436
434 @override 437 @override
435 js.Expression visitVariableUse(tree_ir.VariableUse node) { 438 js.Expression visitVariableUse(tree_ir.VariableUse node) {
436 return buildVariableAccess(node.variable); 439 return buildVariableAccess(node.variable);
437 } 440 }
438 441
439 js.Expression buildVariableAccess(tree_ir.Variable variable) { 442 js.Expression buildVariableAccess(tree_ir.Variable variable) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 js.Expression arguments = new js.ArrayInitializer( 712 js.Expression arguments = new js.ArrayInitializer(
710 visitExpressionList(node.arguments)); 713 visitExpressionList(node.arguments));
711 js.Expression argumentNames = new js.ArrayInitializer( 714 js.Expression argumentNames = new js.ArrayInitializer(
712 node.selector.namedArguments.map(js.string).toList(growable: false)); 715 node.selector.namedArguments.map(js.string).toList(growable: false));
713 return buildStaticHelperInvocation(glue.createInvocationMirrorMethod, 716 return buildStaticHelperInvocation(glue.createInvocationMirrorMethod,
714 <js.Expression>[name, internalName, kind, arguments, argumentNames]); 717 <js.Expression>[name, internalName, kind, arguments, argumentNames]);
715 } 718 }
716 719
717 @override 720 @override
718 js.Expression visitInterceptor(tree_ir.Interceptor node) { 721 js.Expression visitInterceptor(tree_ir.Interceptor node) {
719 glue.registerUseInterceptorInCodegen(); 722 registry.registerUseInterceptor();
720 registry.registerSpecializedGetInterceptor(node.interceptedClasses); 723 registry.registerSpecializedGetInterceptor(node.interceptedClasses);
721 js.Name helperName = glue.getInterceptorName(node.interceptedClasses); 724 js.Name helperName = glue.getInterceptorName(node.interceptedClasses);
722 js.Expression globalHolder = glue.getInterceptorLibrary(); 725 js.Expression globalHolder = glue.getInterceptorLibrary();
723 return js.js('#.#(#)', 726 return js.js('#.#(#)',
724 [globalHolder, helperName, visitExpression(node.input)]) 727 [globalHolder, helperName, visitExpression(node.input)])
725 .withSourceInformation(node.sourceInformation); 728 .withSourceInformation(node.sourceInformation);
726 } 729 }
727 730
728 @override 731 @override
729 js.Expression visitGetField(tree_ir.GetField node) { 732 js.Expression visitGetField(tree_ir.GetField node) {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 void registerDefaultParameterValues(ExecutableElement element) { 1048 void registerDefaultParameterValues(ExecutableElement element) {
1046 if (element is! FunctionElement) return; 1049 if (element is! FunctionElement) return;
1047 FunctionElement function = element; 1050 FunctionElement function = element;
1048 if (function.isStatic) return; // Defaults are inlined at call sites. 1051 if (function.isStatic) return; // Defaults are inlined at call sites.
1049 function.functionSignature.forEachOptionalParameter((param) { 1052 function.functionSignature.forEachOptionalParameter((param) {
1050 ConstantValue constant = glue.getDefaultParameterValue(param); 1053 ConstantValue constant = glue.getDefaultParameterValue(param);
1051 registry.registerCompileTimeConstant(constant); 1054 registry.registerCompileTimeConstant(constant);
1052 }); 1055 });
1053 } 1056 }
1054 } 1057 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend_impact.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698