OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // TODO(jmesserly): _genStub is a hole in the run-time type checker. | 62 // TODO(jmesserly): _genStub is a hole in the run-time type checker. |
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 var funcImpl = world.coreimpl.types['_FunctionImplementation']; | 72 world.functionImplType.markUsed(); |
73 funcImpl.markUsed(); | 73 world.gen.genMethod(world.functionImplType.getMember('_genStub')); |
74 world.gen.genMethod(funcImpl.getMember('_genStub')); | |
75 } | 74 } |
76 | 75 |
77 Value invoke(MethodGenerator context, Node node, Value target, | 76 Value invoke(MethodGenerator context, Node node, Value target, |
78 Arguments args) { | 77 Arguments args) { |
79 return super.invoke(context, node, target, args); | 78 return super.invoke(context, node, target, args); |
80 } | 79 } |
81 | 80 |
82 void generate(CodeWriter code) { | 81 void generate(CodeWriter code) { |
83 isGenerated = true; | 82 isGenerated = true; |
84 if (args.hasNames) { | 83 if (args.hasNames) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 nameBuilder.add('\$'); | 260 nameBuilder.add('\$'); |
262 if (name.contains('\$')) { | 261 if (name.contains('\$')) { |
263 // Disambiguate "a:b:" from "a$b:". Using the length works well because | 262 // Disambiguate "a:b:" from "a$b:". Using the length works well because |
264 // the names can't start with digits. | 263 // the names can't start with digits. |
265 nameBuilder.add('${name.length}'); | 264 nameBuilder.add('${name.length}'); |
266 } | 265 } |
267 nameBuilder.add(name); | 266 nameBuilder.add(name); |
268 } | 267 } |
269 return nameBuilder.toString(); | 268 return nameBuilder.toString(); |
270 } | 269 } |
OLD | NEW |