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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2898183002: Prepare for development branch by updating externally-used API. (Closed)
Patch Set: Minor tweaks found during testing. Created 3 years, 7 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
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 52a818ca23ab742bf8c30c98fd4a1efae39090ab..42d3a59efa81f35d779ece3d562a0f71cce3c456 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -49,7 +49,7 @@ import '../../scanner/token.dart' show Token;
import '../scanner/token.dart'
show BeginGroupToken, isBinaryOperator, isMinusOperator;
-import '../errors.dart' show formatUnexpected, internalError;
+import '../errors.dart' show InputError, formatUnexpected, internalError;
import '../source/scope_listener.dart'
show JumpTargetKind, NullValue, ScopeListener;
@@ -305,6 +305,23 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
switchScope = outerSwitchScope;
}
+ void declareVariable(VariableDeclaration variable) {
+ InputError error = scope.declare(
+ variable.name,
+ new KernelVariableBuilder(
+ variable, member ?? classBuilder ?? library, uri),
+ variable.fileOffset,
+ uri);
+ if (error != null) {
+ addCompileTimeError(
+ variable.fileOffset,
+ "Can't declare '${variable.name}' because it was already used in "
+ "this scope.");
+ library.addCompileTimeError(error.charOffset, error.error,
+ fileUri: error.uri);
+ }
+ }
+
@override
JumpTarget createJumpTarget(JumpTargetKind kind, int charOffset) {
return new JumpTarget(kind, functionNestingLevel, member, charOffset);
@@ -1143,8 +1160,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
VariableDeclaration variable = pop();
variable.fileOffset = nameToken.charOffset;
push(variable);
- scope[variable.name] = new KernelVariableBuilder(
- variable, member ?? classBuilder ?? library, uri);
+ declareVariable(variable);
}
@override
@@ -2062,8 +2078,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
push(new KernelFunctionDeclaration(
variable, new FunctionNode(new InvalidStatement()))
..fileOffset = beginToken.charOffset);
- scope[variable.name] = new KernelVariableBuilder(
- variable, member ?? classBuilder ?? library, uri);
+ declareVariable(variable);
enterLocalScope();
}
@@ -2668,6 +2683,12 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
@override
+ void addCompileTimeErrorFromMessage(FastaMessage message) {
+ library.addCompileTimeError(message.charOffset, message.message,
+ fileUri: message.uri);
+ }
+
+ @override
void debugEvent(String name) {
// printEvent(name);
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/dill/dill_loader.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698