| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart'; | 8 import '../common/names.dart'; |
| 9 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 /// Returns the [Name] corresponding to [name]. | 76 /// Returns the [Name] corresponding to [name]. |
| 77 Name getName(ir.Name name); | 77 Name getName(ir.Name name); |
| 78 | 78 |
| 79 /// Returns `true` is [node] has a `@Native(...)` annotation. | 79 /// Returns `true` is [node] has a `@Native(...)` annotation. |
| 80 bool isNativeClass(ir.Class node); | 80 bool isNativeClass(ir.Class node); |
| 81 | 81 |
| 82 /// Return `true` if [node] is the `dart:_foreign_helper` library. | 82 /// Return `true` if [node] is the `dart:_foreign_helper` library. |
| 83 bool isForeignLibrary(ir.Library node); | 83 bool isForeignLibrary(ir.Library node); |
| 84 | 84 |
| 85 /// Computes the native behavior for reading the native [field]. | 85 /// Computes the native behavior for reading the native [field]. |
| 86 native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field); | 86 native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field, |
| 87 {bool isJsInterop}); |
| 87 | 88 |
| 88 /// Computes the native behavior for writing to the native [field]. | 89 /// Computes the native behavior for writing to the native [field]. |
| 89 native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field); | 90 native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field); |
| 90 | 91 |
| 91 /// Computes the native behavior for calling [procedure]. | 92 /// Computes the native behavior for calling [procedure]. |
| 92 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure); | 93 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure, |
| 94 {bool isJsInterop}); |
| 93 | 95 |
| 94 /// Computes the [native.NativeBehavior] for a call to the [JS] function. | 96 /// Computes the [native.NativeBehavior] for a call to the [JS] function. |
| 95 native.NativeBehavior getNativeBehaviorForJsCall(ir.StaticInvocation node); | 97 native.NativeBehavior getNativeBehaviorForJsCall(ir.StaticInvocation node); |
| 96 | 98 |
| 97 /// Computes the [native.NativeBehavior] for a call to the [JS_BUILTIN] | 99 /// Computes the [native.NativeBehavior] for a call to the [JS_BUILTIN] |
| 98 /// function. | 100 /// function. |
| 99 native.NativeBehavior getNativeBehaviorForJsBuiltinCall( | 101 native.NativeBehavior getNativeBehaviorForJsBuiltinCall( |
| 100 ir.StaticInvocation node); | 102 ir.StaticInvocation node); |
| 101 | 103 |
| 102 /// Computes the [native.NativeBehavior] for a call to the | 104 /// Computes the [native.NativeBehavior] for a call to the |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 412 } |
| 411 ir.Node argument = node.arguments.positional.first; | 413 ir.Node argument = node.arguments.positional.first; |
| 412 if (argument is ir.TypeLiteral && argument.type is ir.InterfaceType) { | 414 if (argument is ir.TypeLiteral && argument.type is ir.InterfaceType) { |
| 413 return getInterfaceType(argument.type); | 415 return getInterfaceType(argument.type); |
| 414 } | 416 } |
| 415 return null; | 417 return null; |
| 416 } | 418 } |
| 417 | 419 |
| 418 /// Computes the native behavior for reading the native [field]. | 420 /// Computes the native behavior for reading the native [field]. |
| 419 // TODO(johnniwinther): Cache this for later use. | 421 // TODO(johnniwinther): Cache this for later use. |
| 420 native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field) { | 422 native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field, |
| 423 {bool isJsInterop}) { |
| 421 DartType type = getDartType(field.type); | 424 DartType type = getDartType(field.type); |
| 422 List<ConstantValue> metadata = getMetadata(field.annotations); | 425 List<ConstantValue> metadata = getMetadata(field.annotations); |
| 423 // TODO(johnniwinther): Provide the correct value for [isJsInterop]. | |
| 424 return nativeBehaviorBuilder.buildFieldLoadBehavior( | 426 return nativeBehaviorBuilder.buildFieldLoadBehavior( |
| 425 type, metadata, typeLookup(resolveAsRaw: false), | 427 type, metadata, typeLookup(resolveAsRaw: false), |
| 426 isJsInterop: false); | 428 isJsInterop: isJsInterop); |
| 427 } | 429 } |
| 428 | 430 |
| 429 /// Computes the native behavior for writing to the native [field]. | 431 /// Computes the native behavior for writing to the native [field]. |
| 430 // TODO(johnniwinther): Cache this for later use. | 432 // TODO(johnniwinther): Cache this for later use. |
| 431 native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field) { | 433 native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field) { |
| 432 DartType type = getDartType(field.type); | 434 DartType type = getDartType(field.type); |
| 433 return nativeBehaviorBuilder.buildFieldStoreBehavior(type); | 435 return nativeBehaviorBuilder.buildFieldStoreBehavior(type); |
| 434 } | 436 } |
| 435 | 437 |
| 436 /// Computes the native behavior for calling [procedure]. | 438 /// Computes the native behavior for calling [procedure]. |
| 437 // TODO(johnniwinther): Cache this for later use. | 439 // TODO(johnniwinther): Cache this for later use. |
| 438 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure) { | 440 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure, |
| 441 {bool isJsInterop}) { |
| 439 DartType type = getFunctionType(procedure.function); | 442 DartType type = getFunctionType(procedure.function); |
| 440 List<ConstantValue> metadata = getMetadata(procedure.annotations); | 443 List<ConstantValue> metadata = getMetadata(procedure.annotations); |
| 441 // TODO(johnniwinther): Provide the correct value for [isJsInterop]. | |
| 442 return nativeBehaviorBuilder.buildMethodBehavior( | 444 return nativeBehaviorBuilder.buildMethodBehavior( |
| 443 type, metadata, typeLookup(resolveAsRaw: false), | 445 type, metadata, typeLookup(resolveAsRaw: false), |
| 444 isJsInterop: false); | 446 isJsInterop: isJsInterop); |
| 445 } | 447 } |
| 446 } | 448 } |
| 447 | 449 |
| 448 /// Visitor that converts string literals and concatenations of string literals | 450 /// Visitor that converts string literals and concatenations of string literals |
| 449 /// into the string value. | 451 /// into the string value. |
| 450 class Stringifier extends ir.ExpressionVisitor<String> { | 452 class Stringifier extends ir.ExpressionVisitor<String> { |
| 451 @override | 453 @override |
| 452 String visitStringLiteral(ir.StringLiteral node) => node.value; | 454 String visitStringLiteral(ir.StringLiteral node) => node.value; |
| 453 | 455 |
| 454 @override | 456 @override |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 814 } |
| 813 if (isRedirecting) { | 815 if (isRedirecting) { |
| 814 return new RedirectingGenerativeConstantConstructor( | 816 return new RedirectingGenerativeConstantConstructor( |
| 815 defaultValues, superConstructorInvocation); | 817 defaultValues, superConstructorInvocation); |
| 816 } else { | 818 } else { |
| 817 return new GenerativeConstantConstructor( | 819 return new GenerativeConstantConstructor( |
| 818 type, defaultValues, fieldMap, superConstructorInvocation); | 820 type, defaultValues, fieldMap, superConstructorInvocation); |
| 819 } | 821 } |
| 820 } | 822 } |
| 821 } | 823 } |
| OLD | NEW |