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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2985333002: fix #30290, assertion messages that contain `yield` (Closed)
Patch Set: merge and update status 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 unified diff | Download patch
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test-main.js » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 3939 matching lines...) Expand 10 before | Expand all | Expand 10 after
3950 JS.EmptyStatement visitEmptyStatement(EmptyStatement node) => 3950 JS.EmptyStatement visitEmptyStatement(EmptyStatement node) =>
3951 new JS.EmptyStatement(); 3951 new JS.EmptyStatement();
3952 3952
3953 @override 3953 @override
3954 JS.Statement visitAssertStatement(AssertStatement node) { 3954 JS.Statement visitAssertStatement(AssertStatement node) {
3955 // TODO(jmesserly): only emit in checked mode. 3955 // TODO(jmesserly): only emit in checked mode.
3956 var condition = node.condition; 3956 var condition = node.condition;
3957 var conditionType = condition.staticType; 3957 var conditionType = condition.staticType;
3958 JS.Expression jsCondition = _visit(condition); 3958 JS.Expression jsCondition = _visit(condition);
3959 3959
3960 var assertHelper = 'assert';
3961 if (conditionType is FunctionType && 3960 if (conditionType is FunctionType &&
3962 conditionType.parameters.isEmpty && 3961 conditionType.parameters.isEmpty &&
3963 conditionType.returnType == types.boolType) { 3962 conditionType.returnType == types.boolType) {
3964 jsCondition = new JS.Call(jsCondition, []); 3963 jsCondition = _callHelper('test(#())', jsCondition);
3965 } else if (conditionType != types.boolType) { 3964 } else if (conditionType != types.boolType) {
3966 assertHelper = 'dassert'; 3965 jsCondition = _callHelper('dassert(#)', jsCondition);
3966 } else if (isNullable(condition)) {
3967 jsCondition = _callHelper('test(#)', jsCondition);
3967 } 3968 }
3968 var args = [jsCondition]; 3969 return js.statement(' if (!#) #.assertFailed(#);', [
3969 if (node.message != null) { 3970 jsCondition,
3970 args.add(js.call('() => #', [_visit(node.message)])); 3971 _runtimeModule,
3971 } 3972 node.message != null ? [_visit(node.message)] : []
3972 return _callHelperStatement('$assertHelper(#);', [args]); 3973 ]);
3973 } 3974 }
3974 3975
3975 @override 3976 @override
3976 JS.Statement visitReturnStatement(ReturnStatement node) { 3977 JS.Statement visitReturnStatement(ReturnStatement node) {
3977 var e = node.expression; 3978 var e = node.expression;
3978 if (e == null) return new JS.Return(); 3979 if (e == null) return new JS.Return();
3979 return _visit<JS.Expression>(e).toReturn(); 3980 return _visit<JS.Expression>(e).toReturn();
3980 } 3981 }
3981 3982
3982 @override 3983 @override
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 if (targetIdentifier.staticElement is! PrefixElement) return false; 5975 if (targetIdentifier.staticElement is! PrefixElement) return false;
5975 var prefix = targetIdentifier.staticElement as PrefixElement; 5976 var prefix = targetIdentifier.staticElement as PrefixElement;
5976 5977
5977 // The library the prefix is referring to must come from a deferred import. 5978 // The library the prefix is referring to must come from a deferred import.
5978 var containingLibrary = resolutionMap 5979 var containingLibrary = resolutionMap
5979 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 5980 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
5980 .library; 5981 .library;
5981 var imports = containingLibrary.getImportsWithPrefix(prefix); 5982 var imports = containingLibrary.getImportsWithPrefix(prefix);
5982 return imports.length == 1 && imports[0].isDeferred; 5983 return imports.length == 1 && imports[0].isDeferred;
5983 } 5984 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test-main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698