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

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

Issue 2686533002: Refactor computation of NativeBehavior. (Closed)
Patch Set: Rebased Created 3 years, 10 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
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 '../common.dart'; 8 import '../common.dart';
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 @override 581 @override
582 InterfaceType getRawType(ClassElement cls) { 582 InterfaceType getRawType(ClassElement cls) {
583 return cls.rawType; 583 return cls.rawType;
584 } 584 }
585 585
586 @override 586 @override
587 InterfaceType getThisType(ClassElement cls) { 587 InterfaceType getThisType(ClassElement cls) {
588 return cls.thisType; 588 return cls.thisType;
589 } 589 }
590 590
591 native.BehaviorComputer get nativeBehaviorComputer =>
592 new native.BehaviorComputerImpl(_compiler);
593
591 /// Computes the native behavior for reading the native [field]. 594 /// Computes the native behavior for reading the native [field].
592 // TODO(johnniwinther): Cache this for later use. 595 // TODO(johnniwinther): Cache this for later use.
593 native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field) { 596 native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field) {
594 ResolutionDartType type = getDartType(field.type); 597 ResolutionDartType type = getDartType(field.type);
595 List<ConstantExpression> metadata = getMetadata(field.annotations); 598 List<ConstantExpression> metadata = getMetadata(field.annotations);
596 return native.NativeBehavior.ofFieldLoad(CURRENT_ELEMENT_SPANNABLE, type, 599 // TODO(johnniwinther): Provide the correct value for [isJsInterop].
Siggi Cherem (dart-lang) 2017/02/08 17:00:28 was this working before? (are there tests that wil
Johnni Winther 2017/02/10 09:11:45 Same behavior as before (probably not working).
597 metadata, typeLookup(resolveAsRaw: false), _compiler, 600 return nativeBehaviorComputer.ofFieldLoad(
601 type, metadata, typeLookup(resolveAsRaw: false),
598 isJsInterop: false); 602 isJsInterop: false);
599 } 603 }
600 604
601 /// Computes the native behavior for writing to the native [field]. 605 /// Computes the native behavior for writing to the native [field].
602 // TODO(johnniwinther): Cache this for later use. 606 // TODO(johnniwinther): Cache this for later use.
603 native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field) { 607 native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field) {
604 ResolutionDartType type = getDartType(field.type); 608 DartType type = getDartType(field.type);
605 return native.NativeBehavior.ofFieldStore(type, _compiler.resolution); 609 return nativeBehaviorComputer.ofFieldStore(type);
606 } 610 }
607 611
608 /// Computes the native behavior for calling [procedure]. 612 /// Computes the native behavior for calling [procedure].
609 // TODO(johnniwinther): Cache this for later use. 613 // TODO(johnniwinther): Cache this for later use.
610 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure) { 614 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure) {
611 ResolutionDartType type = getFunctionType(procedure.function); 615 DartType type = getFunctionType(procedure.function);
612 List<ConstantExpression> metadata = getMetadata(procedure.annotations); 616 List<ConstantExpression> metadata = getMetadata(procedure.annotations);
613 return native.NativeBehavior.ofMethod(CURRENT_ELEMENT_SPANNABLE, type, 617 // TODO(johnniwinther): Provide the correct value for [isJsInterop].
614 metadata, typeLookup(resolveAsRaw: false), _compiler, 618 return nativeBehaviorComputer.ofMethod(
619 type, metadata, typeLookup(resolveAsRaw: false),
615 isJsInterop: false); 620 isJsInterop: false);
616 } 621 }
617 622
618 MemberEntity getConstructorBodyEntity(ir.Constructor constructor) { 623 MemberEntity getConstructorBodyEntity(ir.Constructor constructor) {
619 AstElement element = getElement(constructor); 624 AstElement element = getElement(constructor);
620 MemberEntity constructorBody = 625 MemberEntity constructorBody =
621 ConstructorBodyElementX.createFromResolvedAst(element.resolvedAst); 626 ConstructorBodyElementX.createFromResolvedAst(element.resolvedAst);
622 assert(constructorBody != null); 627 assert(constructorBody != null);
623 return constructorBody; 628 return constructorBody;
624 } 629 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 JumpTarget continueTarget = 826 JumpTarget continueTarget =
822 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); 827 astAdapter.getJumpTarget(switchCase, isContinueTarget: true);
823 assert(continueTarget is KernelJumpTarget); 828 assert(continueTarget is KernelJumpTarget);
824 targetIndexMap[continueTarget] = switchIndex; 829 targetIndexMap[continueTarget] = switchIndex;
825 assert(builder.jumpTargets[continueTarget] == null); 830 assert(builder.jumpTargets[continueTarget] == null);
826 builder.jumpTargets[continueTarget] = this; 831 builder.jumpTargets[continueTarget] = this;
827 switchIndex++; 832 switchIndex++;
828 } 833 }
829 } 834 }
830 } 835 }
OLDNEW
« pkg/compiler/lib/src/native/behavior.dart ('K') | « pkg/compiler/lib/src/native/enqueue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698