| OLD | NEW |
| 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 bool allowSpeculativeOptimization = true; | 9 bool allowSpeculativeOptimization = true; |
| 10 List<HTypeGuard> guards = const <HTypeGuard>[]; | 10 List<HTypeGuard> guards = const <HTypeGuard>[]; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 const SourceString('JS_CURRENT_ISOLATE'), library), this); | 259 const SourceString('JS_CURRENT_ISOLATE'), library), this); |
| 260 library.define(new ForeignElement( | 260 library.define(new ForeignElement( |
| 261 const SourceString('JS_CALL_IN_ISOLATE'), library), this); | 261 const SourceString('JS_CALL_IN_ISOLATE'), library), this); |
| 262 library.define(new ForeignElement( | 262 library.define(new ForeignElement( |
| 263 const SourceString('DART_CLOSURE_TO_JS'), library), this); | 263 const SourceString('DART_CLOSURE_TO_JS'), library), this); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void runCompiler(Uri uri) { | 266 void runCompiler(Uri uri) { |
| 267 scanBuiltinLibraries(); | 267 scanBuiltinLibraries(); |
| 268 mainApp = scanner.loadLibrary(uri, null); | 268 mainApp = scanner.loadLibrary(uri, null); |
| 269 final Element mainMethod = mainApp.find(MAIN); | 269 final Element main = mainApp.find(MAIN); |
| 270 if (mainMethod === null) { | 270 if (main === null) { |
| 271 withCurrentElement(mainApp, () => cancel('Could not find $MAIN')); | 271 withCurrentElement(mainApp, () => cancel('Could not find $MAIN')); |
| 272 } else { | 272 } else { |
| 273 withCurrentElement(mainMethod, () { | 273 withCurrentElement(main, () { |
| 274 if (!mainMethod.isFunction()) { | 274 if (!main.isFunction()) { |
| 275 cancel('main is not a function', element: mainMethod); | 275 cancel('main is not a function', element: main); |
| 276 } | 276 } |
| 277 FunctionElement mainMethod = main; |
| 277 FunctionParameters parameters = mainMethod.computeParameters(this); | 278 FunctionParameters parameters = mainMethod.computeParameters(this); |
| 278 if (parameters.parameterCount > 0) { | 279 if (parameters.parameterCount > 0) { |
| 279 cancel('main cannot have parameters', element: mainMethod); | 280 cancel('main cannot have parameters', element: mainMethod); |
| 280 } | 281 } |
| 281 }); | 282 }); |
| 282 } | 283 } |
| 283 native.processNativeClasses(this, universe.libraries.getValues()); | 284 native.processNativeClasses(this, universe.libraries.getValues()); |
| 284 enqueue(new WorkItem.toCompile(mainMethod)); | 285 enqueue(new WorkItem.toCompile(main)); |
| 285 codegenProgress.reset(); | 286 codegenProgress.reset(); |
| 286 while (!worklist.isEmpty()) { | 287 while (!worklist.isEmpty()) { |
| 287 WorkItem work = worklist.removeLast(); | 288 WorkItem work = worklist.removeLast(); |
| 288 withCurrentElement(work.element, () => (work.run)(this)); | 289 withCurrentElement(work.element, () => (work.run)(this)); |
| 289 } | 290 } |
| 290 workListIsClosed = true; | 291 workListIsClosed = true; |
| 291 assert(enqueuer.checkNoEnqueuedInvokedInstanceMethods()); | 292 assert(enqueuer.checkNoEnqueuedInvokedInstanceMethods()); |
| 292 enqueuer.registerFieldClosureInvocations(); | 293 enqueuer.registerFieldClosureInvocations(); |
| 293 emitter.assembleProgram(); | 294 emitter.assembleProgram(); |
| 294 if (!worklist.isEmpty()) { | 295 if (!worklist.isEmpty()) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 542 } |
| 542 } | 543 } |
| 543 | 544 |
| 544 class SourceSpan { | 545 class SourceSpan { |
| 545 final Uri uri; | 546 final Uri uri; |
| 546 final int begin; | 547 final int begin; |
| 547 final int end; | 548 final int end; |
| 548 | 549 |
| 549 const SourceSpan(this.uri, this.begin, this.end); | 550 const SourceSpan(this.uri, this.begin, this.end); |
| 550 } | 551 } |
| OLD | NEW |