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

Unified Diff: runtime/vm/parser.cc

Issue 23038010: Fix Function.end_token_pos() and implement MethodMirror.source getter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 years, 4 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 | « runtime/vm/intrinsifier.h ('k') | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index cdbb608d1729ed1a7abd922490c2eb521dceb5b2..6e65ac8ef8c25c4ff889007900cb9b88754cfb24 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -1591,7 +1591,6 @@ String& Parser::ParseNativeDeclaration() {
}
String& native_name = *CurrentLiteral();
ConsumeToken();
- ExpectSemicolon();
return native_name;
}
@@ -2749,9 +2748,11 @@ SequenceNode* Parser::ParseFunc(const Function& func,
}
OpenBlock(); // Open a nested scope for the outermost function block.
+ intptr_t end_token_pos = 0;
if (CurrentToken() == Token::kLBRACE) {
ConsumeToken();
ParseStatementSequence();
+ end_token_pos = TokenPos();
ExpectToken(Token::kRBRACE);
} else if (CurrentToken() == Token::kARROW) {
ConsumeToken();
@@ -2759,8 +2760,11 @@ SequenceNode* Parser::ParseFunc(const Function& func,
AstNode* expr = ParseExpr(kAllowConst, kConsumeCascades);
ASSERT(expr != NULL);
current_block_->statements->Add(new ReturnNode(expr_pos, expr));
+ end_token_pos = TokenPos();
} else if (IsLiteral("native")) {
ParseNativeFunctionBlock(&params, func);
+ end_token_pos = TokenPos();
+ ExpectSemicolon();
} else if (func.is_external()) {
// Body of an external method contains a single throw.
const String& function_name = String::ZoneHandle(func.name());
@@ -2774,9 +2778,13 @@ SequenceNode* Parser::ParseFunc(const Function& func,
InvocationMirror::kStatic :
InvocationMirror::kDynamic,
InvocationMirror::kMethod));
+ end_token_pos = TokenPos();
} else {
UnexpectedToken();
}
+ ASSERT(func.end_token_pos() == func.token_pos() ||
+ func.end_token_pos() == end_token_pos);
+ func.set_end_token_pos(end_token_pos);
SequenceNode* body = CloseBlock();
current_block_->statements->Add(body);
innermost_function_ = saved_innermost_function.raw();
@@ -3075,6 +3083,8 @@ void Parser::ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method) {
"Constructor with redirection may not have a function body");
}
ParseNativeDeclaration();
+ method_end_pos = TokenPos();
+ ExpectSemicolon();
} else {
// We haven't found a method body. Issue error if one is required.
const bool must_have_body =
@@ -4424,6 +4434,7 @@ void Parser::ParseTopLevelFunction(TopLevel* top_level,
intptr_t function_end_pos = function_pos;
if (is_external) {
+ function_end_pos = TokenPos();
ExpectSemicolon();
} else if (CurrentToken() == Token::kLBRACE) {
SkipBlock();
@@ -4431,10 +4442,12 @@ void Parser::ParseTopLevelFunction(TopLevel* top_level,
} else if (CurrentToken() == Token::kARROW) {
ConsumeToken();
SkipExpr();
+ function_end_pos = TokenPos();
ExpectSemicolon();
- function_end_pos = TokenPos() - 1;
} else if (IsLiteral("native")) {
ParseNativeDeclaration();
+ function_end_pos = TokenPos();
+ ExpectSemicolon();
} else {
ErrorMsg("function block expected");
}
@@ -4549,6 +4562,7 @@ void Parser::ParseTopLevelAccessor(TopLevel* top_level,
intptr_t accessor_end_pos = accessor_pos;
if (is_external) {
+ accessor_end_pos = TokenPos();
ExpectSemicolon();
} else if (CurrentToken() == Token::kLBRACE) {
SkipBlock();
@@ -4556,10 +4570,12 @@ void Parser::ParseTopLevelAccessor(TopLevel* top_level,
} else if (CurrentToken() == Token::kARROW) {
ConsumeToken();
SkipExpr();
+ accessor_end_pos = TokenPos();
ExpectSemicolon();
- accessor_end_pos = TokenPos() - 1;
} else if (IsLiteral("native")) {
ParseNativeDeclaration();
+ accessor_end_pos = TokenPos();
+ ExpectSemicolon();
} else {
ErrorMsg("function block expected");
}
@@ -5365,8 +5381,6 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) {
Array& default_parameter_values = Array::Handle();
SequenceNode* statements = Parser::ParseFunc(function,
default_parameter_values);
- ASSERT(is_new_closure || (function.end_token_pos() == (TokenPos() - 1)));
- function.set_end_token_pos(TokenPos() - 1);
// Now that the local function has formal parameters, lookup the signature
// class in the current library (but not in its imports) and only create a new
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698