| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 // TODO(ahe): Share these with js_helper.dart. | 7 // TODO(ahe): Share these with js_helper.dart. |
| 8 const FUNCTION_INDEX = 0; | 8 const FUNCTION_INDEX = 0; |
| 9 const NAME_INDEX = 1; | 9 const NAME_INDEX = 1; |
| 10 const CALL_NAME_INDEX = 2; | 10 const CALL_NAME_INDEX = 2; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 for (var i = 0; i < fields.length; i++) { | 229 for (var i = 0; i < fields.length; i++) { |
| 230 if(i != 0) str += ", "; | 230 if(i != 0) str += ", "; |
| 231 | 231 |
| 232 var field = generateAccessor(fields[i], accessors, name); | 232 var field = generateAccessor(fields[i], accessors, name); |
| 233 if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; } | 233 if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; } |
| 234 var parameter = "p_" + field; | 234 var parameter = "p_" + field; |
| 235 str += parameter; | 235 str += parameter; |
| 236 body += ("this." + field + " = " + parameter + ";\\n"); | 236 body += ("this." + field + " = " + parameter + ";\\n"); |
| 237 } | 237 } |
| 238 // TODO(zarah): Check whether there is any gain in always having this |
| 239 // property and if so, add it unconditionally. |
| 240 body += "if (typeInfo) this.\$builtinTypeInfo = typeInfo;\\n"; |
| 238 if (supportsDirectProtoAccess) { | 241 if (supportsDirectProtoAccess) { |
| 239 body += "this." + #deferredActionString + "();"; | 242 body += "this." + #deferredActionString + "();"; |
| 240 } | 243 } |
| 241 str += ") {\\n" + body + "}\\n"; | 244 |
| 245 if (fields.length > 0) str += ","; |
| 246 str += "typeInfo) {\\n" + body + "}\\n"; |
| 242 str += name + ".$typeNameProperty=\\"" + name + "\\";\\n"; | 247 str += name + ".$typeNameProperty=\\"" + name + "\\";\\n"; |
| 243 str += "\$desc=\$collectedClasses." + name + "[1];\\n"; | 248 str += "\$desc=\$collectedClasses." + name + "[1];\\n"; |
| 244 str += name + ".prototype = \$desc;\\n"; | 249 str += name + ".prototype = \$desc;\\n"; |
| 245 if (typeof defineClass.name != "string") { | 250 if (typeof defineClass.name != "string") { |
| 246 str += name + ".name=\\"" + name + "\\";\\n"; | 251 str += name + ".name=\\"" + name + "\\";\\n"; |
| 247 } | 252 } |
| 248 if (#hasIsolateSupport) { | 253 if (#hasIsolateSupport) { |
| 249 str += name + "." + #fieldNamesProperty + "=[" + fieldNames | 254 str += name + "." + #fieldNamesProperty + "=[" + fieldNames |
| 250 + "];\\n"; | 255 + "];\\n"; |
| 251 } | 256 } |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 (function() { | 850 (function() { |
| 846 var result = $array[$index]; | 851 var result = $array[$index]; |
| 847 if ($check) { | 852 if ($check) { |
| 848 throw new Error( | 853 throw new Error( |
| 849 name + ": expected value of type \'$type\' at index " + ($index) + | 854 name + ": expected value of type \'$type\' at index " + ($index) + |
| 850 " but got " + (typeof result)); | 855 " but got " + (typeof result)); |
| 851 } | 856 } |
| 852 return result; | 857 return result; |
| 853 })()'''; | 858 })()'''; |
| 854 } | 859 } |
| OLD | NEW |