| OLD | NEW |
| 1 // Copyright (c) 2011, 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 /** A dynamic member stub. */ | 5 /** A dynamic member stub. */ |
| 6 class VarMember { | 6 class VarMember { |
| 7 final String name; | 7 final String name; |
| 8 bool isGenerated = false; | 8 bool isGenerated = false; |
| 9 | 9 |
| 10 VarMember(this.name); | 10 VarMember(this.name); |
| 11 | 11 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // It bypasses the checks we would do at the callsite for methods. | 63 // It bypasses the checks we would do at the callsite for methods. |
| 64 // Also, it won't work properly for native JS functions (those don't have | 64 // Also, it won't work properly for native JS functions (those don't have |
| 65 // an accurate .length) | 65 // an accurate .length) |
| 66 class VarFunctionStub extends VarMember { | 66 class VarFunctionStub extends VarMember { |
| 67 final Arguments args; | 67 final Arguments args; |
| 68 | 68 |
| 69 VarFunctionStub(String name, Arguments callArgs) | 69 VarFunctionStub(String name, Arguments callArgs) |
| 70 : super(name), args = callArgs.toCallStubArgs() { | 70 : super(name), args = callArgs.toCallStubArgs() { |
| 71 // Ensure dependency is generated | 71 // Ensure dependency is generated |
| 72 world.functionImplType.markUsed(); | 72 world.functionImplType.markUsed(); |
| 73 world.gen.genMethod(world.functionImplType.getMember('_genStub')); | 73 world.gen.invokeMethod(world.functionImplType.getMember('_genStub')); |
| 74 } | 74 } |
| 75 | 75 |
| 76 Value invoke(MethodGenerator context, Node node, Value target, | 76 Value invoke(MethodGenerator context, Node node, Value target, |
| 77 Arguments args) { | 77 Arguments args) { |
| 78 return super.invoke(context, node, target, args); | 78 return super.invoke(context, node, target, args); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void generate(CodeWriter code) { | 81 void generate(CodeWriter code) { |
| 82 isGenerated = true; | 82 isGenerated = true; |
| 83 if (args.hasNames) { | 83 if (args.hasNames) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 nameBuilder.add('\$'); | 265 nameBuilder.add('\$'); |
| 266 if (name.contains('\$')) { | 266 if (name.contains('\$')) { |
| 267 // Disambiguate "a:b:" from "a$b:". Using the length works well because | 267 // Disambiguate "a:b:" from "a$b:". Using the length works well because |
| 268 // the names can't start with digits. | 268 // the names can't start with digits. |
| 269 nameBuilder.add('${name.length}'); | 269 nameBuilder.add('${name.length}'); |
| 270 } | 270 } |
| 271 nameBuilder.add(name); | 271 nameBuilder.add(name); |
| 272 } | 272 } |
| 273 return nameBuilder.toString(); | 273 return nameBuilder.toString(); |
| 274 } | 274 } |
| OLD | NEW |