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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1111863002: fix static members in _emitMemberName (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: catch more cases 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/runtime/dart/typed_data.js ('k') | test/codegen/expect/names.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index f8724d4a0e69c1f0b6467f55e78b2726ba354b71..1a425e0ad0c66693d8739622d8395f16f2b3ddba 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -1277,7 +1277,9 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
var type = getStaticType(target);
var name = node.methodName.name;
- var memberName = _emitMemberName(name, type: type);
+ var element = node.methodName.staticElement;
+ bool isStatic = element is ExecutableElement && element.isStatic;
+ var memberName = _emitMemberName(name, type: type, isStatic: isStatic);
if (rules.isDynamicTarget(target)) {
code = 'dart.$DSEND(#, #, #)';
@@ -1904,13 +1906,15 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
/// Shared code for [PrefixedIdentifier] and [PropertyAccess].
JS.Expression _emitGet(Expression target, SimpleIdentifier memberId) {
- var name = _emitMemberName(memberId.name, type: getStaticType(target));
+ var member = memberId.staticElement;
+ bool isStatic = member is ExecutableElement && member.isStatic;
+ var name = _emitMemberName(memberId.name,
+ type: getStaticType(target), isStatic: isStatic);
if (rules.isDynamicTarget(target)) {
return js.call('dart.$DLOAD(#, #)', [_visit(target), name]);
}
String code;
- var member = memberId.staticElement;
if (member != null && member is MethodElement) {
// Tear-off methods: explicitly bind it.
if (_requiresStaticDispatch(target, memberId.name)) {
@@ -2358,6 +2362,20 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
///
JS.Expression _emitMemberName(String name,
{DartType type, bool unary: false, bool isStatic: false}) {
+
+ // Static methods skip most of the rename steps.
+ if (isStatic) {
+ if (invalidJSStaticMethodName(name)) {
+ // Choose an string name. Use an invalid identifier so it won't conflict
+ // with any valid member names.
+ // TODO(jmesserly): this works around the problem, but I'm pretty sure we
+ // don't need it, as static methods seemed to work. The only concrete
+ // issue we saw was in the defineNamedConstructor helper function.
+ name = '$name*';
+ }
+ return _propertyName(name);
+ }
+
if (name.startsWith('_')) {
return _privateNames.putIfAbsent(
name, () => _initSymbol(new JSTemporary(name)));
@@ -2374,15 +2392,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
name = 'unary-';
}
- if (isStatic && invalidJSStaticMethodName(name)) {
- // Choose an string name. Use an invalid identifier so it won't conflict
- // with any valid member names.
- // TODO(jmesserly): this works around the problem, but I'm pretty sure we
- // don't need it, as static methods seemed to work. The only concrete
- // issue we saw was in the defineNamedConstructor helper function.
- name = '$name*';
- }
-
if (extLibrary != null) {
return _extensionMethodName(name, extLibrary);
}
« no previous file with comments | « lib/runtime/dart/typed_data.js ('k') | test/codegen/expect/names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698