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

Side by Side Diff: runtime/vm/parser.cc

Issue 9240014: Set breakpoint at url, line number (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 } 2062 }
2063 SkipToMatchingParenthesis(); 2063 SkipToMatchingParenthesis();
2064 } else { 2064 } else {
2065 SkipInitializers(); 2065 SkipInitializers();
2066 } 2066 }
2067 } 2067 }
2068 2068
2069 // Only constructors can redirect to another method. 2069 // Only constructors can redirect to another method.
2070 ASSERT((method->redirect_name == NULL) || method->IsConstructor()); 2070 ASSERT((method->redirect_name == NULL) || method->IsConstructor());
2071 2071
2072 intptr_t method_end_pos = method_pos;
2072 if ((CurrentToken() == Token::kLBRACE) || 2073 if ((CurrentToken() == Token::kLBRACE) ||
2073 (CurrentToken() == Token::kARROW)) { 2074 (CurrentToken() == Token::kARROW)) {
2074 if (method->has_abstract) { 2075 if (method->has_abstract) {
2075 ErrorMsg(method->name_pos, 2076 ErrorMsg(method->name_pos,
2076 "abstract method '%s' may not have function body", 2077 "abstract method '%s' may not have function body",
2077 method->name->ToCString()); 2078 method->name->ToCString());
2078 } else if (method->IsConstructor() && method->has_const) { 2079 } else if (method->IsConstructor() && method->has_const) {
2079 ErrorMsg(method->name_pos, 2080 ErrorMsg(method->name_pos,
2080 "const constructor '%s' may not have function body", 2081 "const constructor '%s' may not have function body",
2081 method->name->ToCString()); 2082 method->name->ToCString());
2082 } else if (method->IsFactory() && method->has_const) { 2083 } else if (method->IsFactory() && method->has_const) {
2083 ErrorMsg(method->name_pos, 2084 ErrorMsg(method->name_pos,
2084 "const factory '%s' may not have function body", 2085 "const factory '%s' may not have function body",
2085 method->name->ToCString()); 2086 method->name->ToCString());
2086 } else if (members->is_interface()) { 2087 } else if (members->is_interface()) {
2087 ErrorMsg(method->name_pos, 2088 ErrorMsg(method->name_pos,
2088 "function body not allowed in interface declaration"); 2089 "function body not allowed in interface declaration");
2089 } 2090 }
2090 if (CurrentToken() == Token::kLBRACE) { 2091 if (CurrentToken() == Token::kLBRACE) {
2091 SkipBlock(); 2092 SkipBlock();
2092 } else { 2093 } else {
2093 ConsumeToken(); 2094 ConsumeToken();
2094 SkipExpr(); 2095 SkipExpr();
2095 ExpectSemicolon(); 2096 ExpectSemicolon();
2096 } 2097 }
2098 method_end_pos = token_index_;
2097 } else if (IsLiteral("native")) { 2099 } else if (IsLiteral("native")) {
2098 if (method->has_abstract) { 2100 if (method->has_abstract) {
2099 ErrorMsg(method->name_pos, 2101 ErrorMsg(method->name_pos,
2100 "abstract method '%s' may not have function body", 2102 "abstract method '%s' may not have function body",
2101 method->name->ToCString()); 2103 method->name->ToCString());
2102 } else if (members->is_interface()) { 2104 } else if (members->is_interface()) {
2103 ErrorMsg(method->name_pos, 2105 ErrorMsg(method->name_pos,
2104 "function body not allowed in interface declaration"); 2106 "function body not allowed in interface declaration");
2105 } else if (method->IsConstructor() && method->has_const) { 2107 } else if (method->IsConstructor() && method->has_const) {
2106 ErrorMsg(method->name_pos, 2108 ErrorMsg(method->name_pos,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 } else { 2146 } else {
2145 function_kind = RawFunction::kFunction; 2147 function_kind = RawFunction::kFunction;
2146 } 2148 }
2147 Function& func = Function::ZoneHandle( 2149 Function& func = Function::ZoneHandle(
2148 Function::New(*method->name, 2150 Function::New(*method->name,
2149 function_kind, 2151 function_kind,
2150 method->has_static, 2152 method->has_static,
2151 method->has_const, 2153 method->has_const,
2152 method_pos)); 2154 method_pos));
2153 func.set_result_type(*method->type); 2155 func.set_result_type(*method->type);
2156 func.set_end_token_index(method_end_pos);
2154 2157
2155 // No need to resolve parameter types yet, or add parameters to local scope. 2158 // No need to resolve parameter types yet, or add parameters to local scope.
2156 ASSERT(is_top_level_); 2159 ASSERT(is_top_level_);
2157 AddFormalParamsToFunction(&method->params, func); 2160 AddFormalParamsToFunction(&method->params, func);
2158 members->AddFunction(&func); 2161 members->AddFunction(&func);
2159 } 2162 }
2160 2163
2161 2164
2162 void Parser::ParseFieldDefinition(ClassDesc* members, MemberDesc* field) { 2165 void Parser::ParseFieldDefinition(ClassDesc* members, MemberDesc* field) {
2163 // The parser has read the first field name and is now at the token 2166 // The parser has read the first field name and is now at the token
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 } 3140 }
3138 3141
3139 if (CurrentToken() != Token::kLPAREN) { 3142 if (CurrentToken() != Token::kLPAREN) {
3140 ErrorMsg("'(' expected"); 3143 ErrorMsg("'(' expected");
3141 } 3144 }
3142 const intptr_t function_pos = token_index_; 3145 const intptr_t function_pos = token_index_;
3143 ParamList params; 3146 ParamList params;
3144 const bool allow_explicit_default_values = true; 3147 const bool allow_explicit_default_values = true;
3145 ParseFormalParameterList(allow_explicit_default_values, &params); 3148 ParseFormalParameterList(allow_explicit_default_values, &params);
3146 3149
3150 intptr_t function_end_pos = function_pos;
3147 if (CurrentToken() == Token::kLBRACE) { 3151 if (CurrentToken() == Token::kLBRACE) {
3148 SkipBlock(); 3152 SkipBlock();
3153 function_end_pos = token_index_;
3149 } else if (CurrentToken() == Token::kARROW) { 3154 } else if (CurrentToken() == Token::kARROW) {
3150 ConsumeToken(); 3155 ConsumeToken();
3151 SkipExpr(); 3156 SkipExpr();
3152 ExpectSemicolon(); 3157 ExpectSemicolon();
3158 function_end_pos = token_index_;
3153 } else if (IsLiteral("native")) { 3159 } else if (IsLiteral("native")) {
3154 ParseNativeDeclaration(); 3160 ParseNativeDeclaration();
3155 } else { 3161 } else {
3156 ErrorMsg("function block expected"); 3162 ErrorMsg("function block expected");
3157 } 3163 }
3158 Function& func = Function::ZoneHandle( 3164 Function& func = Function::ZoneHandle(
3159 Function::New(func_name, RawFunction::kFunction, 3165 Function::New(func_name, RawFunction::kFunction,
3160 is_static, false, function_pos)); 3166 is_static, false, function_pos));
3161 func.set_result_type(result_type); 3167 func.set_result_type(result_type);
3168 func.set_end_token_index(function_end_pos);
3162 AddFormalParamsToFunction(&params, func); 3169 AddFormalParamsToFunction(&params, func);
3163 top_level->functions.Add(&func); 3170 top_level->functions.Add(&func);
3164 library_.AddObject(func, func_name); 3171 library_.AddObject(func, func_name);
3165 } 3172 }
3166 3173
3167 3174
3168 void Parser::ParseTopLevelAccessor(TopLevel* top_level) { 3175 void Parser::ParseTopLevelAccessor(TopLevel* top_level) {
3169 const bool is_static = true; 3176 const bool is_static = true;
3170 AbstractType& result_type = AbstractType::Handle(); 3177 AbstractType& result_type = AbstractType::Handle();
3171 bool is_getter = (CurrentToken() == Token::kGET); 3178 bool is_getter = (CurrentToken() == Token::kGET);
(...skipping 4588 matching lines...) Expand 10 before | Expand all | Expand 10 after
7760 } 7767 }
7761 7768
7762 7769
7763 void Parser::SkipNestedExpr() { 7770 void Parser::SkipNestedExpr() {
7764 const bool saved_mode = SetAllowFunctionLiterals(true); 7771 const bool saved_mode = SetAllowFunctionLiterals(true);
7765 SkipExpr(); 7772 SkipExpr();
7766 SetAllowFunctionLiterals(saved_mode); 7773 SetAllowFunctionLiterals(saved_mode);
7767 } 7774 }
7768 7775
7769 } // namespace dart 7776 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698