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

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

Issue 2466353002: Revert "More functionality in kernel_impact." and "Compute NativeBehavior for foreign functions." (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/serialization/system.dart ('k') | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('j') | 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 bb002dd22fe4f2c03c728dfa14a58ff75896f68b..0b54193ad356ab74e563f6de983d88c93ca8e20f 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -10,11 +10,8 @@ import '../compiler.dart';
import '../constants/values.dart';
import '../dart_types.dart';
import '../elements/elements.dart';
-import '../js_backend/backend_helpers.dart';
import '../js_backend/js_backend.dart';
import '../kernel/kernel.dart';
-import '../kernel/kernel_debug.dart';
-import '../native/native.dart' show NativeBehavior;
import '../resolution/tree_elements.dart';
import '../tree/tree.dart' as ast;
import '../types/masks.dart';
@@ -64,7 +61,6 @@ class KernelAstAdapter {
TreeElements get elements => _resolvedAst.elements;
GlobalTypeInferenceResults get _inferenceResults =>
_compiler.globalInference.results;
- DiagnosticReporter get reporter => _compiler.reporter;
ConstantValue getConstantForSymbol(ir.SymbolLiteral node) {
ast.Node astNode = getNode(node);
@@ -77,8 +73,7 @@ class KernelAstAdapter {
Element getElement(ir.Node node) {
Element result = _nodeToElement[node];
- assert(invariant(CURRENT_ELEMENT_SPANNABLE, result != null,
- message: "No element found for $node."));
+ assert(result != null);
return result;
}
@@ -284,135 +279,6 @@ class KernelAstAdapter {
List<DartType> getDartTypes(List<ir.DartType> types) {
return types.map(getDartType).toList();
}
-
- @override
- ForeignKind getForeignKind(ir.StaticInvocation node) {
- if (isForeignLibrary(node.target.enclosingLibrary)) {
- switch (node.target.name.name) {
- case BackendHelpers.JS:
- return ForeignKind.JS;
- case BackendHelpers.JS_BUILTIN:
- return ForeignKind.JS_BUILTIN;
- case BackendHelpers.JS_EMBEDDED_GLOBAL:
- return ForeignKind.JS_EMBEDDED_GLOBAL;
- case BackendHelpers.JS_INTERCEPTOR_CONSTANT:
- return ForeignKind.JS_INTERCEPTOR_CONSTANT;
- }
- }
- return ForeignKind.NONE;
- }
-
- bool isForeignLibrary(ir.Library node) {
- return node.importUri == BackendHelpers.DART_FOREIGN_HELPER;
- }
-
- DartType _typeLookup(String typeName) {
- DartType findIn(Uri uri) {
- LibraryElement library = _compiler.libraryLoader.lookupLibrary(uri);
- if (library != null) {
- Element element = library.find(typeName);
- if (element != null && element.isClass) {
- ClassElement cls = element;
- return cls.rawType;
- }
- }
- return null;
- }
-
- DartType type = findIn(Uris.dart_core);
- type ??= findIn(BackendHelpers.DART_JS_HELPER);
- type ??= findIn(BackendHelpers.DART_INTERCEPTORS);
- type ??= findIn(BackendHelpers.DART_ISOLATE_HELPER);
- type ??= findIn(Uris.dart_collection);
- type ??= findIn(Uris.dart_html);
- return type;
- }
-
- String _getStringArgument(ir.StaticInvocation node, int index) {
- return node.arguments.positional[index].accept(new Stringifier());
- }
-
- NativeBehavior getNativeBehaviorForJsCall(ir.StaticInvocation node) {
- if (node.arguments.positional.length < 2 ||
- node.arguments.named.isNotEmpty) {
- reporter.reportErrorMessage(
- CURRENT_ELEMENT_SPANNABLE, MessageKind.WRONG_ARGUMENT_FOR_JS);
- return new NativeBehavior();
- }
- String specString = _getStringArgument(node, 0);
- if (specString == null) {
- reporter.reportErrorMessage(
- CURRENT_ELEMENT_SPANNABLE, MessageKind.WRONG_ARGUMENT_FOR_JS_FIRST);
- return new NativeBehavior();
- }
-
- String codeString = _getStringArgument(node, 1);
- if (codeString == null) {
- reporter.reportErrorMessage(
- CURRENT_ELEMENT_SPANNABLE, MessageKind.WRONG_ARGUMENT_FOR_JS_SECOND);
- return new NativeBehavior();
- }
-
- return NativeBehavior.ofJsCall(specString, codeString, _typeLookup,
- CURRENT_ELEMENT_SPANNABLE, reporter, _compiler.coreTypes);
- }
-
- NativeBehavior getNativeBehaviorForJsBuiltinCall(ir.StaticInvocation node) {
- if (node.arguments.positional.length < 1) {
- reporter.internalError(
- CURRENT_ELEMENT_SPANNABLE, "JS builtin expression has no type.");
- return new NativeBehavior();
- }
- if (node.arguments.positional.length < 2) {
- reporter.internalError(
- CURRENT_ELEMENT_SPANNABLE, "JS builtin is missing name.");
- return new NativeBehavior();
- }
- String specString = _getStringArgument(node, 0);
- if (specString == null) {
- reporter.internalError(
- CURRENT_ELEMENT_SPANNABLE, "Unexpected first argument.");
- return new NativeBehavior();
- }
- return NativeBehavior.ofJsBuiltinCall(specString, _typeLookup,
- CURRENT_ELEMENT_SPANNABLE, reporter, _compiler.coreTypes);
- }
-
- NativeBehavior getNativeBehaviorForJsEmbeddedGlobalCall(
- ir.StaticInvocation node) {
- if (node.arguments.positional.length < 1) {
- reporter.internalError(CURRENT_ELEMENT_SPANNABLE,
- "JS embedded global expression has no type.");
- return new NativeBehavior();
- }
- if (node.arguments.positional.length < 2) {
- reporter.internalError(
- CURRENT_ELEMENT_SPANNABLE, "JS embedded global is missing name.");
- return new NativeBehavior();
- }
- if (node.arguments.positional.length > 2 ||
- node.arguments.named.isNotEmpty) {
- reporter.internalError(CURRENT_ELEMENT_SPANNABLE,
- "JS embedded global has more than 2 arguments.");
- return new NativeBehavior();
- }
- String specString = _getStringArgument(node, 0);
- if (specString == null) {
- reporter.internalError(
- CURRENT_ELEMENT_SPANNABLE, "Unexpected first argument.");
- return new NativeBehavior();
- }
- return NativeBehavior.ofJsEmbeddedGlobalCall(specString, _typeLookup,
- CURRENT_ELEMENT_SPANNABLE, reporter, _compiler.coreTypes);
- }
-}
-
-enum ForeignKind {
- JS,
- JS_BUILTIN,
- JS_EMBEDDED_GLOBAL,
- JS_INTERCEPTOR_CONSTANT,
- NONE,
}
class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
@@ -429,19 +295,7 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
@override
DartType visitTypeParameterType(ir.TypeParameterType node) {
- if (node.parameter.parent is ir.Class) {
- ir.Class cls = node.parameter.parent;
- int index = cls.typeParameters.indexOf(node.parameter);
- ClassElement classElement = astAdapter.getElement(cls);
- return classElement.typeVariables[index];
- } else if (node.parameter.parent is ir.FunctionNode) {
- ir.FunctionNode func = node.parameter.parent;
- int index = func.typeParameters.indexOf(node.parameter);
- ConstructorElement constructorElement = astAdapter.getElement(func);
- ClassElement classElement = constructorElement.enclosingClass;
- return classElement.typeVariables[index];
- }
- throw new UnsupportedError('Unsupported type parameter type node $node.');
+ return new TypeVariableType(astAdapter.getElement(node.parameter));
}
@override
@@ -479,21 +333,3 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
throw new UnimplementedError("Invalid types not currently supported");
}
}
-
-/// Visitor that converts string literals and concatenations of string literals
-/// into the string value.
-class Stringifier extends ir.ExpressionVisitor<String> {
- @override
- String visitStringLiteral(ir.StringLiteral node) => node.value;
-
- @override
- String visitStringConcatenation(ir.StringConcatenation node) {
- StringBuffer sb = new StringBuffer();
- for (ir.Expression expression in node.expressions) {
- String value = expression.accept(this);
- if (value == null) return null;
- sb.write(value);
- }
- return sb.toString();
- }
-}
« no previous file with comments | « pkg/compiler/lib/src/serialization/system.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