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

Side by Side Diff: pkg/kernel/lib/transformations/closure/mock.dart

Issue 2777883002: Remove Fasta's copy of accessors.dart. (Closed)
Patch Set: Remove type checking of Rasta, not strong mode clean. Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « pkg/kernel/lib/transformations/closure/converter.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library kernel.transformations.closure.mock; 5 library kernel.transformations.closure.mock;
6 6
7 import '../../ast.dart' 7 import '../../ast.dart'
8 show 8 show
9 Arguments, 9 Arguments,
10 Block, 10 Block,
(...skipping 16 matching lines...) Expand all
27 NullLiteral, 27 NullLiteral,
28 Procedure, 28 Procedure,
29 ProcedureKind, 29 ProcedureKind,
30 Program, 30 Program,
31 PropertyGet, 31 PropertyGet,
32 ReturnStatement, 32 ReturnStatement,
33 Source, 33 Source,
34 Statement, 34 Statement,
35 StaticInvocation, 35 StaticInvocation,
36 Supertype, 36 Supertype,
37 TreeNode,
37 VariableDeclaration, 38 VariableDeclaration,
38 VariableGet; 39 VariableGet;
39 40
40 import '../../core_types.dart' show CoreTypes; 41 import '../../core_types.dart' show CoreTypes;
41 42
42 import '../../frontend/accessors.dart' 43 import '../../frontend/accessors.dart'
43 show 44 show
44 Accessor, 45 Accessor,
45 IndexAccessor, 46 IndexAccessor,
46 PropertyAccessor, 47 PropertyAccessor,
(...skipping 18 matching lines...) Expand all
65 /// } 66 /// }
66 /// } 67 /// }
67 /// 68 ///
68 /// Returns the mock. 69 /// Returns the mock.
69 Class mockUpContext(CoreTypes coreTypes, Program program) { 70 Class mockUpContext(CoreTypes coreTypes, Program program) {
70 String fileUri = "dart:mock"; 71 String fileUri = "dart:mock";
71 72
72 /// final List list; 73 /// final List list;
73 Field listField = new Field(new Name("list"), 74 Field listField = new Field(new Name("list"),
74 type: coreTypes.listClass.rawType, isFinal: true, fileUri: fileUri); 75 type: coreTypes.listClass.rawType, isFinal: true, fileUri: fileUri);
75 Accessor listFieldAccessor = 76 Accessor listFieldAccessor = new ThisPropertyAccessor(
76 new ThisPropertyAccessor(listField.name, listField, null); 77 listField.name, listField, null, TreeNode.noOffset);
77 78
78 /// var parent; 79 /// var parent;
79 Field parentField = new Field(new Name("parent"), fileUri: fileUri); 80 Field parentField = new Field(new Name("parent"), fileUri: fileUri);
80 Accessor parentFieldAccessor = 81 Accessor parentFieldAccessor = new ThisPropertyAccessor(
81 new ThisPropertyAccessor(parentField.name, parentField, parentField); 82 parentField.name, parentField, parentField, TreeNode.noOffset);
82 83
83 List<Field> fields = <Field>[listField, parentField]; 84 List<Field> fields = <Field>[listField, parentField];
84 85
85 /// Context(int i) : list = new List(i); 86 /// Context(int i) : list = new List(i);
86 VariableDeclaration iParameter = new VariableDeclaration("i", 87 VariableDeclaration iParameter = new VariableDeclaration("i",
87 type: coreTypes.intClass.rawType, isFinal: true); 88 type: coreTypes.intClass.rawType, isFinal: true);
88 89
89 // TODO(karlklose): use the default factory when it is exposed again. 90 // TODO(karlklose): use the default factory when it is exposed again.
90 Procedure listConstructor = coreTypes.listClass.procedures 91 Procedure listConstructor = coreTypes.listClass.procedures
91 .firstWhere((Procedure p) => p.name.name == 'filled'); 92 .firstWhere((Procedure p) => p.name.name == 'filled');
92 93
93 Constructor constructor = new Constructor( 94 Constructor constructor = new Constructor(
94 new FunctionNode(new EmptyStatement(), 95 new FunctionNode(new EmptyStatement(),
95 positionalParameters: <VariableDeclaration>[iParameter]), 96 positionalParameters: <VariableDeclaration>[iParameter]),
96 name: new Name(""), 97 name: new Name(""),
97 initializers: <Initializer>[ 98 initializers: <Initializer>[
98 new FieldInitializer( 99 new FieldInitializer(
99 listField, 100 listField,
100 new StaticInvocation( 101 new StaticInvocation(
101 listConstructor, 102 listConstructor,
102 new Arguments(<Expression>[ 103 new Arguments(<Expression>[
103 new VariableAccessor(iParameter).buildSimpleRead(), 104 new VariableAccessor(iParameter, null, TreeNode.noOffset)
105 .buildSimpleRead(),
104 new NullLiteral(), 106 new NullLiteral(),
105 ], types: <DartType>[ 107 ], types: <DartType>[
106 const DynamicType() 108 const DynamicType()
107 ]))) 109 ])))
108 ]); 110 ]);
109 111
110 /// operator[] (int i) => list[i]; 112 /// operator[] (int i) => list[i];
111 iParameter = new VariableDeclaration("i", 113 iParameter = new VariableDeclaration("i",
112 type: coreTypes.intClass.rawType, isFinal: true); 114 type: coreTypes.intClass.rawType, isFinal: true);
113 Accessor accessor = IndexAccessor.make(listFieldAccessor.buildSimpleRead(), 115 Accessor accessor = IndexAccessor.make(
114 new VariableAccessor(iParameter).buildSimpleRead(), null, null); 116 listFieldAccessor.buildSimpleRead(),
117 new VariableAccessor(iParameter, null, TreeNode.noOffset)
118 .buildSimpleRead(),
119 null,
120 null);
115 Procedure indexGet = new Procedure( 121 Procedure indexGet = new Procedure(
116 new Name("[]"), 122 new Name("[]"),
117 ProcedureKind.Operator, 123 ProcedureKind.Operator,
118 new FunctionNode(new ReturnStatement(accessor.buildSimpleRead()), 124 new FunctionNode(new ReturnStatement(accessor.buildSimpleRead()),
119 positionalParameters: <VariableDeclaration>[iParameter]), 125 positionalParameters: <VariableDeclaration>[iParameter]),
120 fileUri: fileUri); 126 fileUri: fileUri);
121 127
122 /// operator[]= (int i, value) { 128 /// operator[]= (int i, value) {
123 /// list[i] = value; 129 /// list[i] = value;
124 /// } 130 /// }
125 iParameter = new VariableDeclaration("i", 131 iParameter = new VariableDeclaration("i",
126 type: coreTypes.intClass.rawType, isFinal: true); 132 type: coreTypes.intClass.rawType, isFinal: true);
127 VariableDeclaration valueParameter = 133 VariableDeclaration valueParameter =
128 new VariableDeclaration("value", isFinal: true); 134 new VariableDeclaration("value", isFinal: true);
129 accessor = IndexAccessor.make(listFieldAccessor.buildSimpleRead(), 135 accessor = IndexAccessor.make(
130 new VariableAccessor(iParameter).buildSimpleRead(), null, null); 136 listFieldAccessor.buildSimpleRead(),
137 new VariableAccessor(iParameter, null, TreeNode.noOffset)
138 .buildSimpleRead(),
139 null,
140 null);
131 Expression expression = accessor.buildAssignment( 141 Expression expression = accessor.buildAssignment(
132 new VariableAccessor(valueParameter).buildSimpleRead(), 142 new VariableAccessor(valueParameter, null, TreeNode.noOffset)
143 .buildSimpleRead(),
133 voidContext: true); 144 voidContext: true);
134 Procedure indexSet = new Procedure( 145 Procedure indexSet = new Procedure(
135 new Name("[]="), 146 new Name("[]="),
136 ProcedureKind.Operator, 147 ProcedureKind.Operator,
137 new FunctionNode(new ExpressionStatement(expression), 148 new FunctionNode(new ExpressionStatement(expression),
138 positionalParameters: <VariableDeclaration>[ 149 positionalParameters: <VariableDeclaration>[
139 iParameter, 150 iParameter,
140 valueParameter 151 valueParameter
141 ]), 152 ]),
142 fileUri: fileUri); 153 fileUri: fileUri);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 fields: fields, 198 fields: fields,
188 procedures: procedures, 199 procedures: procedures,
189 fileUri: fileUri); 200 fileUri: fileUri);
190 Library mock = new Library(Uri.parse(fileUri), 201 Library mock = new Library(Uri.parse(fileUri),
191 name: "mock", classes: [contextClass])..fileUri = fileUri; 202 name: "mock", classes: [contextClass])..fileUri = fileUri;
192 program.libraries.add(mock); 203 program.libraries.add(mock);
193 mock.parent = program; 204 mock.parent = program;
194 program.uriToSource[mock.fileUri] = new Source(<int>[0], const <int>[]); 205 program.uriToSource[mock.fileUri] = new Source(<int>[0], const <int>[]);
195 return contextClass; 206 return contextClass;
196 } 207 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/transformations/closure/converter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698