Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/setup_program_builder.dart

Issue 1220793012: Revert "Fix runtimeType.toString for tear-offs." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
11 const REQUIRED_PARAMETER_INDEX = 3; 11 const REQUIRED_PARAMETER_INDEX = 3;
12 const OPTIONAL_PARAMETER_INDEX = 4; 12 const OPTIONAL_PARAMETER_INDEX = 4;
13 const DEFAULT_ARGUMENTS_INDEX = 5; 13 const DEFAULT_ARGUMENTS_INDEX = 5;
14 14
15 const bool VALIDATE_DATA = false; 15 const bool VALIDATE_DATA = false;
16 16
17 const RANGE1_SIZE = RANGE1_LAST - RANGE1_FIRST + 1; 17 const RANGE1_SIZE = RANGE1_LAST - RANGE1_FIRST + 1;
18 const RANGE2_SIZE = RANGE2_LAST - RANGE2_FIRST + 1; 18 const RANGE2_SIZE = RANGE2_LAST - RANGE2_FIRST + 1;
19 const RANGE1_ADJUST = - (FIRST_FIELD_CODE - RANGE1_FIRST); 19 const RANGE1_ADJUST = - (FIRST_FIELD_CODE - RANGE1_FIRST);
20 const RANGE2_ADJUST = - (FIRST_FIELD_CODE + RANGE1_SIZE - RANGE2_FIRST); 20 const RANGE2_ADJUST = - (FIRST_FIELD_CODE + RANGE1_SIZE - RANGE2_FIRST);
21 const RANGE3_ADJUST = 21 const RANGE3_ADJUST =
22 - (FIRST_FIELD_CODE + RANGE1_SIZE + RANGE2_SIZE - RANGE3_FIRST); 22 - (FIRST_FIELD_CODE + RANGE1_SIZE + RANGE2_SIZE - RANGE3_FIRST);
23 23
24 const String setupProgramName ='setupProgram'; 24 const String setupProgramName ='setupProgram';
25 // TODO(floitsch): make sure this property can't clash with anything. It's
26 // unlikely since it lives on types, but still.
27 const String typeNameProperty = r'builtin$cls';
25 28
26 jsAst.Statement buildSetupProgram(Program program, Compiler compiler, 29 jsAst.Statement buildSetupProgram(Program program, Compiler compiler,
27 JavaScriptBackend backend, 30 JavaScriptBackend backend,
28 Namer namer, 31 Namer namer,
29 OldEmitter emitter) { 32 OldEmitter emitter) {
30 33
31 jsAst.Expression typeInformationAccess = 34 jsAst.Expression typeInformationAccess =
32 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION); 35 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION);
33 jsAst.Expression globalFunctionsAccess = 36 jsAst.Expression globalFunctionsAccess =
34 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); 37 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 var field = generateAccessor(fields[i], accessors, name); 233 var field = generateAccessor(fields[i], accessors, name);
231 if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; } 234 if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; }
232 var parameter = "p_" + field; 235 var parameter = "p_" + field;
233 str += parameter; 236 str += parameter;
234 body += ("this." + field + " = " + parameter + ";\\n"); 237 body += ("this." + field + " = " + parameter + ";\\n");
235 } 238 }
236 if (supportsDirectProtoAccess) { 239 if (supportsDirectProtoAccess) {
237 body += "this." + #deferredActionString + "();"; 240 body += "this." + #deferredActionString + "();";
238 } 241 }
239 str += ") {\\n" + body + "}\\n"; 242 str += ") {\\n" + body + "}\\n";
243 str += name + ".$typeNameProperty=\\"" + name + "\\";\\n";
240 str += "\$desc=\$collectedClasses." + name + "[1];\\n"; 244 str += "\$desc=\$collectedClasses." + name + "[1];\\n";
241 str += name + ".prototype = \$desc;\\n"; 245 str += name + ".prototype = \$desc;\\n";
242 if (typeof defineClass.name != "string") { 246 if (typeof defineClass.name != "string") {
243 // IE does not store the name, but allows to modify the property.
244 str += name + ".name=\\"" + name + "\\";\\n"; 247 str += name + ".name=\\"" + name + "\\";\\n";
245 } 248 }
246 if (#hasIsolateSupport) { 249 if (#hasIsolateSupport) {
247 str += name + "." + #fieldNamesProperty + "=[" + fieldNames 250 str += name + "." + #fieldNamesProperty + "=[" + fieldNames
248 + "];\\n"; 251 + "];\\n";
249 } 252 }
250 str += accessors.join(""); 253 str += accessors.join("");
251 254
252 return str; 255 return str;
253 } 256 }
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 (function() { 846 (function() {
844 var result = $array[$index]; 847 var result = $array[$index];
845 if ($check) { 848 if ($check) {
846 throw new Error( 849 throw new Error(
847 name + ": expected value of type \'$type\' at index " + ($index) + 850 name + ": expected value of type \'$type\' at index " + ($index) +
848 " but got " + (typeof result)); 851 " but got " + (typeof result));
849 } 852 }
850 return result; 853 return result;
851 })()'''; 854 })()''';
852 } 855 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698