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

Unified Diff: pkg/compiler/lib/src/elements/types.dart

Issue 2598983002: Introduce DartType super hierarchy based on Entity (Closed)
Patch Set: Updated cf. comments. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/elements/types.dart
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0e9795738eb6d314d4e204a7ffa44d952abc2f56
--- /dev/null
+++ b/pkg/compiler/lib/src/elements/types.dart
@@ -0,0 +1,87 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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 'entities.dart';
+
+/// Hierarchy to describe types in Dart.
+///
+/// This hierarchy is a super hierarchy of the use-case specific hierarchies
+/// used in different parts of the compiler. This hierarchy abstracts details
+/// not generally needed or required for the Dart type hierarchy. For instance,
+/// the hierarchy in 'resolution_types.dart' has properties supporting lazy
+/// computation (like computeAlias) and distinctions between 'Foo' and
+/// 'Foo<dynamic>', features that are not needed for code generation and not
+/// supported from kernel.
+///
+/// Current only 'resolution_types.dart' implement this hierarchy but when the
+/// compiler moves to use [Entity] instead of [Element] this hierarchy can be
+/// implementated directly but other entity systems, for instance based directly
+/// on kernel ir without the need for [Element].
+
+abstract class DartType {
+ /// Returns the unaliased type of this type.
+ ///
+ /// The unaliased type of a typedef'd type is the unaliased type to which its
+ /// name is bound. The unaliased version of any other type is the type itself.
+ ///
+ /// For example, the unaliased type of `typedef A Func<A,B>(B b)` is the
+ /// function type `(B) -> A` and the unaliased type of `Func<int,String>`
+ /// is the function type `(String) -> int`.
+ DartType get unaliased;
+
+ /// Is `true` if this type has no non-dynamic type arguments.
+ bool get treatAsRaw;
+
+ /// Is `true` if this type should be treated as the dynamic type.
+ bool get treatAsDynamic;
+
+ /// Is `true` if this type is the dynamic type.
+ bool get isDynamic;
+
+ /// Is `true` if this type is the void type.
+ bool get isVoid;
+
+ /// Is `true` if this is the type of `Object` from dart:core.
+ bool get isObject;
+
+ /// Is `true` if this type is an interface type.
+ bool get isInterfaceType;
+
+ /// Is `true` if this type is a typedef.
+ bool get isTypedef;
+
+ /// Is `true` if this type is a function type.
+ bool get isFunctionType;
+
+ /// Is `true` if this type is a type variable.
+ bool get isTypeVariable;
+
+ /// Is `true` if this type is a malformed type.
+ bool get isMalformed;
+}
+
+abstract class InterfaceType extends DartType {
+ ClassEntity get element;
+}
+
+abstract class TypeVariableType extends DartType {
+ TypeVariableEntity get element;
+}
+
+abstract class VoidType extends DartType {}
+
+abstract class DynamicType extends DartType {}
+
+abstract class FunctionType extends DartType {
+ DartType get returnType;
+ List<DartType> get parameterTypes;
+ List<DartType> get optionalParameterTypes;
+
+ /// The names of the named parameters ordered lexicographically.
+ List<String> get namedParameters;
+
+ /// The types of the named parameters in the order corresponding to the
+ /// [namedParameters].
+ List<DartType> get namedParameterTypes;
+}
« no previous file with comments | « pkg/compiler/lib/src/elements/entities.dart ('k') | pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698