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 #library('mirrors.dart2js'); | 5 #library('mirrors.dart2js'); |
6 | 6 |
7 #import('dart:io'); | 7 #import('dart:io'); |
8 #import('dart:uri'); | 8 #import('dart:uri'); |
9 | 9 |
10 #import('../../../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); | 10 #import('../../../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 } else if (type is TypeVariableType) { | 68 } else if (type is TypeVariableType) { |
69 return new Dart2JsTypeVariableMirror(system, type); | 69 return new Dart2JsTypeVariableMirror(system, type); |
70 } else if (type is FunctionType) { | 70 } else if (type is FunctionType) { |
71 return new Dart2JsFunctionTypeMirror(system, type, functionSignature); | 71 return new Dart2JsFunctionTypeMirror(system, type, functionSignature); |
72 } else if (type is VoidType) { | 72 } else if (type is VoidType) { |
73 return new Dart2JsVoidMirror(system, type); | 73 return new Dart2JsVoidMirror(system, type); |
74 } else if (type is TypedefType) { | 74 } else if (type is TypedefType) { |
75 return new Dart2JsTypedefMirror(system, type); | 75 return new Dart2JsTypedefMirror(system, type); |
76 } | 76 } |
77 throw new IllegalArgumentException("Unexpected interface type $type"); | 77 throw new ArgumentError("Unexpected interface type $type"); |
78 } | 78 } |
79 | 79 |
80 Collection<Dart2JsMemberMirror> _convertElementMemberToMemberMirrors( | 80 Collection<Dart2JsMemberMirror> _convertElementMemberToMemberMirrors( |
81 Dart2JsObjectMirror library, Element element) { | 81 Dart2JsObjectMirror library, Element element) { |
82 if (element is SynthesizedConstructorElement) { | 82 if (element is SynthesizedConstructorElement) { |
83 return const <Dart2JsMemberMirror>[]; | 83 return const <Dart2JsMemberMirror>[]; |
84 } else if (element is VariableElement) { | 84 } else if (element is VariableElement) { |
85 return <Dart2JsMemberMirror>[new Dart2JsFieldMirror(library, element)]; | 85 return <Dart2JsMemberMirror>[new Dart2JsFieldMirror(library, element)]; |
86 } else if (element is FunctionElement) { | 86 } else if (element is FunctionElement) { |
87 return <Dart2JsMemberMirror>[new Dart2JsMethodMirror(library, element)]; | 87 return <Dart2JsMemberMirror>[new Dart2JsMethodMirror(library, element)]; |
88 } else if (element is AbstractFieldElement) { | 88 } else if (element is AbstractFieldElement) { |
89 var members = <Dart2JsMemberMirror>[]; | 89 var members = <Dart2JsMemberMirror>[]; |
90 if (element.getter !== null) { | 90 if (element.getter !== null) { |
91 members.add(new Dart2JsMethodMirror(library, element.getter)); | 91 members.add(new Dart2JsMethodMirror(library, element.getter)); |
92 } | 92 } |
93 if (element.setter !== null) { | 93 if (element.setter !== null) { |
94 members.add(new Dart2JsMethodMirror(library, element.setter)); | 94 members.add(new Dart2JsMethodMirror(library, element.setter)); |
95 } | 95 } |
96 return members; | 96 return members; |
97 } | 97 } |
98 throw new IllegalArgumentException( | 98 throw new ArgumentError( |
99 "Unexpected member type $element ${element.kind}"); | 99 "Unexpected member type $element ${element.kind}"); |
100 } | 100 } |
101 | 101 |
102 MethodMirror _convertElementMethodToMethodMirror(Dart2JsObjectMirror library, | 102 MethodMirror _convertElementMethodToMethodMirror(Dart2JsObjectMirror library, |
103 Element element) { | 103 Element element) { |
104 if (element is FunctionElement) { | 104 if (element is FunctionElement) { |
105 return new Dart2JsMethodMirror(library, element); | 105 return new Dart2JsMethodMirror(library, element); |
106 } else { | 106 } else { |
107 return null; | 107 return null; |
108 } | 108 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 class Dart2JsCompilation implements Compilation { | 291 class Dart2JsCompilation implements Compilation { |
292 bool isWindows = (Platform.operatingSystem == 'windows'); | 292 bool isWindows = (Platform.operatingSystem == 'windows'); |
293 api.Compiler _compiler; | 293 api.Compiler _compiler; |
294 Uri cwd; | 294 Uri cwd; |
295 bool isAborting = false; | 295 bool isAborting = false; |
296 Map<String, SourceFile> sourceFiles; | 296 Map<String, SourceFile> sourceFiles; |
297 | 297 |
298 Future<String> provider(Uri uri) { | 298 Future<String> provider(Uri uri) { |
299 if (uri.scheme != 'file') { | 299 if (uri.scheme != 'file') { |
300 throw new IllegalArgumentException(uri); | 300 throw new ArgumentError(uri); |
301 } | 301 } |
302 String source; | 302 String source; |
303 try { | 303 try { |
304 source = readAll(uriPathToNative(uri.path)); | 304 source = readAll(uriPathToNative(uri.path)); |
305 } on FileIOException catch (ex) { | 305 } on FileIOException catch (ex) { |
306 throw 'Error: Cannot read "${relativize(cwd, uri, isWindows)}" ' | 306 throw 'Error: Cannot read "${relativize(cwd, uri, isWindows)}" ' |
307 '(${ex.osError}).'; | 307 '(${ex.osError}).'; |
308 } | 308 } |
309 sourceFiles[uri.toString()] = | 309 sourceFiles[uri.toString()] = |
310 new SourceFile(relativize(cwd, uri, isWindows), source); | 310 new SourceFile(relativize(cwd, uri, isWindows), source); |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 if (node !== null) { | 1391 if (node !== null) { |
1392 var span = system.compiler.spanFromNode(node, script.uri); | 1392 var span = system.compiler.spanFromNode(node, script.uri); |
1393 return new Dart2JsLocation(script, span); | 1393 return new Dart2JsLocation(script, span); |
1394 } else { | 1394 } else { |
1395 var span = system.compiler.spanFromElement(_variable); | 1395 var span = system.compiler.spanFromElement(_variable); |
1396 return new Dart2JsLocation(script, span); | 1396 return new Dart2JsLocation(script, span); |
1397 } | 1397 } |
1398 } | 1398 } |
1399 } | 1399 } |
1400 | 1400 |
OLD | NEW |