| 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('native'); | 5 #library('native'); |
| 6 #import('../../lib/uri/uri.dart'); |
| 6 #import('leg.dart'); | 7 #import('leg.dart'); |
| 7 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
| 8 #import('scanner/scannerlib.dart'); | 9 #import('scanner/scannerlib.dart'); |
| 9 #import('ssa/ssa.dart'); | 10 #import('ssa/ssa.dart'); |
| 10 #import('tree/tree.dart'); | 11 #import('tree/tree.dart'); |
| 11 #import('util/util.dart'); | 12 #import('util/util.dart'); |
| 12 | 13 |
| 13 void processNativeClasses(Compiler compiler, | 14 void processNativeClasses(Compiler compiler, |
| 14 CompilationUnitElement compilationUnit) { | 15 CompilationUnitElement compilationUnit) { |
| 15 for (Link<Element> link = compilationUnit.topLevelElements; | 16 for (Link<Element> link = compilationUnit.topLevelElements; |
| 16 !link.isEmpty(); link = link.tail) { | 17 !link.isEmpty(); link = link.tail) { |
| 17 Element element = link.head; | 18 Element element = link.head; |
| 18 if (element.kind == ElementKind.CLASS) { | 19 if (element.kind == ElementKind.CLASS) { |
| 19 ClassElement classElement = element; | 20 ClassElement classElement = element; |
| 20 if (classElement.isNative()) { | 21 if (classElement.isNative()) { |
| 21 compiler.registerInstantiatedClass(classElement); | 22 compiler.registerInstantiatedClass(classElement); |
| 22 // Also parse the node to know all its methods because | 23 // Also parse the node to know all its methods because |
| 23 // otherwise it will only be parsed if there is a call to | 24 // otherwise it will only be parsed if there is a call to |
| 24 // one of its constructor. | 25 // one of its constructor. |
| 25 element.parseNode(compiler); | 26 element.parseNode(compiler); |
| 26 // Resolve to setup the inheritance. | 27 // Resolve to setup the inheritance. |
| 27 element.resolve(compiler); | 28 element.resolve(compiler); |
| 28 } | 29 } |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 | 33 |
| 33 void checkNativeSupport(Compiler compiler, LibraryElement library) { | 34 void checkNativeSupport(Compiler compiler, |
| 34 if (library.script.name.contains('dart/frog/tests/native/src')) { | 35 LibraryElement library, |
| 36 Uri uri) { |
| 37 String libraryName = uri.toString(); |
| 38 if (library.script.name.contains('dart/frog/tests/native/src') |
| 39 || libraryName == 'dart:dom' |
| 40 || libraryName == 'dart:html') { |
| 35 library.define(new ForeignElement( | 41 library.define(new ForeignElement( |
| 36 const SourceString('native'), library), compiler); | 42 const SourceString('native'), library), compiler); |
| 37 } | 43 } |
| 38 } | 44 } |
| 39 | 45 |
| 40 Token handleNativeBlockToSkip(Listener listener, Token token) { | 46 Token handleNativeBlockToSkip(Listener listener, Token token) { |
| 41 token = token.next; | 47 token = token.next; |
| 42 if (token.kind === STRING_TOKEN) { | 48 if (token.kind === STRING_TOKEN) { |
| 43 token = token.next; | 49 token = token.next; |
| 44 } | 50 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } else if (!node.arguments.tail.isEmpty()) { | 215 } else if (!node.arguments.tail.isEmpty()) { |
| 210 builder.compiler.cancel('More than one argument to native'); | 216 builder.compiler.cancel('More than one argument to native'); |
| 211 } else { | 217 } else { |
| 212 LiteralString jsCode = node.arguments.head; | 218 LiteralString jsCode = node.arguments.head; |
| 213 int start = jsCode.value.slowToString()[0] === '@' ? 1 : 0; | 219 int start = jsCode.value.slowToString()[0] === '@' ? 1 : 0; |
| 214 builder.push(new HForeign(builder.unquote(jsCode, start), | 220 builder.push(new HForeign(builder.unquote(jsCode, start), |
| 215 const SourceString('Object'), | 221 const SourceString('Object'), |
| 216 <HInstruction>[])); | 222 <HInstruction>[])); |
| 217 } | 223 } |
| 218 } | 224 } |
| OLD | NEW |