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

Side by Side Diff: frog/leg/compiler.dart

Issue 9271037: Inserted string validation as separate task in compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/leg/leg.dart » ('j') | frog/leg/leg.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class WorkItem { 5 class WorkItem {
6 final Element element; 6 final Element element;
7 TreeElements resolutionTree; 7 TreeElements resolutionTree;
8 Function run; 8 Function run;
9 Map<int, BailoutInfo> bailouts = null; 9 Map<int, BailoutInfo> bailouts = null;
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 Namer namer; 42 Namer namer;
43 Types types; 43 Types types;
44 44
45 CompilerTask measuredTask; 45 CompilerTask measuredTask;
46 Element currentElement; 46 Element currentElement;
47 Element currentLibrary = null; // TODO(ngeoffray): initialize this. 47 Element currentLibrary = null; // TODO(ngeoffray): initialize this.
48 48
49 List<CompilerTask> tasks; 49 List<CompilerTask> tasks;
50 ScannerTask scanner; 50 ScannerTask scanner;
51 ParserTask parser; 51 ParserTask parser;
52 StringValidatorTask stringValidator;
52 TreeValidatorTask validator; 53 TreeValidatorTask validator;
53 ResolverTask resolver; 54 ResolverTask resolver;
54 TypeCheckerTask checker; 55 TypeCheckerTask checker;
55 SsaBuilderTask builder; 56 SsaBuilderTask builder;
56 SsaOptimizerTask optimizer; 57 SsaOptimizerTask optimizer;
57 SsaCodeGeneratorTask generator; 58 SsaCodeGeneratorTask generator;
58 CodeEmitterTask emitter; 59 CodeEmitterTask emitter;
59 CompileTimeConstantHandler compileTimeConstantHandler; 60 CompileTimeConstantHandler compileTimeConstantHandler;
60 61
61 static final SourceString MAIN = const SourceString('main'); 62 static final SourceString MAIN = const SourceString('main');
62 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); 63 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod');
63 64
64 Compiler() 65 Compiler()
65 : types = new Types(), 66 : types = new Types(),
66 universe = new Universe(), 67 universe = new Universe(),
67 worklist = new Queue<WorkItem>() { 68 worklist = new Queue<WorkItem>() {
68 namer = new Namer(this); 69 namer = new Namer(this);
69 compileTimeConstantHandler = new CompileTimeConstantHandler(this); 70 compileTimeConstantHandler = new CompileTimeConstantHandler(this);
70 scanner = new ScannerTask(this); 71 scanner = new ScannerTask(this);
71 parser = new ParserTask(this); 72 parser = new ParserTask(this);
73 stringValidator = new StringValidatorTask(this);
72 validator = new TreeValidatorTask(this); 74 validator = new TreeValidatorTask(this);
73 resolver = new ResolverTask(this); 75 resolver = new ResolverTask(this);
74 checker = new TypeCheckerTask(this); 76 checker = new TypeCheckerTask(this);
75 builder = new SsaBuilderTask(this); 77 builder = new SsaBuilderTask(this);
76 optimizer = new SsaOptimizerTask(this); 78 optimizer = new SsaOptimizerTask(this);
77 generator = new SsaCodeGeneratorTask(this); 79 generator = new SsaCodeGeneratorTask(this);
78 emitter = new CodeEmitterTask(this); 80 emitter = new CodeEmitterTask(this);
79 tasks = [scanner, parser, resolver, checker, builder, optimizer, generator, 81 tasks = [scanner, parser, stringValidator, resolver, checker, builder,
80 emitter, compileTimeConstantHandler]; 82 optimizer, generator, emitter, compileTimeConstantHandler];
81 } 83 }
82 84
83 void ensure(bool condition) { 85 void ensure(bool condition) {
84 if (!condition) cancel('failed assertion in leg'); 86 if (!condition) cancel('failed assertion in leg');
85 } 87 }
86 88
87 void unimplemented(String methodName, 89 void unimplemented(String methodName,
88 [Node node, Token token, HInstruction instruction]) { 90 [Node node, Token token, HInstruction instruction]) {
89 cancel("$methodName not implemented", node, token, instruction); 91 cancel("$methodName not implemented", node, token, instruction);
90 } 92 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 currentElement = work.element; 178 currentElement = work.element;
177 (work.run)(this); 179 (work.run)(this);
178 } 180 }
179 enqueueInvokedInstanceMethods(); 181 enqueueInvokedInstanceMethods();
180 } while (!worklist.isEmpty()); 182 } while (!worklist.isEmpty());
181 emitter.assembleProgram(); 183 emitter.assembleProgram();
182 } 184 }
183 185
184 TreeElements analyzeElement(Element element) { 186 TreeElements analyzeElement(Element element) {
185 Node tree = parser.parse(element); 187 Node tree = parser.parse(element);
188 stringValidator.validate(tree);
186 validator.validate(tree); 189 validator.validate(tree);
187 TreeElements elements = resolver.resolve(element); 190 TreeElements elements = resolver.resolve(element);
188 checker.check(tree, elements); 191 checker.check(tree, elements);
189 return elements; 192 return elements;
190 } 193 }
191 194
192 TreeElements analyze(WorkItem work) { 195 TreeElements analyze(WorkItem work) {
193 work.resolutionTree = analyzeElement(work.element); 196 work.resolutionTree = analyzeElement(work.element);
194 return work.resolutionTree; 197 return work.resolutionTree;
195 } 198 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 244
242 void registerDynamicSetter(SourceString methodName) { 245 void registerDynamicSetter(SourceString methodName) {
243 universe.invokedSetters.add(methodName); 246 universe.invokedSetters.add(methodName);
244 } 247 }
245 248
246 void registerInstantiatedClass(ClassElement element) { 249 void registerInstantiatedClass(ClassElement element) {
247 universe.instantiatedClasses.add(element); 250 universe.instantiatedClasses.add(element);
248 } 251 }
249 252
250 Element resolveType(ClassElement element) { 253 Element resolveType(ClassElement element) {
251 parser.parse(element); 254 Node tree = parser.parse(element);
255 stringValidator.validate(tree);
252 resolver.resolveType(element); 256 resolver.resolveType(element);
253 return element; 257 return element;
254 } 258 }
255 259
256 Element resolveSignature(FunctionElement element) { 260 Element resolveSignature(FunctionElement element) {
257 parser.parse(element); 261 Node tree = parser.parse(element);
262 stringValidator.validate(tree);
258 resolver.resolveSignature(element); 263 resolver.resolveSignature(element);
259 return element; 264 return element;
260 } 265 }
261 266
262 reportWarning(Node node, var message) {} 267 reportWarning(Node node, var message) {}
263 reportError(Node node, var message) {} 268 reportError(Node node, var message) {}
264 269
265 Script readScript(String filename) { 270 Script readScript(String filename) {
266 unimplemented('Compiler.readScript'); 271 unimplemented('Compiler.readScript');
267 } 272 }
(...skipping 28 matching lines...) Expand all
296 301
297 class CompilerCancelledException implements Exception { 302 class CompilerCancelledException implements Exception {
298 final String reason; 303 final String reason;
299 CompilerCancelledException(this.reason); 304 CompilerCancelledException(this.reason);
300 305
301 String toString() { 306 String toString() {
302 String banner = 'compiler cancelled'; 307 String banner = 'compiler cancelled';
303 return (reason !== null) ? '$banner: $reason' : '$banner'; 308 return (reason !== null) ? '$banner: $reason' : '$banner';
304 } 309 }
305 } 310 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/leg.dart » ('j') | frog/leg/leg.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698