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 class NativeEmitter { | 5 class NativeEmitter { |
6 | 6 |
7 Compiler compiler; | 7 Compiler compiler; |
8 bool addedDynamicFunction = false; | 8 bool addedDynamicFunction = false; |
9 bool addedTypeNameOfFunction = false; | 9 bool addedTypeNameOfFunction = false; |
10 bool addedDefPropFunction = false; | 10 bool addedDefPropFunction = false; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 method = method || methods.Object; | 150 method = method || methods.Object; |
151 | 151 |
152 if (method == null) { | 152 if (method == null) { |
153 method = function() { | 153 method = function() { |
154 throw $capture(new $exception(obj, name, arguments)); | 154 throw $capture(new $exception(obj, name, arguments)); |
155 }; | 155 }; |
156 } | 156 } |
157 | 157 |
158 var proto = Object.getPrototypeOf(obj); | 158 var proto = Object.getPrototypeOf(obj); |
| 159 var nullCheckMethod = function() { |
| 160 var res = method.apply(this, Array.prototype.slice.call(arguments)); |
| 161 return res === null ? (void 0) : res; |
| 162 } |
159 if (!proto.hasOwnProperty(name)) { | 163 if (!proto.hasOwnProperty(name)) { |
160 $defPropName(proto, name, method); | 164 $defPropName(proto, name, nullCheckMethod); |
161 } | 165 } |
162 | 166 |
163 return method.apply(this, Array.prototype.slice.call(arguments)); | 167 return nullCheckMethod.apply(this, Array.prototype.slice.call(arguments)); |
164 }; | 168 }; |
165 dynamicBind.methods = methods; | 169 dynamicBind.methods = methods; |
166 $defPropName(Object.prototype, name, dynamicBind); | 170 $defPropName(Object.prototype, name, dynamicBind); |
167 return methods; | 171 return methods; |
168 }'''; | 172 }'''; |
169 } | 173 } |
170 | 174 |
171 String buildDynamicMetadataCode() => ''' | 175 String buildDynamicMetadataCode() => ''' |
172 if (typeof $dynamicMetadataName == 'undefined') $dynamicMetadataName = [];'''; | 176 if (typeof $dynamicMetadataName == 'undefined') $dynamicMetadataName = [];'''; |
173 | 177 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 entries.add("\n ['$clsName', ${tagDefns[cls]}]"); | 523 entries.add("\n ['$clsName', ${tagDefns[cls]}]"); |
520 } | 524 } |
521 buffer.add(Strings.join(entries, ',')); | 525 buffer.add(Strings.join(entries, ',')); |
522 buffer.add('];\n'); | 526 buffer.add('];\n'); |
523 buffer.add('$dynamicSetMetadataName(table);\n'); | 527 buffer.add('$dynamicSetMetadataName(table);\n'); |
524 | 528 |
525 buffer.add('})();\n'); | 529 buffer.add('})();\n'); |
526 } | 530 } |
527 } | 531 } |
528 } | 532 } |
OLD | NEW |