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

Side by Side Diff: sdk/lib/js/dart2js/js_dart2js.dart

Issue 19387005: Workaround for 11854 (broken type check) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/html/html.status » ('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) 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 library dart.js; 5 library dart.js;
6 6
7 import 'dart:_foreign_helper' show JS; 7 import 'dart:_foreign_helper' show JS;
8 import 'dart:_js_helper' show convertDartClosureToJS; 8 import 'dart:_js_helper' show convertDartClosureToJS;
9 9
10 JsObject get context { 10 JsObject get context {
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 JsFunction toJs() => new JsFunction._fromJs(_jsFunction); 41 JsFunction toJs() => new JsFunction._fromJs(_jsFunction);
42 } 42 }
43 43
44 class JsObject implements Serializable<JsObject> { 44 class JsObject implements Serializable<JsObject> {
45 final dynamic _jsObject; 45 final dynamic _jsObject;
46 46
47 JsObject._fromJs(this._jsObject); 47 JsObject._fromJs(this._jsObject);
48 48
49 factory JsObject(Serializable<JsFunction> constructor, [List arguments]) { 49 // TODO(vsm): Type constructor as Serializable<JsFunction> when
50 // dartbug.com/11854 is fixed.
51 factory JsObject(var constructor, [List arguments]) {
50 final constr = _convertToJS(constructor); 52 final constr = _convertToJS(constructor);
51 if (arguments == null) { 53 if (arguments == null) {
52 return new JsObject._fromJs(JS('=Object', 'new #()', constr)); 54 return new JsObject._fromJs(JS('=Object', 'new #()', constr));
53 } 55 }
54 final args = arguments.map(_convertToJS).toList(); 56 final args = arguments.map(_convertToJS).toList();
55 switch (args.length) { 57 switch (args.length) {
56 case 0: 58 case 0:
57 return new JsObject._fromJs(JS('=Object', 'new #()', constr)); 59 return new JsObject._fromJs(JS('=Object', 'new #()', constr));
58 case 1: 60 case 1:
59 return new JsObject._fromJs(JS('=Object', 'new #(#)', constr, args[0])); 61 return new JsObject._fromJs(JS('=Object', 'new #(#)', constr, args[0]));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 operator==(other) => other is JsObject && 130 operator==(other) => other is JsObject &&
129 JS('bool', '# === #', _convertToJS(this), _convertToJS(other)); 131 JS('bool', '# === #', _convertToJS(this), _convertToJS(other));
130 132
131 bool hasProperty(String property) => JS('bool', '# in #', property, 133 bool hasProperty(String property) => JS('bool', '# in #', property,
132 _convertToJS(this)); 134 _convertToJS(this));
133 135
134 void deleteProperty(String name) { 136 void deleteProperty(String name) {
135 JS('void', 'delete #[#]', _convertToJS(this), name); 137 JS('void', 'delete #[#]', _convertToJS(this), name);
136 } 138 }
137 139
138 bool instanceof(Serializable<JsFunction> type) => 140 // TODO(vsm): Type type as Serializable<JsFunction> when
141 // dartbug.com/11854 is fixed.
142 bool instanceof(var type) =>
139 JS('bool', '# instanceof #', _convertToJS(this), _convertToJS(type)); 143 JS('bool', '# instanceof #', _convertToJS(this), _convertToJS(type));
140 144
141 String toString() { 145 String toString() {
142 try { 146 try {
143 return JS('String', '#.toString()', _convertToJS(this)); 147 return JS('String', '#.toString()', _convertToJS(this));
144 } catch(e) { 148 } catch(e) {
145 return super.toString(); 149 return super.toString();
146 } 150 }
147 } 151 }
148 152
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 JS('bool', 'typeof # == "boolean" || # instanceof Boolean', o, o)) { 192 JS('bool', 'typeof # == "boolean" || # instanceof Boolean', o, o)) {
189 return o; 193 return o;
190 } else if (JS('bool', '# instanceof Function', o)) { 194 } else if (JS('bool', '# instanceof Function', o)) {
191 return new JsFunction._fromJs(JS('=Object', '#', o)); 195 return new JsFunction._fromJs(JS('=Object', '#', o));
192 } else if (JS('bool', '# instanceof DartProxy', o)) { 196 } else if (JS('bool', '# instanceof DartProxy', o)) {
193 return JS('var', '#.o', o); 197 return JS('var', '#.o', o);
194 } else { 198 } else {
195 return new JsObject._fromJs(JS('=Object', '#', o)); 199 return new JsObject._fromJs(JS('=Object', '#', o));
196 } 200 }
197 } 201 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698