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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2535273002: Better mirrors support for mixins and private fields (Closed)
Patch Set: Address comments Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 361f5ec0198127d03ab3f0f684ebeaa356228e5d..9bc283942e440cc52660be88e65e4049721f2f78 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -124,6 +124,7 @@ class CodeGenerator extends GeneralizingAstVisitor
final ClassElement numClass;
final ClassElement objectClass;
final ClassElement stringClass;
+ final ClassElement symbolClass;
ConstFieldVisitor _constants;
@@ -164,6 +165,7 @@ class CodeGenerator extends GeneralizingAstVisitor
nullClass = _getLibrary(c, 'dart:core').getType('Null'),
objectClass = _getLibrary(c, 'dart:core').getType('Object'),
stringClass = _getLibrary(c, 'dart:core').getType('String'),
+ symbolClass = _getLibrary(c, 'dart:_internal').getType('Symbol'),
dartJSLibrary = _getLibrary(c, 'dart:js');
LibraryElement get currentLibrary => _loader.currentElement.library;
@@ -5192,11 +5194,17 @@ class CodeGenerator extends GeneralizingAstVisitor
@override
visitSymbolLiteral(SymbolLiteral node) {
JS.Expression emitSymbol() {
- // TODO(vsm): When we canonicalize, we need to treat private symbols
- // correctly.
+ // TODO(vsm): Handle qualified symbols correctly.
+ var last = node.components.last.toString();
var name = js.string(node.components.join('.'), "'");
- return js
- .call('#.new(#)', [_emitConstructorAccess(types.symbolType), name]);
+ if (last.startsWith('_')) {
+ var nativeSymbol = _emitPrivateNameSymbol(currentLibrary, last);
+ return js.call('new #.es6(#, #)',
+ [_emitConstructorAccess(symbolClass.type), name, nativeSymbol]);
+ } else {
+ return js
+ .call('#.new(#)', [_emitConstructorAccess(types.symbolType), name]);
+ }
}
return _emitConst(emitSymbol);
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test/codegen/lib/mirrors/mixin_simple_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698