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

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

Issue 2695633002: Annotate native methods. (Closed)
Patch Set: Created 3 years, 10 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 a2357c1f0e2f243468e1271137e1a70a9301ca25..8495c24321e885353df65271b8835f713824ebc9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -146,10 +146,6 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
CloneVisitor cloner;
- /// Set to true each time we parse a native function body. It is reset in
- /// [handleInvalidFunctionBody] which is called immediately after.
- bool lastErrorWasNativeFunctionBody = false;
-
BodyBuilder(KernelLibraryBuilder library, this.member, Scope scope,
this.formalParameterScope, this.hierarchy, this.coreTypes,
this.classBuilder, this.isInstanceMember)
@@ -2171,10 +2167,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) {
if (isDartLibrary && kind == ErrorKind.ExpectedFunctionBody) {
Token recover = skipNativeClause(token);
- if (recover != null) {
- buildNative(unescapeString(token.next.value));
- return recover;
- }
+ if (recover != null) return recover;
} else if (kind == ErrorKind.UnexpectedToken) {
String expected = arguments["expected"];
const List<String> trailing = const <String>[")", "}", ";", ","];
@@ -2244,26 +2237,11 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
@override
void handleInvalidFunctionBody(Token token) {
- if (!lastErrorWasNativeFunctionBody) {
+ if (member.isNative) {
+ push(NullValue.FunctionBody);
+ } else {
push(new Block(<Statement>[new InvalidStatement()]));
}
- lastErrorWasNativeFunctionBody = false;
- }
-
- void buildNative(String native) {
- lastErrorWasNativeFunctionBody = true;
-
- // From dartk:
- //
- // currentMember.isExternal = true;
- // currentMember.addAnnotation(new ast.ConstructorInvocation(
- // scope.loader.getCoreClassConstructorReference('ExternalName',
- // library: 'dart:_internal'),
- // new ast.Arguments(<ast.Expression>[
- // new ast.StringLiteral(body.stringLiteral.stringValue)
- // ]),
- // isConst: true));
- push(new Block(<Statement>[new InvalidStatement()]));
}
@override

Powered by Google App Engine
This is Rietveld 408576698