OLD | NEW |
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 import 'dart:collection' show HashSet, Queue; | 5 import 'dart:collection' show HashSet, Queue; |
6 import 'dart:convert' show BASE64, JSON, UTF8; | 6 import 'dart:convert' show BASE64, JSON, UTF8; |
7 import 'dart:io' show File; | 7 import 'dart:io' show File; |
8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; | 8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; |
9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
10 show AnalysisError, CompilationUnit, ErrorSeverity; | 10 show AnalysisError, CompilationUnit, ErrorSeverity; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 sdkResolver: sdkResolver, | 87 sdkResolver: sdkResolver, |
88 fileResolvers: fileResolvers, | 88 fileResolvers: fileResolvers, |
89 summaryData: summaryData, | 89 summaryData: summaryData, |
90 resourceProvider: resourceProvider); | 90 resourceProvider: resourceProvider); |
91 | 91 |
92 var context = createAnalysisContext(); | 92 var context = createAnalysisContext(); |
93 context.sourceFactory = srcFactory; | 93 context.sourceFactory = srcFactory; |
94 context.typeProvider = sdkResolver.dartSdk.context.typeProvider; | 94 context.typeProvider = sdkResolver.dartSdk.context.typeProvider; |
95 context.resultProvider = | 95 context.resultProvider = |
96 new InputPackagesResultProvider(context, summaryData); | 96 new InputPackagesResultProvider(context, summaryData); |
| 97 options.declaredVariables.forEach(context.declaredVariables.define); |
| 98 context.declaredVariables.define('dart.isVM', 'false'); |
97 | 99 |
98 return new ModuleCompiler.withContext(context, summaryData); | 100 return new ModuleCompiler.withContext(context, summaryData); |
99 } | 101 } |
100 | 102 |
101 bool _isFatalError(AnalysisError e, CompilerOptions options) { | 103 bool _isFatalError(AnalysisError e, CompilerOptions options) { |
102 if (errorSeverity(context, e) != ErrorSeverity.ERROR) return false; | 104 if (errorSeverity(context, e) != ErrorSeverity.ERROR) return false; |
103 | 105 |
104 // These errors are not fatal in the REPL compile mode as we | 106 // These errors are not fatal in the REPL compile mode as we |
105 // allow access to private members across library boundaries | 107 // allow access to private members across library boundaries |
106 // and those accesses will show up as undefined members unless | 108 // and those accesses will show up as undefined members unless |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // Fall back to a relative path. | 554 // Fall back to a relative path. |
553 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); | 555 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); |
554 } | 556 } |
555 | 557 |
556 for (int i = 0; i < list.length; i++) { | 558 for (int i = 0; i < list.length; i++) { |
557 list[i] = transformUri(list[i]); | 559 list[i] = transformUri(list[i]); |
558 } | 560 } |
559 map['file'] = transformUri(map['file']); | 561 map['file'] = transformUri(map['file']); |
560 return map; | 562 return map; |
561 } | 563 } |
OLD | NEW |