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

Side by Side Diff: pkg/kernel/test/closures/kernel_chain.dart

Issue 2665723002: Implement canonical name scheme in kernel. (Closed)
Patch Set: Address Kevin's comments Created 3 years, 10 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/test/baseline_tester.dart ('k') | pkg/kernel/test/closures/suite.dart » ('j') | 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library test.kernel.closures.suite; 5 library test.kernel.closures.suite;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show Directory, File, IOSink; 9 import 'dart:io' show Directory, File, IOSink;
10 10
11 import 'dart:typed_data' show Uint8List; 11 import 'dart:typed_data' show Uint8List;
12 12
13 import 'package:kernel/kernel.dart' show Repository, loadProgramFromBinary; 13 import 'package:kernel/kernel.dart' show loadProgramFromBinary;
14 14
15 import 'package:kernel/text/ast_to_text.dart' show Printer; 15 import 'package:kernel/text/ast_to_text.dart' show Printer;
16 16
17 import 'package:testing/testing.dart' 17 import 'package:testing/testing.dart'
18 show ChainContext, Result, StdioProcess, Step; 18 show ChainContext, Result, StdioProcess, Step;
19 19
20 import 'package:kernel/ast.dart' show Library, Program; 20 import 'package:kernel/ast.dart' show Library, Program;
21 21
22 import 'package:kernel/verifier.dart' show verifyProgram; 22 import 'package:kernel/verifier.dart' show verifyProgram;
23 23
24 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; 24 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
25 25
26 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; 26 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
27 27
28 import 'package:kernel/binary/loader.dart' show BinaryLoader;
29
30 Future<bool> fileExists(Uri base, String path) async { 28 Future<bool> fileExists(Uri base, String path) async {
31 return await new File.fromUri(base.resolve(path)).exists(); 29 return await new File.fromUri(base.resolve(path)).exists();
32 } 30 }
33 31
34 class Print extends Step<Program, Program, ChainContext> { 32 class Print extends Step<Program, Program, ChainContext> {
35 const Print(); 33 const Print();
36 34
37 String get name => "print"; 35 String get name => "print";
38 36
39 Future<Result<Program>> run(Program program, _) async { 37 Future<Result<Program>> run(Program program, _) async {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 110
113 String get name => "write .dill"; 111 String get name => "write .dill";
114 112
115 Future<Result<Uri>> run(Program program, _) async { 113 Future<Result<Uri>> run(Program program, _) async {
116 Directory tmp = await Directory.systemTemp.createTemp(); 114 Directory tmp = await Directory.systemTemp.createTemp();
117 Uri uri = tmp.uri.resolve("generated.dill"); 115 Uri uri = tmp.uri.resolve("generated.dill");
118 File generated = new File.fromUri(uri); 116 File generated = new File.fromUri(uri);
119 IOSink sink = generated.openWrite(); 117 IOSink sink = generated.openWrite();
120 try { 118 try {
121 new BinaryPrinter(sink).writeProgramFile(program); 119 new BinaryPrinter(sink).writeProgramFile(program);
120 program.unbindCanonicalNames();
122 } catch (e, s) { 121 } catch (e, s) {
123 return fail(uri, e, s); 122 return fail(uri, e, s);
124 } finally { 123 } finally {
125 print("Wrote `${generated.path}`"); 124 print("Wrote `${generated.path}`");
126 await sink.close(); 125 await sink.close();
127 } 126 }
128 return pass(uri); 127 return pass(uri);
129 } 128 }
130 } 129 }
131 130
(...skipping 13 matching lines...) Expand all
145 } 144 }
146 145
147 class Copy extends Step<Program, Program, ChainContext> { 146 class Copy extends Step<Program, Program, ChainContext> {
148 const Copy(); 147 const Copy();
149 148
150 String get name => "copy program"; 149 String get name => "copy program";
151 150
152 Future<Result<Program>> run(Program program, _) async { 151 Future<Result<Program>> run(Program program, _) async {
153 BytesCollector sink = new BytesCollector(); 152 BytesCollector sink = new BytesCollector();
154 new BinaryPrinter(sink).writeProgramFile(program); 153 new BinaryPrinter(sink).writeProgramFile(program);
154 program.unbindCanonicalNames();
155 Uint8List bytes = sink.collect(); 155 Uint8List bytes = sink.collect();
156 BinaryLoader loader = new BinaryLoader(new Repository()); 156 var newProgram = new Program();
157 return pass(new BinaryBuilder(loader, bytes).readProgramFile()); 157 new BinaryBuilder(bytes).readProgram(newProgram);
158 newProgram.unbindCanonicalNames();
159 return pass(newProgram);
158 } 160 }
159 } 161 }
160 162
161 class BytesCollector implements Sink<List<int>> { 163 class BytesCollector implements Sink<List<int>> {
162 final List<List<int>> lists = <List<int>>[]; 164 final List<List<int>> lists = <List<int>>[];
163 165
164 int length = 0; 166 int length = 0;
165 167
166 void add(List<int> data) { 168 void add(List<int> data) {
167 lists.add(data); 169 lists.add(data);
(...skipping 22 matching lines...) Expand all
190 192
191 Future openWrite(Uri uri, f(IOSink sink)) async { 193 Future openWrite(Uri uri, f(IOSink sink)) async {
192 IOSink sink = new File.fromUri(uri).openWrite(); 194 IOSink sink = new File.fromUri(uri).openWrite();
193 try { 195 try {
194 await f(sink); 196 await f(sink);
195 } finally { 197 } finally {
196 await sink.close(); 198 await sink.close();
197 } 199 }
198 print("Wrote $uri"); 200 print("Wrote $uri");
199 } 201 }
OLDNEW
« no previous file with comments | « pkg/kernel/test/baseline_tester.dart ('k') | pkg/kernel/test/closures/suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698