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

Unified Diff: sdk/lib/_internal/compiler/implementation/native_handler.dart

Issue 206193002: Remove cancel and make crash exit with code 253. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 9 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: sdk/lib/_internal/compiler/implementation/native_handler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/native_handler.dart b/sdk/lib/_internal/compiler/implementation/native_handler.dart
index 966c5b385f272d82821ac765b01b0f143a62bfff..38577c948c4b4d9eb72308141131e60468c9db0a 100644
--- a/sdk/lib/_internal/compiler/implementation/native_handler.dart
+++ b/sdk/lib/_internal/compiler/implementation/native_handler.dart
@@ -288,7 +288,8 @@ abstract class NativeEnqueuerBase implements NativeEnqueuer {
ClassElement find(name) {
Element e = compiler.findHelper(name);
if (e == null || e is! ClassElement) {
- compiler.cancel("Could not find implementation class '${name}'");
+ compiler.internalError(NO_LOCATION_SPANNABLE,
+ "Could not find implementation class '${name}'.");
}
return e;
}
@@ -315,7 +316,7 @@ abstract class NativeEnqueuerBase implements NativeEnqueuer {
// TODO(sra): Better validation of the constant.
if (fields.length != 1 || fields[0] is! StringConstant) {
PartialMetadataAnnotation partial = annotation;
- compiler.cancel(
+ compiler.internalError(annotation,
'Annotations needs one string: ${partial.parseNode(compiler)}');
}
String specString = fields[0].toDartString().slowToString();
@@ -323,7 +324,7 @@ abstract class NativeEnqueuerBase implements NativeEnqueuer {
name = specString;
} else {
PartialMetadataAnnotation partial = annotation;
- compiler.cancel(
+ compiler.internalError(annotation,
'Too many JSName annotations: ${partial.parseNode(compiler)}');
}
}
@@ -764,19 +765,19 @@ class NativeBehavior {
var argNodes = jsCall.arguments;
if (argNodes.isEmpty) {
- compiler.cancel("JS expression has no type", node: jsCall);
+ compiler.internalError(jsCall, "JS expression has no type.");
}
var code = argNodes.tail.head;
if (code is !StringNode || code.isInterpolation) {
- compiler.cancel('JS code must be a string literal', node: code);
+ compiler.internalError(code, 'JS code must be a string literal.');
}
LiteralString specLiteral = argNodes.head.asLiteralString();
if (specLiteral == null) {
// TODO(sra): We could accept a type identifier? e.g. JS(bool, '1<2'). It
// is not very satisfactory because it does not work for void, dynamic.
- compiler.cancel("Unexpected JS first argument", node: argNodes.head);
+ compiler.internalError(argNodes.head, "Unexpected JS first argument.");
}
var behavior = new NativeBehavior();
@@ -891,7 +892,7 @@ class NativeBehavior {
// TODO(sra): Better validation of the constant.
if (fields.length != 1 || fields[0] is! StringConstant) {
PartialMetadataAnnotation partial = annotation;
- compiler.cancel(
+ compiler.internalError(annotation,
'Annotations needs one string: ${partial.parseNode(compiler)}');
}
String specString = fields[0].toDartString().slowToString();
@@ -950,16 +951,18 @@ class NativeBehavior {
int index = typeString.indexOf('<');
if (index < 1) {
- compiler.cancel("Type '$typeString' not found",
- node: _errorNode(locationNodeOrElement, compiler));
+ compiler.internalError(
+ _errorNode(locationNodeOrElement, compiler),
+ "Type '$typeString' not found.");
}
type = lookup(typeString.substring(0, index));
if (type != null) {
// TODO(sra): Parse type parameters.
return type;
}
- compiler.cancel("Type '$typeString' not found",
- node: _errorNode(locationNodeOrElement, compiler));
+ compiler.internalError(
+ _errorNode(locationNodeOrElement, compiler),
+ "Type '$typeString' not found.");
}
static _errorNode(locationNodeOrElement, compiler) {
@@ -971,7 +974,7 @@ class NativeBehavior {
void checkAllowedLibrary(ElementListener listener, Token token) {
LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary();
if (!currentLibrary.canUseNative) {
- listener.recoverableError("Unexpected token", token: token);
+ listener.recoverableError(token, "Unexpected token");
}
}
@@ -1080,8 +1083,8 @@ void handleSsaNative(SsaBuilder builder, Expression nativeBody) {
LiteralString jsCode = nativeBody.asLiteralString();
String str = jsCode.dartString.slowToString();
if (nativeRedirectionRegExp.hasMatch(str)) {
- compiler.cancel("Deprecated syntax, use @JSName('name') instead.",
- node: nativeBody);
+ compiler.internalError(
+ nativeBody, "Deprecated syntax, use @JSName('name') instead.");
}
hasBody = true;
}
@@ -1120,8 +1123,8 @@ void handleSsaNative(SsaBuilder builder, Expression nativeBody) {
} else if (element.kind == ElementKind.SETTER) {
nativeMethodCall = '$receiver$nativeMethodName = $foreignParameters';
} else {
- builder.compiler.internalError('unexpected kind: "${element.kind}"',
- element: element);
+ builder.compiler.internalError(element,
+ 'Unexpected kind: "${element.kind}".');
}
builder.push(new HForeign(js.js(nativeMethodCall), backend.dynamicType,
@@ -1129,9 +1132,9 @@ void handleSsaNative(SsaBuilder builder, Expression nativeBody) {
builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit);
} else {
if (parameters.parameterCount != 0) {
- compiler.cancel(
- 'native "..." syntax is restricted to functions with zero parameters',
- node: nativeBody);
+ compiler.internalError(nativeBody,
+ 'native "..." syntax is restricted to '
+ 'functions with zero parameters.');
}
LiteralString jsCode = nativeBody.asLiteralString();
builder.push(new HForeign.statement(

Powered by Google App Engine
This is Rietveld 408576698