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

Unified Diff: pkg/kernel/lib/analyzer/ast_from_analyzer.dart

Issue 2641523002: Fix some crashes in dartk. (Closed)
Patch Set: Mark main as static, update status files again Created 3 years, 11 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/kernel/lib/analyzer/loader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/analyzer/ast_from_analyzer.dart
diff --git a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
index 034decdcc4abdbdb4be84669cdc9658bccf4f7d2..88efc20918f323b9e82b694e15bb9c0543a404a6 100644
--- a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
+++ b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
@@ -754,11 +754,14 @@ class ExpressionScope extends TypeScope {
return new ast.Throw(new ast.StringLiteral(message));
}
+ ast.Expression buildThrowCompileTimeErrorFromCode(ErrorCode code,
+ [List arguments]) {
+ return buildThrowCompileTimeError(makeErrorMessage(code, arguments));
+ }
+
static final RegExp _errorMessagePattern = new RegExp(r'\{(\d+)\}');
- /// Throws an exception that will be caught at the function level, to replace
- /// the entire function with a throw.
- emitCompileTimeError(ErrorCode error, [List arguments]) {
+ String makeErrorMessage(ErrorCode error, [List arguments]) {
String message = error.message;
if (arguments != null) {
message = message.replaceAllMapped(_errorMessagePattern, (m) {
@@ -767,7 +770,13 @@ class ExpressionScope extends TypeScope {
return arguments[index];
});
}
- throw new _CompilationError(message);
+ return message;
+ }
+
+ /// Throws an exception that will be caught at the function level, to replace
+ /// the entire function with a throw.
+ emitCompileTimeError(ErrorCode error, [List arguments]) {
+ throw new _CompilationError(makeErrorMessage(error, arguments));
}
ast.Expression buildThrowAbstractClassInstantiationError(String name) {
@@ -1693,6 +1702,9 @@ class ExpressionBuilder
if (isTopLevelFunction(function)) {
return scope.staticAccess(node.name, function);
}
+ if (function == function.library.loadLibraryFunction) {
+ return scope.unsupportedFeature('Deferred loading');
+ }
return new VariableAccessor(scope.getVariableReference(function));
case ElementKind.LOCAL_VARIABLE:
@@ -2737,9 +2749,18 @@ class MemberBodyBuilder extends GeneralizingAstVisitor<Null> {
}
for (var parameter in node.parameters.parameterElements) {
if (parameter is FieldFormalParameterElement) {
- var initializer = new ast.FieldInitializer(
- scope.getMemberReference(parameter.field),
- new ast.VariableGet(scope.getVariableReference(parameter)));
+ ast.Initializer initializer;
+ if (parameter.field == null) {
+ initializer = new ast.LocalInitializer(
+ new ast.VariableDeclaration.forValue(scope
+ .buildThrowCompileTimeErrorFromCode(
+ CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD,
+ [parameter.name])));
+ } else {
+ initializer = new ast.FieldInitializer(
+ scope.getMemberReference(parameter.field),
+ new ast.VariableGet(scope.getVariableReference(parameter)));
+ }
constructor.initializers.add(initializer..parent = constructor);
}
}
« no previous file with comments | « no previous file | pkg/kernel/lib/analyzer/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698