| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 native; | 5 part of native; |
| 6 | 6 |
| 7 final RegExp nativeRedirectionRegExp = new RegExp(r'^[a-zA-Z][a-zA-Z_$0-9]*$'); | 7 final RegExp nativeRedirectionRegExp = new RegExp(r'^[a-zA-Z][a-zA-Z_$0-9]*$'); |
| 8 | 8 |
| 9 void handleSsaNative(SsaBuilder builder, Expression nativeBody) { | 9 void handleSsaNative(SsaBuilder builder, Expression nativeBody) { |
| 10 Compiler compiler = builder.compiler; | 10 Compiler compiler = builder.compiler; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Check which pattern this native method follows: | 30 // Check which pattern this native method follows: |
| 31 // 1) foo() native; | 31 // 1) foo() native; |
| 32 // hasBody = false | 32 // hasBody = false |
| 33 // 2) foo() native "bar"; | 33 // 2) foo() native "bar"; |
| 34 // No longer supported, this is now done with @JSName('foo') and case 1. | 34 // No longer supported, this is now done with @JSName('foo') and case 1. |
| 35 // 3) foo() native "return 42"; | 35 // 3) foo() native "return 42"; |
| 36 // hasBody = true | 36 // hasBody = true |
| 37 bool hasBody = false; | 37 bool hasBody = false; |
| 38 assert(element.isNative); | 38 assert(backend.isNative(element)); |
| 39 String nativeMethodName = element.fixedBackendName; | 39 String nativeMethodName = backend.getFixedBackendName(element); |
| 40 if (nativeBody != null) { | 40 if (nativeBody != null) { |
| 41 LiteralString jsCode = nativeBody.asLiteralString(); | 41 LiteralString jsCode = nativeBody.asLiteralString(); |
| 42 String str = jsCode.dartString.slowToString(); | 42 String str = jsCode.dartString.slowToString(); |
| 43 if (nativeRedirectionRegExp.hasMatch(str)) { | 43 if (nativeRedirectionRegExp.hasMatch(str)) { |
| 44 reporter.internalError( | 44 reporter.internalError( |
| 45 nativeBody, "Deprecated syntax, use @JSName('name') instead."); | 45 nativeBody, "Deprecated syntax, use @JSName('name') instead."); |
| 46 } | 46 } |
| 47 hasBody = true; | 47 hasBody = true; |
| 48 } | 48 } |
| 49 | 49 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 LiteralString jsCode = nativeBody.asLiteralString(); | 106 LiteralString jsCode = nativeBody.asLiteralString(); |
| 107 builder.push(new HForeignCode.statement( | 107 builder.push(new HForeignCode.statement( |
| 108 js.js.statementTemplateYielding( | 108 js.js.statementTemplateYielding( |
| 109 new js.LiteralStatement(jsCode.dartString.slowToString())), | 109 new js.LiteralStatement(jsCode.dartString.slowToString())), |
| 110 <HInstruction>[], | 110 <HInstruction>[], |
| 111 new SideEffects(), | 111 new SideEffects(), |
| 112 null, | 112 null, |
| 113 backend.dynamicType)); | 113 backend.dynamicType)); |
| 114 } | 114 } |
| 115 } | 115 } |
| OLD | NEW |