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

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2595493002: Merge CoreTypes and CoreClasses into CommonElements. (Closed)
Patch Set: Updated cf. comment Created 3 years, 12 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 | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('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 import 'package:js_runtime/shared/embedded_names.dart'; 5 import 'package:js_runtime/shared/embedded_names.dart';
6 import 'package:kernel/ast.dart' as ir; 6 import 'package:kernel/ast.dart' as ir;
7 7
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 ir.Procedure get runtimeTypeToString => 416 ir.Procedure get runtimeTypeToString =>
417 kernel.functions[_backend.helpers.runtimeTypeToString]; 417 kernel.functions[_backend.helpers.runtimeTypeToString];
418 418
419 ir.Procedure get createRuntimeType => 419 ir.Procedure get createRuntimeType =>
420 kernel.functions[_backend.helpers.createRuntimeType]; 420 kernel.functions[_backend.helpers.createRuntimeType];
421 421
422 TypeMask get createRuntimeTypeReturnType => 422 TypeMask get createRuntimeTypeReturnType =>
423 TypeMaskFactory.inferredReturnTypeForElement( 423 TypeMaskFactory.inferredReturnTypeForElement(
424 _backend.helpers.createRuntimeType, _globalInferenceResults); 424 _backend.helpers.createRuntimeType, _globalInferenceResults);
425 425
426 ir.Class get objectClass => kernel.classes[_compiler.coreClasses.objectClass]; 426 ir.Class get objectClass =>
427 kernel.classes[_compiler.commonElements.objectClass];
427 428
428 ir.Procedure get currentIsolate => 429 ir.Procedure get currentIsolate =>
429 kernel.functions[_backend.helpers.currentIsolate]; 430 kernel.functions[_backend.helpers.currentIsolate];
430 431
431 ir.Procedure get callInIsolate => 432 ir.Procedure get callInIsolate =>
432 kernel.functions[_backend.helpers.callInIsolate]; 433 kernel.functions[_backend.helpers.callInIsolate];
433 434
434 bool isInForeignLibrary(ir.Member member) => 435 bool isInForeignLibrary(ir.Member member) =>
435 _backend.isForeign(getElement(member)); 436 _backend.isForeign(getElement(member));
436 437
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 473 }
473 474
474 List<DartType> getDartTypes(List<ir.DartType> types) { 475 List<DartType> getDartTypes(List<ir.DartType> types) {
475 return types.map(getDartType).toList(); 476 return types.map(getDartType).toList();
476 } 477 }
477 478
478 DartType getDartTypeOfListLiteral(ir.ListLiteral list) { 479 DartType getDartTypeOfListLiteral(ir.ListLiteral list) {
479 ast.Node node = getNodeOrNull(list); 480 ast.Node node = getNodeOrNull(list);
480 if (node != null) return elements.getType(node); 481 if (node != null) return elements.getType(node);
481 assertNodeIsSynthetic(list); 482 assertNodeIsSynthetic(list);
482 return _compiler.coreTypes.listType(getDartType(list.typeArgument)); 483 return _compiler.commonElements.listType(getDartType(list.typeArgument));
483 } 484 }
484 485
485 DartType getDartTypeOfMapLiteral(ir.MapLiteral literal) { 486 DartType getDartTypeOfMapLiteral(ir.MapLiteral literal) {
486 ast.Node node = getNodeOrNull(literal); 487 ast.Node node = getNodeOrNull(literal);
487 if (node != null) return elements.getType(node); 488 if (node != null) return elements.getType(node);
488 assertNodeIsSynthetic(literal); 489 assertNodeIsSynthetic(literal);
489 return _compiler.coreTypes 490 return _compiler.commonElements
490 .mapType(getDartType(literal.keyType), getDartType(literal.valueType)); 491 .mapType(getDartType(literal.keyType), getDartType(literal.valueType));
491 } 492 }
492 493
493 DartType getFunctionReturnType(ir.FunctionNode node) { 494 DartType getFunctionReturnType(ir.FunctionNode node) {
494 return getDartType(node.returnType); 495 return getDartType(node.returnType);
495 } 496 }
496 497
497 /// Computes the function type corresponding the signature of [node]. 498 /// Computes the function type corresponding the signature of [node].
498 FunctionType getFunctionType(ir.FunctionNode node) { 499 FunctionType getFunctionType(ir.FunctionNode node) {
499 DartType returnType = getFunctionReturnType(node); 500 DartType returnType = getFunctionReturnType(node);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 CURRENT_ELEMENT_SPANNABLE, MessageKind.WRONG_ARGUMENT_FOR_JS_SECOND); 613 CURRENT_ELEMENT_SPANNABLE, MessageKind.WRONG_ARGUMENT_FOR_JS_SECOND);
613 return new native.NativeBehavior(); 614 return new native.NativeBehavior();
614 } 615 }
615 616
616 return native.NativeBehavior.ofJsCall( 617 return native.NativeBehavior.ofJsCall(
617 specString, 618 specString,
618 codeString, 619 codeString,
619 _typeLookup(resolveAsRaw: true), 620 _typeLookup(resolveAsRaw: true),
620 CURRENT_ELEMENT_SPANNABLE, 621 CURRENT_ELEMENT_SPANNABLE,
621 reporter, 622 reporter,
622 _compiler.coreTypes); 623 _compiler.commonElements);
623 } 624 }
624 625
625 /// Computes the [native.NativeBehavior] for a call to the [JS_BUILTIN] functi on. 626 /// Computes the [native.NativeBehavior] for a call to the [JS_BUILTIN] functi on.
626 // TODO(johnniwinther): Cache this for later use. 627 // TODO(johnniwinther): Cache this for later use.
627 native.NativeBehavior getNativeBehaviorForJsBuiltinCall( 628 native.NativeBehavior getNativeBehaviorForJsBuiltinCall(
628 ir.StaticInvocation node) { 629 ir.StaticInvocation node) {
629 if (node.arguments.positional.length < 1) { 630 if (node.arguments.positional.length < 1) {
630 reporter.internalError( 631 reporter.internalError(
631 CURRENT_ELEMENT_SPANNABLE, "JS builtin expression has no type."); 632 CURRENT_ELEMENT_SPANNABLE, "JS builtin expression has no type.");
632 return new native.NativeBehavior(); 633 return new native.NativeBehavior();
633 } 634 }
634 if (node.arguments.positional.length < 2) { 635 if (node.arguments.positional.length < 2) {
635 reporter.internalError( 636 reporter.internalError(
636 CURRENT_ELEMENT_SPANNABLE, "JS builtin is missing name."); 637 CURRENT_ELEMENT_SPANNABLE, "JS builtin is missing name.");
637 return new native.NativeBehavior(); 638 return new native.NativeBehavior();
638 } 639 }
639 String specString = _getStringArgument(node, 0); 640 String specString = _getStringArgument(node, 0);
640 if (specString == null) { 641 if (specString == null) {
641 reporter.internalError( 642 reporter.internalError(
642 CURRENT_ELEMENT_SPANNABLE, "Unexpected first argument."); 643 CURRENT_ELEMENT_SPANNABLE, "Unexpected first argument.");
643 return new native.NativeBehavior(); 644 return new native.NativeBehavior();
644 } 645 }
645 return native.NativeBehavior.ofJsBuiltinCall( 646 return native.NativeBehavior.ofJsBuiltinCall(
646 specString, 647 specString,
647 _typeLookup(resolveAsRaw: true), 648 _typeLookup(resolveAsRaw: true),
648 CURRENT_ELEMENT_SPANNABLE, 649 CURRENT_ELEMENT_SPANNABLE,
649 reporter, 650 reporter,
650 _compiler.coreTypes); 651 _compiler.commonElements);
651 } 652 }
652 653
653 /// Computes the [native.NativeBehavior] for a call to the [JS_EMBEDDED_GLOBAL ] 654 /// Computes the [native.NativeBehavior] for a call to the [JS_EMBEDDED_GLOBAL ]
654 /// function. 655 /// function.
655 // TODO(johnniwinther): Cache this for later use. 656 // TODO(johnniwinther): Cache this for later use.
656 native.NativeBehavior getNativeBehaviorForJsEmbeddedGlobalCall( 657 native.NativeBehavior getNativeBehaviorForJsEmbeddedGlobalCall(
657 ir.StaticInvocation node) { 658 ir.StaticInvocation node) {
658 if (node.arguments.positional.length < 1) { 659 if (node.arguments.positional.length < 1) {
659 reporter.internalError(CURRENT_ELEMENT_SPANNABLE, 660 reporter.internalError(CURRENT_ELEMENT_SPANNABLE,
660 "JS embedded global expression has no type."); 661 "JS embedded global expression has no type.");
(...skipping 14 matching lines...) Expand all
675 if (specString == null) { 676 if (specString == null) {
676 reporter.internalError( 677 reporter.internalError(
677 CURRENT_ELEMENT_SPANNABLE, "Unexpected first argument."); 678 CURRENT_ELEMENT_SPANNABLE, "Unexpected first argument.");
678 return new native.NativeBehavior(); 679 return new native.NativeBehavior();
679 } 680 }
680 return native.NativeBehavior.ofJsEmbeddedGlobalCall( 681 return native.NativeBehavior.ofJsEmbeddedGlobalCall(
681 specString, 682 specString,
682 _typeLookup(resolveAsRaw: true), 683 _typeLookup(resolveAsRaw: true),
683 CURRENT_ELEMENT_SPANNABLE, 684 CURRENT_ELEMENT_SPANNABLE,
684 reporter, 685 reporter,
685 _compiler.coreTypes); 686 _compiler.commonElements);
686 } 687 }
687 688
688 /// Returns `true` is [node] has a `@Native(...)` annotation. 689 /// Returns `true` is [node] has a `@Native(...)` annotation.
689 // TODO(johnniwinther): Cache this for later use. 690 // TODO(johnniwinther): Cache this for later use.
690 bool isNative(ir.Class node) { 691 bool isNative(ir.Class node) {
691 for (ir.Expression annotation in node.annotations) { 692 for (ir.Expression annotation in node.annotations) {
692 if (annotation is ir.ConstructorInvocation) { 693 if (annotation is ir.ConstructorInvocation) {
693 ConstructorElement target = getElement(annotation.target).declaration; 694 ConstructorElement target = getElement(annotation.target).declaration;
694 if (target.enclosingClass == 695 if (target.enclosingClass ==
695 _compiler.commonElements.nativeAnnotationClass) { 696 _compiler.commonElements.nativeAnnotationClass) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 astAdapter.reporter.internalError( 873 astAdapter.reporter.internalError(
873 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); 874 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element.");
874 return null; 875 return null;
875 } 876 }
876 877
877 @override 878 @override
878 ConstantExpression visitStringLiteral(ir.StringLiteral node) { 879 ConstantExpression visitStringLiteral(ir.StringLiteral node) {
879 return new StringConstantExpression(node.value); 880 return new StringConstantExpression(node.value);
880 } 881 }
881 } 882 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698