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

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

Issue 2767773004: Add Vector type to Kernel (Closed)
Patch Set: Make fixes suggested by the reviewers 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/binary/tag.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..ddab8f0ea57808489aebd6eb5d2cb22a6f03b601 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.
asgerf 2017/03/23 11:53:50 `N` is no longer an integer literal. It would be m
Kevin Millikin (Google) 2017/03/23 12:01:03 'integer literal' ==> 'integer'.
Dmitry Stefantsov 2017/03/27 10:57:08 Done.
Dmitry Stefantsov 2017/03/27 10:57:08 Yes. It makes sense. I put the detailed comment ne
+class VectorCreation extends Expression {
+ int length;
+
+ VectorCreation(this.length);
+
+ accept(ExpressionVisitor v) => v.visitVectorCreation(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitVectorCreation(this, arg);
+
+ visitChildren(Visitor v) {}
+
+ transformChildren(Transformer v) {}
+
+ DartType getStaticType(TypeEnvironment types) {
+ return const VectorType();
+ }
+}
+
+/// Expression of the form `v[i]` where `v` is a vector expression, and `i` is
+/// an integer literal used as an index.
Kevin Millikin (Google) 2017/03/23 12:01:03 'integer literal' ==> 'integer'.
Dmitry Stefantsov 2017/03/27 10:57:08 Done.
+class VectorGet extends Expression {
+ Expression vectorExpression;
+ int index;
+
+ VectorGet(this.vectorExpression, this.index) {
+ vectorExpression?.parent = this;
+ }
+
+ accept(ExpressionVisitor v) => v.visitVectorGet(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitVectorGet(this, arg);
+
+ visitChildren(Visitor v) {
+ vectorExpression.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ if (vectorExpression != null) {
+ vectorExpression = vectorExpression.accept(v);
+ vectorExpression?.parent = this;
+ }
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return const DynamicType();
+ }
+}
+
+/// Expressoins of the form `v[i] = x` where `v` is a vector expression, `i` is
asgerf 2017/03/23 11:53:50 Expressoins -> Expression
Kevin Millikin (Google) 2017/03/23 12:01:03 'Expressoins' ==> 'Expressions'. 'integer literal'
Dmitry Stefantsov 2017/03/27 10:57:08 Done.
Dmitry Stefantsov 2017/03/27 10:57:08 Done.
+/// an integer literal used as an index, and `x` is an arbitrary expression.
+class VectorSet extends Expression {
+ Expression vectorExpression;
+ int index;
+ Expression value;
+
+ VectorSet(this.vectorExpression, this.index, this.value) {
+ vectorExpression?.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);
+ value.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ if (vectorExpression != null) {
+ vectorExpression = vectorExpression.accept(v);
+ vectorExpression?.parent = this;
+ }
+ if (value != null) {
+ value = value.accept(v);
+ value?.parent = this;
+ }
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return value.getStaticType(types);
+ }
+}
+
+/// Expression of the form `CopyVector(v)` where `v` is a vector expressoin.
asgerf 2017/03/23 11:53:50 expressoin -> expression
Kevin Millikin (Google) 2017/03/23 12:01:03 'expressoin' ==> 'expression'.
Dmitry Stefantsov 2017/03/27 10:57:08 Done.
Dmitry Stefantsov 2017/03/27 10:57:08 Done.
+class VectorCopy extends Expression {
+ 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) {
+ if (vectorExpression != null) {
+ vectorExpression = vectorExpression.accept(v);
+ vectorExpression?.parent = this;
+ }
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return const VectorType();
+ }
+}
+
// ------------------------------------------------------------------------
// STATEMENTS
// ------------------------------------------------------------------------
@@ -3652,6 +3762,13 @@ class InterfaceType extends DartType {
}
}
+class VectorType extends DartType {
asgerf 2017/03/23 11:53:50 Please check all existing DartTypeVisitors and ove
Dmitry Stefantsov 2017/03/27 10:57:08 Thanks! Done.
+ 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/binary/tag.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698