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

Unified Diff: dart/lib/compiler/implementation/compile_time_constants.dart

Issue 10389143: Add locations to diagnostics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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: dart/lib/compiler/implementation/compile_time_constants.dart
diff --git a/dart/lib/compiler/implementation/compile_time_constants.dart b/dart/lib/compiler/implementation/compile_time_constants.dart
index bda8c7dc414fd42fd12e67b1ce7593e8f8c1425f..62765c1a82a91a6ba67a4d82112a1a2ebedd7169 100644
--- a/dart/lib/compiler/implementation/compile_time_constants.dart
+++ b/dart/lib/compiler/implementation/compile_time_constants.dart
@@ -225,8 +225,9 @@ class FalseConstant extends BoolConstant {
class StringConstant extends PrimitiveConstant {
final DartString value;
int _hashCode;
+ final Node node;
- StringConstant(this.value) {
+ StringConstant(this.value, this.node) {
// TODO(floitsch): cache StringConstants.
// TODO(floitsch): compute hashcode without calling toString() on the
// DartString.
@@ -237,7 +238,7 @@ class StringConstant extends PrimitiveConstant {
void _writeJsCode(StringBuffer buffer, ConstantHandler handler) {
buffer.add("'");
ConstantHandler.writeEscapedString(value, buffer, (reason) {
- throw new CompilerCancelledException(reason);
+ handler.compiler.reportError(node, reason);
});
buffer.add("'");
}
@@ -784,13 +785,14 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
}
Constant visitLiteralString(LiteralString node) {
- return new StringConstant(node.dartString);
+ return new StringConstant(node.dartString, node);
}
Constant visitStringJuxtaposition(StringJuxtaposition node) {
StringConstant left = evaluate(node.first);
StringConstant right = evaluate(node.second);
- return new StringConstant(new DartString.concat(left.value, right.value));
+ return new StringConstant(new DartString.concat(left.value, right.value),
+ node);
}
Constant visitStringInterpolation(StringInterpolation node) {
@@ -812,7 +814,7 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
StringConstant partString = evaluate(part.string);
accumulator = new DartString.concat(accumulator, partString.value);
};
- return new StringConstant(accumulator);
+ return new StringConstant(accumulator, node);
}
// TODO(floitsch): provide better error-messages.
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/compiler.dart » ('j') | dart/lib/compiler/implementation/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698