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

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

Issue 3009733002: fix how DDC finds its undefined constant (Closed)
Patch Set: rebase and rebuild JS files Created 3 years, 4 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 | « no previous file | pkg/dev_compiler/test/codegen_expected/BenchmarkBase.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d6ac909321f79ac69e9b076bed80dd2fc2c04806..8c56a4bef6397a14ac745f0478274c472cc5d504 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -228,10 +228,7 @@ class CodeGenerator extends Object
functionClass = _getLibrary(c, 'dart:core').getType('Function'),
privateSymbolClass =
_getLibrary(c, 'dart:_internal').getType('PrivateSymbol'),
- dartJSLibrary = _getLibrary(c, 'dart:js'),
- _undefinedConstant =
- _getLibrary(c, 'dart:_runtime').publicNamespace.get('undefined') {
- assert(_undefinedConstant != null);
+ dartJSLibrary = _getLibrary(c, 'dart:js') {
typeRep = new JSTypeRep(rules, types);
}
@@ -2493,7 +2490,12 @@ class CodeGenerator extends Object
bool _isJSUndefined(Expression expr) {
expr = expr is AsExpression ? expr.expression : expr;
- return expr is Identifier && expr.staticElement == _undefinedConstant;
+ if (expr is Identifier) {
+ var element = expr.staticElement;
+ return isSdkInternalRuntime(element.library) &&
+ element.name == 'undefined';
+ }
+ return false;
}
JS.Fun _emitNativeFunctionBody(MethodDeclaration node) {
@@ -4139,7 +4141,7 @@ class CodeGenerator extends Object
for (var field in fields) {
// Skip our magic undefined constant.
var element = field.element as TopLevelVariableElement;
- if (element.getter == _undefinedConstant) continue;
+ if (element.name == 'undefined') continue;
_moduleItems.add(annotate(
js.statement('# = #;',
[_emitTopLevelName(field.element), _visitInitializer(field)]),
« no previous file with comments | « no previous file | pkg/dev_compiler/test/codegen_expected/BenchmarkBase.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698