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

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

Issue 954253002: dart2js: add compiler builtins to the core-runtime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move more foreigns to builtins. Created 5 years, 8 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 | Annotate | Revision Log
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 String get setupProgramName => 'setupProgram'; 24 const String setupProgramName ='setupProgram';
25 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';
26 28
27 jsAst.Statement buildSetupProgram(Program program, Compiler compiler, 29 jsAst.Statement buildSetupProgram(Program program, Compiler compiler,
28 JavaScriptBackend backend, 30 JavaScriptBackend backend,
29 Namer namer, 31 Namer namer,
30 OldEmitter emitter) { 32 OldEmitter emitter) {
31 33
32 jsAst.Expression typeInformationAccess = 34 jsAst.Expression typeInformationAccess =
33 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION); 35 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION);
34 jsAst.Expression globalFunctionsAccess = 36 jsAst.Expression globalFunctionsAccess =
35 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); 37 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 var field = generateAccessor(fields[i], accessors, name); 232 var field = generateAccessor(fields[i], accessors, name);
231 if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; } 233 if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; }
232 var parameter = "p_" + field; 234 var parameter = "p_" + field;
233 str += parameter; 235 str += parameter;
234 body += ("this." + field + " = " + parameter + ";\\n"); 236 body += ("this." + field + " = " + parameter + ";\\n");
235 } 237 }
236 if (supportsDirectProtoAccess) { 238 if (supportsDirectProtoAccess) {
237 body += "this." + #deferredActionString + "();"; 239 body += "this." + #deferredActionString + "();";
238 } 240 }
239 str += ") {\\n" + body + "}\\n"; 241 str += ") {\\n" + body + "}\\n";
240 str += name + ".builtin\$cls=\\"" + name + "\\";\\n"; 242 str += name + ".$typeNameProperty=\\"" + name + "\\";\\n";
241 str += "\$desc=\$collectedClasses." + name + "[1];\\n"; 243 str += "\$desc=\$collectedClasses." + name + "[1];\\n";
242 str += name + ".prototype = \$desc;\\n"; 244 str += name + ".prototype = \$desc;\\n";
243 if (typeof defineClass.name != "string") { 245 if (typeof defineClass.name != "string") {
244 str += name + ".name=\\"" + name + "\\";\\n"; 246 str += name + ".name=\\"" + name + "\\";\\n";
245 } 247 }
246 if (#hasIsolateSupport) { 248 if (#hasIsolateSupport) {
247 str += name + "." + #fieldNamesProperty + "=[" + fieldNames 249 str += name + "." + #fieldNamesProperty + "=[" + fieldNames
248 + "];\\n"; 250 + "];\\n";
249 } 251 }
250 str += accessors.join(""); 252 str += accessors.join("");
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 (function() { 843 (function() {
842 var result = $array[$index]; 844 var result = $array[$index];
843 if ($check) { 845 if ($check) {
844 throw new Error( 846 throw new Error(
845 name + ": expected value of type \'$type\' at index " + ($index) + 847 name + ": expected value of type \'$type\' at index " + ($index) +
846 " but got " + (typeof result)); 848 " but got " + (typeof result));
847 } 849 }
848 return result; 850 return result;
849 })()'''; 851 })()''';
850 } 852 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698