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

Unified Diff: pkg/kernel/lib/ast.dart

Issue 2767773004: Add Vector type to Kernel (Closed)
Patch Set: Add a note to return Run step in Closure Conversion test suite Created 3 years, 9 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 | « no previous file | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | pkg/kernel/lib/text/ast_to_text.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 9d6d5cdd073424bf9d2999e6e6673af3d96dd8bc..121e179cb82c2dfc3de5b584bd489a88783c361d 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -2750,6 +2750,116 @@ class CheckLibraryIsLoaded extends Expression {
transformChildren(Transformer v) {}
}
+/// Expression of the form `MakeVector(N)` where `N` is an integer literal.
+class VectorCreation extends Expression {
+ final IntLiteral length;
asgerf 2017/03/22 14:33:22 The kernel AST is mutable, only List fields should
Dmitry Stefantsov 2017/03/23 11:22:43 Thanks! Done.
+
+ VectorCreation(this.length) {
+ length?.parent = this;
+ }
+
+ accept(ExpressionVisitor v) => v.visitVectorCreation(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitVectorCreation(this, arg);
+
+ visitChildren(Visitor v) {
+ length.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ length.accept(v);
asgerf 2017/03/22 14:33:22 transformChildren should replace the children, not
Dmitry Stefantsov 2017/03/23 11:22:43 Of course. Thanks! Fixed.
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return new VectorType();
+ }
+}
+
+/// Expression of the form `v[i]` where `v` is a vector expression, and `i` is
+/// an integer literal used as an index.
+class VectorGet extends Expression {
+ final Expression vectorExpression;
+ final IntLiteral index;
+
+ VectorGet(this.vectorExpression, this.index) {
+ vectorExpression?.parent = this;
+ index?.parent = this;
+ }
+
+ accept(ExpressionVisitor v) => v.visitVectorGet(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitVectorGet(this, arg);
+
+ visitChildren(Visitor v) {
+ vectorExpression.accept(v);
+ index.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ vectorExpression.accept(v);
+ index.accept(v);
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return const DynamicType();
+ }
+}
+
+/// Expressoins of the form `v[i] = x` where `v` is a vector expression, `i` is
+/// an integer literal used as an index, and `x` is an arbitrary expression.
+class VectorSet extends Expression {
+ final Expression vectorExpression;
+ final IntLiteral index;
+ Expression value;
+
+ VectorSet(this.vectorExpression, this.index, this.value) {
+ vectorExpression?.parent = this;
+ index?.parent = this;
+ value?.parent = this;
+ }
+
+ accept(ExpressionVisitor v) => v.visitVectorSet(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitVectorSet(this, arg);
+
+ visitChildren(Visitor v) {
+ vectorExpression.accept(v);
+ index.accept(v);
+ value.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ vectorExpression.accept(v);
+ index.accept(v);
+ value.accept(v);
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return value.getStaticType(types);
+ }
+}
+
+/// Expression of the form `CopyVector(v)` where `v` is a vector expressoin.
+class VectorCopy extends Expression {
+ final Expression vectorExpression;
+
+ VectorCopy(this.vectorExpression) {
+ vectorExpression?.parent = this;
+ }
+
+ accept(ExpressionVisitor v) => v.visitVectorCopy(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitVectorCopy(this, arg);
+
+ visitChildren(Visitor v) {
+ vectorExpression.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ vectorExpression.accept(v);
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return new VectorType();
+ }
+}
+
// ------------------------------------------------------------------------
// STATEMENTS
// ------------------------------------------------------------------------
@@ -3652,6 +3762,13 @@ class InterfaceType extends DartType {
}
}
+class VectorType extends DartType {
+ const VectorType();
+
+ accept(DartTypeVisitor v) => v.visitVectorType(this);
+ visitChildren(Visitor v) {}
+}
+
/// A possibly generic function type.
class FunctionType extends DartType {
final List<TypeParameter> typeParameters;
« no previous file with comments | « no previous file | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | pkg/kernel/lib/text/ast_to_text.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698