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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 12310045: Make quotes in support code match rest of code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/js_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // }, 243 // },
244 // bar$2: function(t, v) { 244 // bar$2: function(t, v) {
245 // this.x = t - v; 245 // this.x = t - v;
246 // }, 246 // },
247 // }); 247 // });
248 248
249 // function(cls, fields, prototype) { 249 // function(cls, fields, prototype) {
250 return js.fun(['cls', 'fields', 'prototype'], [ 250 return js.fun(['cls', 'fields', 'prototype'], [
251 js['var constructor'], 251 js['var constructor'],
252 252
253 // if (typeof fields == 'function') { 253 // if (typeof fields == "function") {
254 js.if_(js["typeof fields == 'function'"], [ 254 js.if_(js['typeof fields == "function"'], [
255 js['constructor = fields'] 255 js['constructor = fields']
256 ], /* else */ [ 256 ], /* else */ [
257 js['var str = "function " + cls + "("'], 257 js['var str = "function " + cls + "("'],
258 js['var body = ""'], 258 js['var body = ""'],
259 259
260 // for (var i = 0; i < fields.length; i++) { 260 // for (var i = 0; i < fields.length; i++) {
261 js.for_(js['var i = 0'], js['i < fields.length'], js['i++'], [ 261 js.for_(js['var i = 0'], js['i < fields.length'], js['i++'], [
262 // if (i != 0) str += ", "; 262 // if (i != 0) str += ", ";
263 js.if_(js['i != 0'], js['str += ", "']), 263 js.if_(js['i != 0'], js['str += ", "']),
264 264
(...skipping 23 matching lines...) Expand all
288 // So we have to do more checks. 288 // So we have to do more checks.
289 // Opera bug was filed as DSK-370158, and fixed as CORE-47615 289 // Opera bug was filed as DSK-370158, and fixed as CORE-47615
290 // (http://my.opera.com/desktopteam/blog/2012/07/20/more-12-01-fixes). 290 // (http://my.opera.com/desktopteam/blog/2012/07/20/more-12-01-fixes).
291 // If the browser does not support __proto__ we need to instantiate an 291 // If the browser does not support __proto__ we need to instantiate an
292 // object with the correct (internal) prototype set up correctly, and then 292 // object with the correct (internal) prototype set up correctly, and then
293 // copy the members. 293 // copy the members.
294 // TODO(8541): Remove this work around. 294 // TODO(8541): Remove this work around.
295 295
296 return [ 296 return [
297 js['var $supportsProtoName = false'], 297 js['var $supportsProtoName = false'],
298 js["var tmp = (defineClass('c', ['f?'], {})).prototype"], 298 js['var tmp = (defineClass("c", ["f?"], {})).prototype'],
299 299
300 js.if_(js['tmp.__proto__'], [ 300 js.if_(js['tmp.__proto__'], [
301 js['tmp.__proto__ = {}'], 301 js['tmp.__proto__ = {}'],
302 js.if_(js[r"typeof tmp.get$f != 'undefined'"], 302 js.if_(js[r'typeof tmp.get$f != "undefined"'],
303 js['$supportsProtoName = true']) 303 js['$supportsProtoName = true'])
304 304
305 ]) 305 ])
306 ]; 306 ];
307 } 307 }
308 308
309 jsAst.Fun get finishClassesFunction { 309 jsAst.Fun get finishClassesFunction {
310 // Class descriptions are collected in a JS object. 310 // Class descriptions are collected in a JS object.
311 // 'finishClasses' takes all collected descriptions and sets up 311 // 'finishClasses' takes all collected descriptions and sets up
312 // the prototype. 312 // the prototype.
(...skipping 21 matching lines...) Expand all
334 // if (hasOwnProperty.call(collectedClasses, cls)) { 334 // if (hasOwnProperty.call(collectedClasses, cls)) {
335 js.if_(js['hasOwnProperty.call(collectedClasses, cls)'], [ 335 js.if_(js['hasOwnProperty.call(collectedClasses, cls)'], [
336 js['var desc = collectedClasses[cls]'], 336 js['var desc = collectedClasses[cls]'],
337 337
338 /* The 'fields' are either a constructor function or a 338 /* The 'fields' are either a constructor function or a
339 * string encoding fields, constructor and superclass. Get 339 * string encoding fields, constructor and superclass. Get
340 * the superclass and the fields in the format 340 * the superclass and the fields in the format
341 * Super;field1,field2 from the null-string property on the 341 * Super;field1,field2 from the null-string property on the
342 * descriptor. 342 * descriptor.
343 */ 343 */
344 // var fields = desc[''], supr; 344 // var fields = desc[""], supr;
345 js["var fields = desc[''], supr"], 345 js['var fields = desc[""], supr'],
346 346
347 js.if_(js["typeof fields == 'string'"], [ 347 js.if_(js['typeof fields == "string"'], [
348 js['var s = fields.split(";")'], 348 js['var s = fields.split(";")'],
349 js['supr = s[0]'], 349 js['supr = s[0]'],
350 js["fields = s[1] == '' ? [] : s[1].split(',')"], 350 js['fields = s[1] == "" ? [] : s[1].split(",")'],
351 ], /* else */ [ 351 ], /* else */ [
352 js['supr = desc.super'] 352 js['supr = desc.super']
353 ]), 353 ]),
354 354
355 js['isolateProperties[cls] = defineClass(cls, fields, desc)'], 355 js['isolateProperties[cls] = defineClass(cls, fields, desc)'],
356 356
357 // if (supr) pendingClasses[cls] = supr; 357 // if (supr) pendingClasses[cls] = supr;
358 js.if_(js['supr'], js['pendingClasses[cls] = supr']) 358 js.if_(js['supr'], js['pendingClasses[cls] = supr'])
359 ]) 359 ])
360 ]), 360 ]),
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 /** 1006 /**
1007 * Generates a holder object if it is needed. A holder is a JavaScript 1007 * Generates a holder object if it is needed. A holder is a JavaScript
1008 * object literal with a field [builtin$cls] that contains the name of the 1008 * object literal with a field [builtin$cls] that contains the name of the
1009 * class as a string (just like object constructors do). The is-checks for 1009 * class as a string (just like object constructors do). The is-checks for
1010 * the class are are added to the holder object later. 1010 * the class are are added to the holder object later.
1011 */ 1011 */
1012 void maybeGenerateHolder(ClassElement cls) { 1012 void maybeGenerateHolder(ClassElement cls) {
1013 if (!needsHolder(cls)) return; 1013 if (!needsHolder(cls)) return;
1014 String holder = namer.isolateAccess(cls); 1014 String holder = namer.isolateAccess(cls);
1015 String name = namer.getName(cls); 1015 String name = namer.getName(cls);
1016 buffer.add("$holder$_=$_{builtin\$cls:$_'$name'"); 1016 buffer.add('$holder$_=$_{builtin\$cls:$_"$name"');
1017 buffer.add('}$N'); 1017 buffer.add('}$N');
1018 } 1018 }
1019 1019
1020 // Create representation objects for classes that we do not have a class 1020 // Create representation objects for classes that we do not have a class
1021 // definition for (because they are uninstantiated or native). 1021 // definition for (because they are uninstantiated or native).
1022 for (ClassElement cls in rti.allArguments) { 1022 for (ClassElement cls in rti.allArguments) {
1023 maybeGenerateHolder(cls); 1023 maybeGenerateHolder(cls);
1024 } 1024 }
1025 1025
1026 // Add checks to the constructors of instantiated classes or to the created 1026 // Add checks to the constructors of instantiated classes or to the created
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 String mainCall = null; 2180 String mainCall = null;
2181 if (compiler.hasIsolateSupport()) { 2181 if (compiler.hasIsolateSupport()) {
2182 Element isolateMain = 2182 Element isolateMain =
2183 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE); 2183 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE);
2184 mainCall = buildIsolateSetup(buffer, main, isolateMain); 2184 mainCall = buildIsolateSetup(buffer, main, isolateMain);
2185 } else { 2185 } else {
2186 mainCall = '${namer.isolateAccess(main)}()'; 2186 mainCall = '${namer.isolateAccess(main)}()';
2187 } 2187 }
2188 addComment('BEGIN invoke [main].', buffer); 2188 addComment('BEGIN invoke [main].', buffer);
2189 buffer.add(""" 2189 buffer.add("""
2190 if (typeof document !== 'undefined' && document.readyState !== 'complete') { 2190 if (typeof document !== "undefined" && document.readyState !== "complete") {
2191 document.addEventListener('readystatechange', function () { 2191 document.addEventListener("readystatechange", function () {
2192 if (document.readyState == 'complete') { 2192 if (document.readyState == "complete") {
2193 if (typeof dartMainRunner === 'function') { 2193 if (typeof dartMainRunner === "function") {
2194 dartMainRunner(function() { ${mainCall}; }); 2194 dartMainRunner(function() { ${mainCall}; });
2195 } else { 2195 } else {
2196 ${mainCall}; 2196 ${mainCall};
2197 } 2197 }
2198 } 2198 }
2199 }, false); 2199 }, false);
2200 } else { 2200 } else {
2201 if (typeof dartMainRunner === 'function') { 2201 if (typeof dartMainRunner === "function") {
2202 dartMainRunner(function() { ${mainCall}; }); 2202 dartMainRunner(function() { ${mainCall}; });
2203 } else { 2203 } else {
2204 ${mainCall}; 2204 ${mainCall};
2205 } 2205 }
2206 } 2206 }
2207 """); 2207 """);
2208 addComment('END invoke [main].', buffer); 2208 addComment('END invoke [main].', buffer);
2209 } 2209 }
2210 2210
2211 void emitGetInterceptorMethod(CodeBuffer buffer, 2211 void emitGetInterceptorMethod(CodeBuffer buffer,
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 """; 2706 """;
2707 const String HOOKS_API_USAGE = """ 2707 const String HOOKS_API_USAGE = """
2708 // The code supports the following hooks: 2708 // The code supports the following hooks:
2709 // dartPrint(message) - if this function is defined it is called 2709 // dartPrint(message) - if this function is defined it is called
2710 // instead of the Dart [print] method. 2710 // instead of the Dart [print] method.
2711 // dartMainRunner(main) - if this function is defined, the Dart [main] 2711 // dartMainRunner(main) - if this function is defined, the Dart [main]
2712 // method will not be invoked directly. 2712 // method will not be invoked directly.
2713 // Instead, a closure that will invoke [main] is 2713 // Instead, a closure that will invoke [main] is
2714 // passed to [dartMainRunner]. 2714 // passed to [dartMainRunner].
2715 """; 2715 """;
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698