| OLD | NEW | 
|    1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file |    1 // Copyright (c) 2013, 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 part of dart2js_incremental; |    5 part of dart2js_incremental; | 
|    6  |    6  | 
|    7 /// Do not call this method directly. It will be made private. |    7 /// Do not call this method directly. It will be made private. | 
|    8 // TODO(ahe): Make this method private. |    8 // TODO(ahe): Make this method private. | 
|    9 Future<CompilerImpl> reuseCompiler( |    9 Future<CompilerImpl> reuseCompiler( | 
|   10     {CompilerDiagnostics diagnosticHandler, |   10     {CompilerDiagnostics diagnosticHandler, | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   28   if (diagnosticHandler == null) { |   28   if (diagnosticHandler == null) { | 
|   29     throw 'Missing diagnosticHandler'; |   29     throw 'Missing diagnosticHandler'; | 
|   30   } |   30   } | 
|   31   if (outputProvider == null) { |   31   if (outputProvider == null) { | 
|   32     outputProvider = const NullCompilerOutput(); |   32     outputProvider = const NullCompilerOutput(); | 
|   33   } |   33   } | 
|   34   if (environment == null) { |   34   if (environment == null) { | 
|   35     environment = {}; |   35     environment = {}; | 
|   36   } |   36   } | 
|   37   CompilerImpl compiler = cachedCompiler; |   37   CompilerImpl compiler = cachedCompiler; | 
 |   38   JavaScriptBackend backend = compiler?.backend; | 
|   38   if (compiler == null || |   39   if (compiler == null || | 
|   39       compiler.libraryRoot != libraryRoot || |   40       compiler.libraryRoot != libraryRoot || | 
|   40       !compiler.options.hasIncrementalSupport || |   41       !compiler.options.hasIncrementalSupport || | 
|   41       compiler.hasCrashed || |   42       compiler.hasCrashed || | 
|   42       compiler.enqueuer.resolution.hasEnqueuedReflectiveElements || |   43       backend.mirrorsAnalysis.resolutionHandler.hasEnqueuedReflectiveElements || | 
|   43       compiler.deferredLoadTask.isProgramSplit) { |   44       compiler.deferredLoadTask.isProgramSplit) { | 
|   44     if (compiler != null && compiler.options.hasIncrementalSupport) { |   45     if (compiler != null && compiler.options.hasIncrementalSupport) { | 
|   45       print('***FLUSH***'); |   46       print('***FLUSH***'); | 
|   46       if (compiler.hasCrashed) { |   47       if (compiler.hasCrashed) { | 
|   47         print('Unable to reuse compiler due to crash.'); |   48         print('Unable to reuse compiler due to crash.'); | 
|   48       } else if (compiler.enqueuer.resolution.hasEnqueuedReflectiveElements) { |   49       } else if (backend.mirrorsAnalysis.resolutionHandler | 
 |   50                      .hasEnqueuedReflectiveElements) { | 
|   49         print('Unable to reuse compiler due to dart:mirrors.'); |   51         print('Unable to reuse compiler due to dart:mirrors.'); | 
|   50       } else if (compiler.deferredLoadTask.isProgramSplit) { |   52       } else if (compiler.deferredLoadTask.isProgramSplit) { | 
|   51         print('Unable to reuse compiler due to deferred loading.'); |   53         print('Unable to reuse compiler due to deferred loading.'); | 
|   52       } else { |   54       } else { | 
|   53         print('Unable to reuse compiler.'); |   55         print('Unable to reuse compiler.'); | 
|   54       } |   56       } | 
|   55     } |   57     } | 
|   56     oldTag.makeCurrent(); |   58     oldTag.makeCurrent(); | 
|   57     compiler = new CompilerImpl( |   59     compiler = new CompilerImpl( | 
|   58         inputProvider, |   60         inputProvider, | 
|   59         outputProvider, |   61         outputProvider, | 
|   60         diagnosticHandler, |   62         diagnosticHandler, | 
|   61         new CompilerOptions.parse( |   63         new CompilerOptions.parse( | 
|   62             libraryRoot: libraryRoot, |   64             libraryRoot: libraryRoot, | 
|   63             packageRoot: packageRoot, |   65             packageRoot: packageRoot, | 
|   64             packageConfig: packageConfig, |   66             packageConfig: packageConfig, | 
|   65             options: options, |   67             options: options, | 
|   66             environment: environment)); |   68             environment: environment)); | 
|   67     JavaScriptBackend backend = compiler.backend; |   69     backend = compiler.backend; | 
|   68  |   70  | 
|   69     full.Emitter emitter = backend.emitter.emitter; |   71     full.Emitter emitter = backend.emitter.emitter; | 
|   70  |   72  | 
|   71     // Much like a scout, an incremental compiler is always prepared. For |   73     // Much like a scout, an incremental compiler is always prepared. For | 
|   72     // mixins, classes, and lazy statics, at least. |   74     // mixins, classes, and lazy statics, at least. | 
|   73     emitter |   75     emitter | 
|   74         ..needsClassSupport = true |   76         ..needsClassSupport = true | 
|   75         ..needsMixinSupport = true |   77         ..needsMixinSupport = true | 
|   76         ..needsLazyInitializer = true |   78         ..needsLazyInitializer = true | 
|   77         ..needsStructuredMemberInfo = true; |   79         ..needsStructuredMemberInfo = true; | 
|   78  |   80  | 
|   79     Uri core = Uri.parse("dart:core"); |   81     Uri core = Uri.parse("dart:core"); | 
|   80  |   82  | 
|   81     return compiler.setupSdk().then((_) { |   83     return compiler.setupSdk().then((_) { | 
|   82       return compiler.libraryLoader.loadLibrary(core).then((_) { |   84       return compiler.libraryLoader.loadLibrary(core).then((_) { | 
|   83         // Likewise, always be prepared for runtimeType support. |   85         // Likewise, always be prepared for runtimeType support. | 
|   84         // TODO(johnniwinther): Add global switch to force RTI. |   86         // TODO(johnniwinther): Add global switch to force RTI. | 
|   85         compiler.enabledRuntimeType = true; |   87         compiler.enabledRuntimeType = true; | 
|   86         backend.registerRuntimeType( |   88         backend.registerRuntimeType(compiler.enqueuer.resolution); | 
|   87             compiler.enqueuer.resolution, compiler.globalDependencies); |  | 
|   88         return compiler; |   89         return compiler; | 
|   89       }); |   90       }); | 
|   90     }); |   91     }); | 
|   91   } else { |   92   } else { | 
|   92     compiler.tasks.forEach((t) => t.clearMeasurements()); |   93     compiler.tasks.forEach((t) => t.clearMeasurements()); | 
|   93     compiler |   94     compiler | 
|   94         ..userOutputProvider = outputProvider |   95         ..userOutputProvider = outputProvider | 
|   95         ..provider = inputProvider |   96         ..provider = inputProvider | 
|   96         ..handler = diagnosticHandler |   97         ..handler = diagnosticHandler | 
|   97         ..enqueuer.resolution.queueIsClosed = false |   98         ..enqueuer.resolution.queueIsClosed = false | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  189   final Map<String, String> output = new Map<String, String>(); |  190   final Map<String, String> output = new Map<String, String>(); | 
|  190  |  191  | 
|  191   EventSink<String> createEventSink(String name, String extension) { |  192   EventSink<String> createEventSink(String name, String extension) { | 
|  192     return new StringEventSink((String data) { |  193     return new StringEventSink((String data) { | 
|  193       output['$name.$extension'] = data; |  194       output['$name.$extension'] = data; | 
|  194     }); |  195     }); | 
|  195   } |  196   } | 
|  196  |  197  | 
|  197   String operator[] (String key) => output[key]; |  198   String operator[] (String key) => output[key]; | 
|  198 } |  199 } | 
| OLD | NEW |