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

Unified Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2411793007: Revert "Build CFG for various JS() foreign methods" (Closed)
Patch Set: Redo "Build CFG for various JS() foreign methods" Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
diff --git a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
index 0b54193ad356ab74e563f6de983d88c93ca8e20f..ab23be0bc4cd3db63a0107681f5e41ccd86217ab 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:js_runtime/shared/embedded_names.dart';
import 'package:kernel/ast.dart' as ir;
import '../common.dart';
@@ -10,8 +11,10 @@ import '../compiler.dart';
import '../constants/values.dart';
import '../dart_types.dart';
import '../elements/elements.dart';
+import '../js/js.dart' as js;
import '../js_backend/js_backend.dart';
import '../kernel/kernel.dart';
+import '../native/native.dart' as native;
import '../resolution/tree_elements.dart';
import '../tree/tree.dart' as ast;
import '../types/masks.dart';
@@ -220,6 +223,10 @@ class KernelAstAdapter {
return TypeMaskFactory.inferredTypeForSelector(selector, mask, _compiler);
}
+ TypeMask typeFromNativeBehavior(native.NativeBehavior nativeBehavior) {
+ return TypeMaskFactory.fromNativeBehavior(nativeBehavior, _compiler);
+ }
+
ConstantValue getConstantFor(ir.Node node) {
ConstantValue constantValue =
_backend.constants.getConstantValueForNode(getNode(node), elements);
@@ -272,6 +279,45 @@ class KernelAstAdapter {
TypeMask get assertThrowReturnType => TypeMaskFactory
.inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler);
+ ir.Procedure get currentIsolate =>
+ kernel.functions[_backend.helpers.currentIsolate];
+
+ bool isInForeignLibrary(ir.Member member) =>
+ _backend.isForeign(getElement(member));
+
+ native.NativeBehavior getNativeBehavior(ir.Node node) {
+ return elements.getNativeData(getNode(node));
+ }
+
+ js.Name getNameForJsGetName(ir.Node argument, ConstantValue constant) {
+ int index = _extractEnumIndexFromConstantValue(
+ constant, _backend.helpers.jsGetNameEnum);
+ if (index == null) return null;
+ return _backend.namer
+ .getNameForJsGetName(getNode(argument), JsGetName.values[index]);
+ }
+
+ js.Template getJsBuiltinTemplate(ConstantValue constant) {
+ int index = _extractEnumIndexFromConstantValue(
+ constant, _backend.helpers.jsBuiltinEnum);
+ if (index == null) return null;
+ return _backend.emitter.builtinTemplateFor(JsBuiltin.values[index]);
+ }
+
+ int _extractEnumIndexFromConstantValue(
+ ConstantValue constant, Element classElement) {
+ if (constant is ConstructedConstantValue) {
+ if (constant.type.element == classElement) {
+ assert(constant.fields.length == 1);
+ ConstantValue indexConstant = constant.fields.values.single;
+ if (indexConstant is IntConstantValue) {
+ return indexConstant.primitiveValue;
+ }
+ }
+ }
+ return null;
+ }
+
DartType getDartType(ir.DartType type) {
return type.accept(_typeConverter);
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698