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

Side by Side Diff: dart/sdk/lib/_internal/lib/js_helper.dart

Issue 16851002: Implement minified MirrorSystem.getName. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test Created 7 years, 6 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) 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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, 8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS,
9 JS, 9 JS,
10 JS_CALL_IN_ISOLATE, 10 JS_CALL_IN_ISOLATE,
11 JS_CURRENT_ISOLATE, 11 JS_CURRENT_ISOLATE,
12 JS_CURRENT_ISOLATE_CONTEXT, 12 JS_CURRENT_ISOLATE_CONTEXT,
13 JS_DART_OBJECT_CONSTRUCTOR, 13 JS_DART_OBJECT_CONSTRUCTOR,
14 JS_IS_INDEXABLE_FIELD_NAME, 14 JS_IS_INDEXABLE_FIELD_NAME,
15 JS_OBJECT_CLASS_NAME, 15 JS_OBJECT_CLASS_NAME,
16 JS_OPERATOR_AS_PREFIX, 16 JS_OPERATOR_AS_PREFIX,
17 JS_OPERATOR_IS_PREFIX, 17 JS_OPERATOR_IS_PREFIX,
18 RAW_DART_FUNCTION_REF; 18 RAW_DART_FUNCTION_REF;
19 import 'dart:_interceptors'; 19 import 'dart:_interceptors';
20 import "dart:_collection-dev" as _symbol_dev; 20 import 'dart:_collection-dev' as _symbol_dev;
21 import 'dart:_js_names' show mangledNames;
21 22
22 part 'constant_map.dart'; 23 part 'constant_map.dart';
23 part 'native_helper.dart'; 24 part 'native_helper.dart';
24 part 'regexp_helper.dart'; 25 part 'regexp_helper.dart';
25 part 'string_helper.dart'; 26 part 'string_helper.dart';
26 part 'js_rti.dart'; 27 part 'js_rti.dart';
27 28
28 bool isJsArray(var value) { 29 bool isJsArray(var value) {
29 return value != null && JS('bool', r'(#.constructor === Array)', value); 30 return value != null && JS('bool', r'(#.constructor === Array)', value);
30 } 31 }
(...skipping 18 matching lines...) Expand all
49 } else if (false == value) { 50 } else if (false == value) {
50 return 'false'; 51 return 'false';
51 } else if (value == null) { 52 } else if (value == null) {
52 return 'null'; 53 return 'null';
53 } 54 }
54 var res = value.toString(); 55 var res = value.toString();
55 if (res is !String) throw new ArgumentError(value); 56 if (res is !String) throw new ArgumentError(value);
56 return res; 57 return res;
57 } 58 }
58 59
59 createInvocationMirror(name, internalName, type, arguments, argumentNames) { 60 createInvocationMirror(String name, internalName, type, arguments,
60 return new JSInvocationMirror(new _symbol_dev.Symbol.unvalidated(name), 61 argumentNames) {
62 return new JSInvocationMirror(name,
61 internalName, 63 internalName,
62 type, 64 type,
63 arguments, 65 arguments,
66 argumentNames);
67 }
68
69 createUnmangledInvocationMirror(Symbol symbol, internalName, type, arguments,
70 argumentNames) {
71 return new JSInvocationMirror(symbol,
72 internalName,
73 type,
74 arguments,
64 argumentNames); 75 argumentNames);
65 } 76 }
66 77
67 class JSInvocationMirror implements Invocation { 78 class JSInvocationMirror implements Invocation {
68 static const METHOD = 0; 79 static const METHOD = 0;
69 static const GETTER = 1; 80 static const GETTER = 1;
70 static const SETTER = 2; 81 static const SETTER = 2;
71 82
72 final Symbol memberName; 83 /// When [_memberName] is a String, it holds the mangled name of this
84 /// invocation. When it is a Symbol, it holds the unmangled name.
85 var /* String or Symbol */ _memberName;
73 final String _internalName; 86 final String _internalName;
74 final int _kind; 87 final int _kind;
75 final List _arguments; 88 final List _arguments;
76 final List _namedArgumentNames; 89 final List _namedArgumentNames;
77 /** Map from argument name to index in _arguments. */ 90 /** Map from argument name to index in _arguments. */
78 Map<String,dynamic> _namedIndices = null; 91 Map<String,dynamic> _namedIndices = null;
79 92
80 JSInvocationMirror(this.memberName, 93 JSInvocationMirror(this._memberName,
81 this._internalName, 94 this._internalName,
82 this._kind, 95 this._kind,
83 this._arguments, 96 this._arguments,
84 this._namedArgumentNames); 97 this._namedArgumentNames);
85 98
99 Symbol get memberName {
100 if (_memberName is Symbol) return _memberName;
101 String name = _memberName;
102 String unmangledName = mangledNames[name];
103 if (unmangledName != null) {
104 name = unmangledName.split(':')[0];
105 }
106 _memberName = new _symbol_dev.Symbol.unvalidated(name);
107 return _memberName;
108 }
109
86 bool get isMethod => _kind == METHOD; 110 bool get isMethod => _kind == METHOD;
87 bool get isGetter => _kind == GETTER; 111 bool get isGetter => _kind == GETTER;
88 bool get isSetter => _kind == SETTER; 112 bool get isSetter => _kind == SETTER;
89 bool get isAccessor => _kind != METHOD; 113 bool get isAccessor => _kind != METHOD;
90 114
91 List get positionalArguments { 115 List get positionalArguments {
92 if (isGetter) return null; 116 if (isGetter) return null;
93 var list = []; 117 var list = [];
94 var argumentCount = 118 var argumentCount =
95 _arguments.length - _namedArgumentNames.length; 119 _arguments.length - _namedArgumentNames.length;
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 } 1473 }
1450 1474
1451 /** 1475 /**
1452 * Error thrown when a runtime error occurs. 1476 * Error thrown when a runtime error occurs.
1453 */ 1477 */
1454 class RuntimeError implements Error { 1478 class RuntimeError implements Error {
1455 final message; 1479 final message;
1456 RuntimeError(this.message); 1480 RuntimeError(this.message);
1457 String toString() => "RuntimeError: $message"; 1481 String toString() => "RuntimeError: $message";
1458 } 1482 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698