Index: vm/parser.cc |
=================================================================== |
--- vm/parser.cc (revision 8936) |
+++ vm/parser.cc (working copy) |
@@ -80,7 +80,7 @@ |
int TraceParser::indent_ = 0; |
#define TRACE_PARSER(s) \ |
- TraceParser __p__(this->token_index_, this->script_, s) |
+ TraceParser __p__(this->TokenIndex(), this->script_, s) |
#else // not DEBUG |
#define TRACE_PARSER(s) |
@@ -196,6 +196,31 @@ |
} |
+bool TokenStreamIterator::IsNull() const { |
+ return tokens_.IsNull(); |
+} |
+ |
+ |
+Token::Kind TokenStreamIterator::CurrentTokenKind() const { |
+ return tokens_.KindAt(token_index_); |
+} |
+ |
+ |
+Token::Kind TokenStreamIterator::LookaheadTokenKind(intptr_t num_tokens) const { |
+ return tokens_.KindAt(token_index_ + num_tokens); |
+} |
+ |
+ |
+RawObject* TokenStreamIterator::CurrentToken() const { |
+ return tokens_.TokenAt(token_index_); |
+} |
+ |
+ |
+RawString* TokenStreamIterator::CurrentLiteral() const { |
+ return tokens_.LiteralAt(token_index_); |
+} |
+ |
+ |
struct Parser::Block : public ZoneAllocated { |
Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
: parent(outer_block), scope(local_scope), statements(seq) { |
@@ -247,8 +272,8 @@ |
Parser::Parser(const Script& script, |
const Library& library) |
: script_(script), |
- tokens_(TokenStream::Handle(script.tokens())), |
- token_index_(0), |
+ tokens_iterator_(TokenStream::Handle(script.tokens()), 0), |
+ token_kind_(Token::kILLEGAL), |
current_block_(NULL), |
is_top_level_(false), |
current_member_(NULL), |
@@ -258,9 +283,8 @@ |
library_(library), |
try_blocks_list_(NULL), |
expression_temp_(NULL) { |
- ASSERT(!tokens_.IsNull()); |
+ ASSERT(!tokens_iterator_.IsNull()); |
ASSERT(!library.IsNull()); |
- SetPosition(0); |
} |
@@ -269,8 +293,8 @@ |
const Function& function, |
intptr_t token_index) |
: script_(script), |
- tokens_(TokenStream::Handle(script.tokens())), |
- token_index_(0), |
+ tokens_iterator_(TokenStream::Handle(script.tokens()), token_index), |
+ token_kind_(Token::kILLEGAL), |
current_block_(NULL), |
is_top_level_(false), |
current_member_(NULL), |
@@ -280,9 +304,8 @@ |
library_(Library::Handle(current_class_.library())), |
try_blocks_list_(NULL), |
expression_temp_(NULL) { |
- ASSERT(!tokens_.IsNull()); |
+ ASSERT(!tokens_iterator_.IsNull()); |
ASSERT(!function.IsNull()); |
- SetPosition(token_index); |
if (FLAG_enable_type_checks) { |
EnsureExpressionTemp(); |
} |
@@ -312,10 +335,10 @@ |
void Parser::SetPosition(intptr_t position) { |
- if (position < token_index_ && position != 0) { |
- CompilerStats::num_tokens_rewind += (token_index_ - position); |
+ if (position < TokenIndex() && position != 0) { |
+ CompilerStats::num_tokens_rewind += (TokenIndex() - position); |
} |
- token_index_ = position; |
+ tokens_iterator_.SetCurrentIndex(position); |
token_kind_ = Token::kILLEGAL; |
} |
@@ -327,16 +350,16 @@ |
Parser parser(script, library); |
parser.ParseTopLevel(); |
if (FLAG_compiler_stats) { |
- CompilerStats::num_tokens_total += parser.tokens_.Length(); |
hausner
2012/06/22 00:02:27
The number of tokens will not be equivalent to the
siva
2012/06/22 17:59:02
Changed name Length() to NumberOfTokens() in the s
|
+ CompilerStats::num_tokens_total += parser.tokens_iterator_.Length(); |
} |
} |
Token::Kind Parser::CurrentToken() { |
if (token_kind_ == Token::kILLEGAL) { |
- token_kind_ = tokens_.KindAt(token_index_); |
+ token_kind_ = tokens_iterator_.CurrentTokenKind(); |
if (token_kind_ == Token::kERROR) { |
- ErrorMsg(token_index_, CurrentLiteral()->ToCString()); |
+ ErrorMsg(TokenIndex(), CurrentLiteral()->ToCString()); |
} |
} |
CompilerStats::num_token_checks++; |
@@ -347,20 +370,20 @@ |
Token::Kind Parser::LookaheadToken(int num_tokens) { |
CompilerStats::num_tokens_lookahead++; |
CompilerStats::num_token_checks++; |
- return tokens_.KindAt(token_index_ + num_tokens); |
+ return tokens_iterator_.LookaheadTokenKind(num_tokens); |
} |
String* Parser::CurrentLiteral() const { |
String& result = String::ZoneHandle(); |
- result ^= tokens_.LiteralAt(token_index_); |
+ result ^= tokens_iterator_.CurrentLiteral(); |
return &result; |
} |
RawDouble* Parser::CurrentDoubleLiteral() const { |
LiteralToken& token = LiteralToken::Handle(); |
- token ^= tokens_.TokenAt(token_index_); |
+ token ^= tokens_iterator_.CurrentToken(); |
ASSERT(token.kind() == Token::kDOUBLE); |
return reinterpret_cast<RawDouble*>(token.value()); |
} |
@@ -368,7 +391,7 @@ |
RawInteger* Parser::CurrentIntegerLiteral() const { |
LiteralToken& token = LiteralToken::Handle(); |
- token ^= tokens_.TokenAt(token_index_); |
+ token ^= tokens_iterator_.CurrentToken(); |
ASSERT(token.kind() == Token::kINTEGER); |
return reinterpret_cast<RawInteger*>(token.value()); |
} |
@@ -704,7 +727,7 @@ |
if (!HasReturnNode(node_sequence)) { |
// Add implicit return node. |
- node_sequence->Add(new ReturnNode(parser.token_index_)); |
+ node_sequence->Add(new ReturnNode(parser.TokenIndex())); |
} |
if (parser.expression_temp_ != NULL) { |
parsed_function->set_expression_temp_var(parser.expression_temp_); |
@@ -764,14 +787,14 @@ |
// fragment to evaluate the expression. Instead, we just make sure |
// the static const field initializer is a constant expression and |
// leave the evaluation to the getter function. |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
AstNode* expr = ParseExpr(kAllowConst); |
if (field.is_const()) { |
// This getter will only be called once at compile time. |
if (expr->EvalConstExpr() == NULL) { |
ErrorMsg(expr_pos, "initializer must be a compile time constant"); |
} |
- ReturnNode* return_node = new ReturnNode(token_index_, expr); |
+ ReturnNode* return_node = new ReturnNode(TokenIndex(), expr); |
current_block_->statements->Add(return_node); |
} else { |
// This getter may be called each time the static field is accessed. |
@@ -793,55 +816,55 @@ |
// Generate code checking for circular dependency in field initialization. |
AstNode* compare_circular = new ComparisonNode( |
- token_index_, |
+ TokenIndex(), |
Token::kEQ_STRICT, |
- new LoadStaticFieldNode(token_index_, field), |
- new LiteralNode(token_index_, |
+ new LoadStaticFieldNode(TokenIndex(), field), |
+ new LiteralNode(TokenIndex(), |
Instance::ZoneHandle(Object::transition_sentinel()))); |
// Set field to null prior to throwing exception, so that subsequent |
// accesses to the field do not throw again, since initializers should only |
// be executed once. |
- SequenceNode* report_circular = new SequenceNode(token_index_, NULL); |
+ SequenceNode* report_circular = new SequenceNode(TokenIndex(), NULL); |
report_circular->Add( |
new StoreStaticFieldNode( |
- token_index_, |
+ TokenIndex(), |
field, |
- new LiteralNode(token_index_, Instance::ZoneHandle()))); |
+ new LiteralNode(TokenIndex(), Instance::ZoneHandle()))); |
// TODO(regis): Exception to throw is not specified by spec. |
const String& circular_error = String::ZoneHandle( |
String::NewSymbol("circular dependency in field initialization")); |
report_circular->Add( |
- new ThrowNode(token_index_, |
- new LiteralNode(token_index_, circular_error), |
+ new ThrowNode(TokenIndex(), |
+ new LiteralNode(TokenIndex(), circular_error), |
NULL)); |
AstNode* circular_check = |
- new IfNode(token_index_, compare_circular, report_circular, NULL); |
+ new IfNode(TokenIndex(), compare_circular, report_circular, NULL); |
current_block_->statements->Add(circular_check); |
// Generate code checking for uninitialized field. |
AstNode* compare_uninitialized = new ComparisonNode( |
- token_index_, |
+ TokenIndex(), |
Token::kEQ_STRICT, |
- new LoadStaticFieldNode(token_index_, field), |
- new LiteralNode(token_index_, |
+ new LoadStaticFieldNode(TokenIndex(), field), |
+ new LiteralNode(TokenIndex(), |
Instance::ZoneHandle(Object::sentinel()))); |
- SequenceNode* initialize_field = new SequenceNode(token_index_, NULL); |
+ SequenceNode* initialize_field = new SequenceNode(TokenIndex(), NULL); |
initialize_field->Add( |
new StoreStaticFieldNode( |
- token_index_, |
+ TokenIndex(), |
field, |
new LiteralNode( |
- token_index_, |
+ TokenIndex(), |
Instance::ZoneHandle(Object::transition_sentinel())))); |
- initialize_field->Add(new StoreStaticFieldNode(token_index_, field, expr)); |
+ initialize_field->Add(new StoreStaticFieldNode(TokenIndex(), field, expr)); |
AstNode* uninitialized_check = |
- new IfNode(token_index_, compare_uninitialized, initialize_field, NULL); |
+ new IfNode(TokenIndex(), compare_uninitialized, initialize_field, NULL); |
current_block_->statements->Add(uninitialized_check); |
// Generate code returning the field value. |
ReturnNode* return_node = |
- new ReturnNode(token_index_, |
- new LoadStaticFieldNode(token_index_, field)); |
+ new ReturnNode(TokenIndex(), |
+ new LoadStaticFieldNode(TokenIndex(), field)); |
current_block_->statements->Add(return_node); |
} |
return CloseBlock(); |
@@ -855,7 +878,7 @@ |
SequenceNode* Parser::ParseInstanceGetter(const Function& func) { |
TRACE_PARSER("ParseInstanceGetter"); |
ParamList params; |
- params.AddReceiver(token_index_); |
+ params.AddReceiver(TokenIndex()); |
ASSERT(func.num_fixed_parameters() == 1); // receiver. |
ASSERT(func.num_optional_parameters() == 0); |
ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
@@ -866,9 +889,9 @@ |
// Receiver is local 0. |
LocalVariable* receiver = current_block_->scope->VariableAt(0); |
- LoadLocalNode* load_receiver = new LoadLocalNode(token_index_, *receiver); |
- // token_index_ is the function's token position which points to the name of |
- // the field; |
+ LoadLocalNode* load_receiver = new LoadLocalNode(TokenIndex(), *receiver); |
+ // TokenIndex() returns the function's token position which points to the |
+ // name of the field; |
ASSERT(IsIdentifier()); |
const String& field_name = *CurrentLiteral(); |
const Class& field_class = Class::Handle(func.owner()); |
@@ -876,9 +899,9 @@ |
Field::ZoneHandle(field_class.LookupInstanceField(field_name)); |
LoadInstanceFieldNode* load_field = |
- new LoadInstanceFieldNode(token_index_, load_receiver, field); |
+ new LoadInstanceFieldNode(TokenIndex(), load_receiver, field); |
- ReturnNode* return_node = new ReturnNode(token_index_, load_field); |
+ ReturnNode* return_node = new ReturnNode(TokenIndex(), load_field); |
current_block_->statements->Add(return_node); |
return CloseBlock(); |
} |
@@ -891,8 +914,8 @@ |
// ReturnNode (void); |
SequenceNode* Parser::ParseInstanceSetter(const Function& func) { |
TRACE_PARSER("ParseInstanceSetter"); |
- // token_index_ is the function's token position which points to the name of |
- // the field; we can use it to form the field_name. |
+ // TokenIndex() returns the function's token position which points to |
+ // the name of the field; we can use it to form the field_name. |
const String& field_name = *CurrentLiteral(); |
const Class& field_class = Class::ZoneHandle(func.owner()); |
const Field& field = |
@@ -900,8 +923,8 @@ |
const AbstractType& field_type = AbstractType::ZoneHandle(field.type()); |
ParamList params; |
- params.AddReceiver(token_index_); |
- params.AddFinalParameter(token_index_, "value", &field_type); |
+ params.AddReceiver(TokenIndex()); |
+ params.AddFinalParameter(TokenIndex(), "value", &field_type); |
ASSERT(func.num_fixed_parameters() == 2); // receiver, value. |
ASSERT(func.num_optional_parameters() == 0); |
ASSERT(AbstractType::Handle(func.result_type()).IsVoidType()); |
@@ -911,15 +934,15 @@ |
AddFormalParamsToScope(¶ms, current_block_->scope); |
LoadLocalNode* receiver = |
- new LoadLocalNode(token_index_, *current_block_->scope->VariableAt(0)); |
+ new LoadLocalNode(TokenIndex(), *current_block_->scope->VariableAt(0)); |
LoadLocalNode* value = |
- new LoadLocalNode(token_index_, *current_block_->scope->VariableAt(1)); |
+ new LoadLocalNode(TokenIndex(), *current_block_->scope->VariableAt(1)); |
StoreInstanceFieldNode* store_field = |
- new StoreInstanceFieldNode(token_index_, receiver, field, value); |
+ new StoreInstanceFieldNode(TokenIndex(), receiver, field, value); |
current_block_->statements->Add(store_field); |
- current_block_->statements->Add(new ReturnNode(token_index_)); |
+ current_block_->statements->Add(new ReturnNode(TokenIndex())); |
return CloseBlock(); |
} |
@@ -927,14 +950,14 @@ |
void Parser::SkipBlock() { |
ASSERT(CurrentToken() == Token::kLBRACE); |
GrowableArray<Token::Kind> token_stack(8); |
- const intptr_t block_start_pos = token_index_; |
+ const intptr_t block_start_pos = TokenIndex(); |
bool is_match = true; |
bool unexpected_token_found = false; |
Token::Kind token; |
intptr_t token_index; |
do { |
token = CurrentToken(); |
- token_index = token_index_; |
+ token_index = TokenIndex(); |
switch (token) { |
case Token::kLBRACE: |
case Token::kLPAREN: |
@@ -1035,7 +1058,7 @@ |
} |
// At this point, we must see an identifier for the parameter name. |
- parameter.name_pos = token_index_; |
+ parameter.name_pos = TokenIndex(); |
parameter.name = ExpectIdentifier("parameter name expected"); |
if (parameter.is_field_initializer) { |
params->has_field_initializer = true; |
@@ -1289,7 +1312,7 @@ |
AstNode* Parser::ParseSuperCall(const String& function_name) { |
TRACE_PARSER("ParseSuperCall"); |
ASSERT(CurrentToken() == Token::kLPAREN); |
- const intptr_t supercall_pos = token_index_; |
+ const intptr_t supercall_pos = TokenIndex(); |
bool is_no_such_method = false; |
const Function& super_function = Function::ZoneHandle( |
@@ -1322,7 +1345,7 @@ |
AstNode* Parser::ParseSuperOperator() { |
TRACE_PARSER("ParseSuperOperator"); |
AstNode* super_op = NULL; |
- const intptr_t operator_pos = token_index_; |
+ const intptr_t operator_pos = TokenIndex(); |
if (CurrentToken() == Token::kLBRACK) { |
ConsumeToken(); |
@@ -1447,7 +1470,7 @@ |
AstNode* Parser::ParseSuperFieldAccess(const String& field_name) { |
TRACE_PARSER("ParseSuperFieldAccess"); |
- const intptr_t field_pos = token_index_; |
+ const intptr_t field_pos = TokenIndex(); |
const Class& super_class = Class::Handle(current_class().SuperClass()); |
if (super_class.IsNull()) { |
ErrorMsg("class '%s' does not have a superclass", |
@@ -1510,7 +1533,7 @@ |
void Parser::GenerateSuperConstructorCall(const Class& cls, |
LocalVariable* receiver) { |
- const intptr_t supercall_pos = token_index_; |
+ const intptr_t supercall_pos = TokenIndex(); |
const Class& super_class = Class::Handle(cls.SuperClass()); |
// Omit the implicit super() if there is no super class (i.e. |
// we're not compiling class Object), or if the super class is an |
@@ -1549,7 +1572,7 @@ |
LocalVariable* receiver) { |
TRACE_PARSER("ParseSuperInitializer"); |
ASSERT(CurrentToken() == Token::kSUPER); |
- const intptr_t supercall_pos = token_index_; |
+ const intptr_t supercall_pos = TokenIndex(); |
ConsumeToken(); |
const Class& super_class = Class::Handle(cls.SuperClass()); |
ASSERT(!super_class.IsNull()); |
@@ -1599,7 +1622,7 @@ |
AstNode* Parser::ParseInitializer(const Class& cls, LocalVariable* receiver) { |
TRACE_PARSER("ParseInitializer"); |
- const intptr_t field_pos = token_index_; |
+ const intptr_t field_pos = TokenIndex(); |
if (CurrentToken() == Token::kTHIS) { |
ConsumeToken(); |
ExpectToken(Token::kPERIOD); |
@@ -1663,7 +1686,7 @@ |
TRACE_PARSER("ParseInitializedInstanceFields"); |
const Array& fields = Array::Handle(cls.fields()); |
Field& f = Field::Handle(); |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
for (int i = 0; i < fields.Length(); i++) { |
f ^= fields.At(i); |
if (!f.is_static() && f.has_initializer()) { |
@@ -1730,7 +1753,7 @@ |
LocalVariable* receiver) { |
TRACE_PARSER("ParseConstructorRedirection"); |
ASSERT(CurrentToken() == Token::kTHIS); |
- const intptr_t call_pos = token_index_; |
+ const intptr_t call_pos = TokenIndex(); |
ConsumeToken(); |
String& ctor_name = String::Handle(cls.Name()); |
String& ctor_suffix = String::Handle(String::NewSymbol(".")); |
@@ -1773,7 +1796,7 @@ |
SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { |
ASSERT(func.IsConstructor()); |
- const intptr_t ctor_pos = token_index_; |
+ const intptr_t ctor_pos = TokenIndex(); |
// Implicit 'this' is the only parameter/local variable. |
OpenFunctionBlock(func); |
@@ -1849,11 +1872,11 @@ |
// Add implicit receiver parameter which is passed the allocated |
// but uninitialized instance to construct. |
- params.AddReceiver(token_index_); |
+ params.AddReceiver(TokenIndex()); |
// Add implicit parameter for construction phase. |
params.AddFinalParameter( |
- token_index_, |
+ TokenIndex(), |
kPhaseParameterName, |
&Type::ZoneHandle(Type::DynamicType())); |
@@ -1931,18 +1954,18 @@ |
if (init_statements->length() > 0) { |
// Generate guard around the initializer code. |
LocalVariable* phase_param = LookupPhaseParameter(); |
- AstNode* phase_value = new LoadLocalNode(token_index_, *phase_param); |
+ AstNode* phase_value = new LoadLocalNode(TokenIndex(), *phase_param); |
AstNode* phase_check = new BinaryOpNode( |
- token_index_, Token::kBIT_AND, phase_value, |
- new LiteralNode(token_index_, |
+ TokenIndex(), Token::kBIT_AND, phase_value, |
+ new LiteralNode(TokenIndex(), |
Smi::ZoneHandle(Smi::New(Function::kCtorPhaseInit)))); |
AstNode* comparison = |
- new ComparisonNode(token_index_, Token::kNE_STRICT, |
+ new ComparisonNode(TokenIndex(), Token::kNE_STRICT, |
phase_check, |
- new LiteralNode(token_index_, |
+ new LiteralNode(TokenIndex(), |
Smi::ZoneHandle(Smi::New(0)))); |
AstNode* guarded_init_statements = |
- new IfNode(token_index_, comparison, init_statements, NULL); |
+ new IfNode(TokenIndex(), comparison, init_statements, NULL); |
current_block_->statements->Add(guarded_init_statements); |
} |
@@ -1995,38 +2018,38 @@ |
const Function& super_ctor = super_call->function(); |
// Patch the initializer call so it only executes the super initializer. |
initializer_args->SetNodeAt(1, |
- new LiteralNode(token_index_, |
+ new LiteralNode(TokenIndex(), |
Smi::ZoneHandle(Smi::New(Function::kCtorPhaseInit)))); |
- ArgumentListNode* super_call_args = new ArgumentListNode(token_index_); |
+ ArgumentListNode* super_call_args = new ArgumentListNode(TokenIndex()); |
// First argument is the receiver. |
- super_call_args->Add(new LoadLocalNode(token_index_, *receiver)); |
+ super_call_args->Add(new LoadLocalNode(TokenIndex(), *receiver)); |
// Second argument is the construction phase argument. |
AstNode* phase_parameter = |
- new LiteralNode(token_index_, |
- Smi::ZoneHandle(Smi::New(Function::kCtorPhaseBody))); |
+ new LiteralNode(TokenIndex(), |
+ Smi::ZoneHandle(Smi::New(Function::kCtorPhaseBody))); |
super_call_args->Add(phase_parameter); |
super_call_args->set_names(initializer_args->names()); |
for (int i = 2; i < initializer_args->length(); i++) { |
AstNode* arg = initializer_args->NodeAt(i); |
if (arg->IsLiteralNode()) { |
LiteralNode* lit = arg->AsLiteralNode(); |
- super_call_args->Add(new LiteralNode(token_index_, lit->literal())); |
+ super_call_args->Add(new LiteralNode(TokenIndex(), lit->literal())); |
} else { |
ASSERT(arg->IsLoadLocalNode() || arg->IsStoreLocalNode()); |
if (arg->IsLoadLocalNode()) { |
const LocalVariable& temp = arg->AsLoadLocalNode()->local(); |
- super_call_args->Add(new LoadLocalNode(token_index_, temp)); |
+ super_call_args->Add(new LoadLocalNode(TokenIndex(), temp)); |
} else if (arg->IsStoreLocalNode()) { |
const LocalVariable& temp = arg->AsStoreLocalNode()->local(); |
- super_call_args->Add(new LoadLocalNode(token_index_, temp)); |
+ super_call_args->Add(new LoadLocalNode(TokenIndex(), temp)); |
} |
} |
} |
ASSERT(super_ctor.AreValidArguments(super_call_args->length(), |
super_call_args->names())); |
current_block_->statements->Add( |
- new StaticCallNode(token_index_, super_ctor, super_call_args)); |
+ new StaticCallNode(TokenIndex(), super_ctor, super_call_args)); |
} |
if (CurrentToken() == Token::kLBRACE) { |
@@ -2048,19 +2071,19 @@ |
if (ctor_block->length() > 0) { |
// Generate guard around the constructor body code. |
LocalVariable* phase_param = LookupPhaseParameter(); |
- AstNode* phase_value = new LoadLocalNode(token_index_, *phase_param); |
+ AstNode* phase_value = new LoadLocalNode(TokenIndex(), *phase_param); |
AstNode* phase_check = |
- new BinaryOpNode(token_index_, Token::kBIT_AND, |
+ new BinaryOpNode(TokenIndex(), Token::kBIT_AND, |
phase_value, |
- new LiteralNode(token_index_, |
+ new LiteralNode(TokenIndex(), |
Smi::ZoneHandle(Smi::New(Function::kCtorPhaseBody)))); |
AstNode* comparison = |
- new ComparisonNode(token_index_, Token::kNE_STRICT, |
+ new ComparisonNode(TokenIndex(), Token::kNE_STRICT, |
phase_check, |
- new LiteralNode(token_index_, |
+ new LiteralNode(TokenIndex(), |
Smi::ZoneHandle(Smi::New(0)))); |
AstNode* guarded_block_statements = |
- new IfNode(token_index_, comparison, ctor_block, NULL); |
+ new IfNode(TokenIndex(), comparison, ctor_block, NULL); |
current_block_->statements->Add(guarded_block_statements); |
} |
@@ -2092,7 +2115,7 @@ |
(!func.is_static() || func.IsFactory()); |
const bool allow_explicit_default_values = true; |
if (has_receiver) { |
- params.AddReceiver(token_index_); |
+ params.AddReceiver(TokenIndex()); |
} |
ASSERT(CurrentToken() == Token::kLPAREN); |
ParseFormalParameterList(allow_explicit_default_values, ¶ms); |
@@ -2140,7 +2163,7 @@ |
ExpectToken(Token::kRBRACE); |
} else if (CurrentToken() == Token::kARROW) { |
ConsumeToken(); |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
AstNode* expr = ParseExpr(kAllowConst); |
ASSERT(expr != NULL); |
current_block_->statements->Add(new ReturnNode(expr_pos, expr)); |
@@ -2208,7 +2231,7 @@ |
TRACE_PARSER("ParseQualIdent"); |
ASSERT(IsIdentifier()); |
ASSERT(!current_class().IsNull()); |
- qual_ident->ident_pos = token_index_; |
+ qual_ident->ident_pos = TokenIndex(); |
qual_ident->ident = CurrentLiteral(); |
qual_ident->lib_prefix = NULL; |
ConsumeToken(); |
@@ -2226,11 +2249,11 @@ |
const Class& scope_class = Class::Handle(TypeParametersScopeClass()); |
if (scope_class.IsNull() || |
(scope_class.LookupTypeParameter(*(qual_ident->ident), |
- token_index_) == |
+ TokenIndex()) == |
TypeParameter::null())) { |
ConsumeToken(); // Consume the kPERIOD token. |
qual_ident->lib_prefix = &lib_prefix; |
- qual_ident->ident_pos = token_index_; |
+ qual_ident->ident_pos = TokenIndex(); |
qual_ident->ident = |
ExpectIdentifier("identifier expected after '.'"); |
} |
@@ -2243,7 +2266,7 @@ |
void Parser::ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method) { |
TRACE_PARSER("ParseMethodOrConstructor"); |
ASSERT(CurrentToken() == Token::kLPAREN); |
- intptr_t method_pos = this->token_index_; |
+ intptr_t method_pos = this->TokenIndex(); |
ASSERT(method->type != NULL); |
ASSERT(method->name_pos > 0); |
ASSERT(current_member_ == method); |
@@ -2286,7 +2309,7 @@ |
!method->has_static || method->IsConstructor() || method->has_factory; |
const bool are_implicitly_final = method->has_const; |
const bool allow_explicit_default_values = true; |
- const intptr_t formal_param_pos = token_index_; |
+ const intptr_t formal_param_pos = TokenIndex(); |
method->params.Clear(); |
if (has_this_param) { |
method->params.AddReceiver(formal_param_pos); |
@@ -2294,7 +2317,7 @@ |
// Constructors have an implicit parameter for the construction phase. |
if (method->IsConstructor()) { |
method->params.AddFinalParameter( |
- token_index_, |
+ TokenIndex(), |
kPhaseParameterName, |
&Type::ZoneHandle(Type::DynamicType())); |
} |
@@ -2383,7 +2406,7 @@ |
SkipExpr(); |
ExpectSemicolon(); |
} |
- method_end_pos = token_index_; |
+ method_end_pos = TokenIndex(); |
} else if (IsLiteral("native")) { |
if (method->has_abstract) { |
ErrorMsg(method->name_pos, |
@@ -2523,7 +2546,7 @@ |
field->has_static, field->has_final, |
field->name_pos); |
ParamList params; |
- params.AddReceiver(token_index_); |
+ params.AddReceiver(TokenIndex()); |
getter.set_result_type(*field->type); |
AddFormalParamsToFunction(¶ms, getter); |
members->AddFunction(getter); |
@@ -2534,8 +2557,8 @@ |
field->has_static, field->has_final, |
field->name_pos); |
ParamList params; |
- params.AddReceiver(token_index_); |
- params.AddFinalParameter(token_index_, "value", field->type); |
+ params.AddReceiver(TokenIndex()); |
+ params.AddFinalParameter(TokenIndex(), "value", field->type); |
setter.set_result_type(Type::Handle(Type::VoidType())); |
AddFormalParamsToFunction(¶ms, setter); |
members->AddFunction(setter); |
@@ -2546,7 +2569,7 @@ |
break; |
} |
ConsumeToken(); |
- field->name_pos = this->token_index_; |
+ field->name_pos = this->TokenIndex(); |
field->name = ExpectIdentifier("field name expected"); |
} |
ExpectSemicolon(); |
@@ -2668,7 +2691,7 @@ |
TypeArguments::Handle(), |
factory_name.ident_pos)); |
} else { |
- member.name_pos = token_index_; |
+ member.name_pos = TokenIndex(); |
member.name = CurrentLiteral(); |
ConsumeToken(); |
} |
@@ -2706,7 +2729,7 @@ |
(LookaheadToken(1) != Token::kSEMICOLON)) { |
ConsumeToken(); |
member.kind = RawFunction::kGetterFunction; |
- member.name_pos = this->token_index_; |
+ member.name_pos = this->TokenIndex(); |
member.name = ExpectIdentifier("identifier expected"); |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg("'(' expected"); |
@@ -2719,7 +2742,7 @@ |
(LookaheadToken(1) != Token::kSEMICOLON)) { |
ConsumeToken(); |
member.kind = RawFunction::kSetterFunction; |
- member.name_pos = this->token_index_; |
+ member.name_pos = this->TokenIndex(); |
member.name = ExpectIdentifier("identifier expected"); |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg("'(' expected"); |
@@ -2743,13 +2766,13 @@ |
} |
operator_token = CurrentToken(); |
member.kind = RawFunction::kFunction; |
- member.name_pos = this->token_index_; |
+ member.name_pos = this->TokenIndex(); |
member.name = |
&String::ZoneHandle(String::NewSymbol(Token::Str(operator_token))); |
ConsumeToken(); |
} else if (IsIdentifier()) { |
member.name = CurrentLiteral(); |
- member.name_pos = token_index_; |
+ member.name_pos = TokenIndex(); |
ConsumeToken(); |
} else { |
ErrorMsg("identifier expected"); |
@@ -2797,9 +2820,9 @@ |
void Parser::ParseClassDefinition(const GrowableObjectArray& pending_classes) { |
TRACE_PARSER("ParseClassDefinition"); |
- const intptr_t class_pos = token_index_; |
+ const intptr_t class_pos = TokenIndex(); |
ExpectToken(Token::kCLASS); |
- const intptr_t classname_pos = token_index_; |
+ const intptr_t classname_pos = TokenIndex(); |
String& class_name = *ExpectTypeIdentifier("class name expected"); |
if (FLAG_trace_parser) { |
OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); |
@@ -2830,7 +2853,7 @@ |
Type& super_type = Type::Handle(); |
if (CurrentToken() == Token::kEXTENDS) { |
ConsumeToken(); |
- const intptr_t type_pos = token_index_; |
+ const intptr_t type_pos = TokenIndex(); |
const AbstractType& type = AbstractType::Handle( |
ParseType(ClassFinalizer::kTryResolve)); |
if (type.IsTypeParameter()) { |
@@ -2855,7 +2878,7 @@ |
if (CurrentToken() == Token::kIMPLEMENTS) { |
Array& interfaces = Array::Handle(); |
- const intptr_t interfaces_pos = token_index_; |
+ const intptr_t interfaces_pos = TokenIndex(); |
interfaces = ParseInterfaceList(); |
AddInterfaces(interfaces_pos, cls, interfaces); |
} |
@@ -2902,10 +2925,10 @@ |
class_desc->token_pos())); |
ParamList params; |
// Add implicit 'this' parameter. |
- params.AddReceiver(token_index_); |
+ params.AddReceiver(TokenIndex()); |
// Add implicit parameter for construction phase. |
params.AddFinalParameter( |
- token_index_, |
+ TokenIndex(), |
kPhaseParameterName, |
&Type::ZoneHandle(Type::DynamicType())); |
@@ -2952,7 +2975,7 @@ |
if (IsIdentifier() && (LookaheadToken(1) == Token::kLPAREN)) { |
return true; |
} |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
bool is_alias_name = false; |
if (IsIdentifier() && (LookaheadToken(1) == Token::kLT)) { |
ConsumeToken(); |
@@ -2975,7 +2998,7 @@ |
const Class& alias_owner = Class::Handle( |
Class::New(String::Handle(String::NewSymbol(":alias_owner")), |
Script::Handle(), |
- token_index_)); |
+ TokenIndex())); |
alias_owner.set_is_interface(); |
alias_owner.set_library(library_); |
set_current_class(alias_owner); |
@@ -2991,7 +3014,7 @@ |
result_type = ParseType(ClassFinalizer::kDoNotResolve); |
} |
- const intptr_t alias_name_pos = token_index_; |
+ const intptr_t alias_name_pos = TokenIndex(); |
const String* alias_name = |
ExpectTypeIdentifier("function alias name expected"); |
@@ -3070,9 +3093,9 @@ |
void Parser::ParseInterfaceDefinition( |
const GrowableObjectArray& pending_classes) { |
TRACE_PARSER("ParseInterfaceDefinition"); |
- const intptr_t interface_pos = token_index_; |
+ const intptr_t interface_pos = TokenIndex(); |
ExpectToken(Token::kINTERFACE); |
- const intptr_t interfacename_pos = token_index_; |
+ const intptr_t interfacename_pos = TokenIndex(); |
String& interface_name = *ExpectTypeIdentifier("interface name expected"); |
if (FLAG_trace_parser) { |
OS::Print("TopLevel parsing interface '%s'\n", interface_name.ToCString()); |
@@ -3105,7 +3128,7 @@ |
if (CurrentToken() == Token::kEXTENDS) { |
Array& interfaces = Array::Handle(); |
- const intptr_t interfaces_pos = token_index_; |
+ const intptr_t interfaces_pos = TokenIndex(); |
interfaces = ParseInterfaceList(); |
AddInterfaces(interfaces_pos, interface, interfaces); |
} |
@@ -3246,7 +3269,7 @@ |
type_parameter = TypeParameter::New(cls, |
index, |
type_parameter_name, |
- token_index_); |
+ TokenIndex()); |
// Check for duplicate type parameters. |
for (intptr_t i = 0; i < index; i++) { |
existing_type_parameter ^= type_parameters_array.At(i); |
@@ -3343,7 +3366,7 @@ |
AbstractType& other_interface = AbstractType::Handle(); |
do { |
ConsumeToken(); |
- intptr_t supertype_pos = token_index_; |
+ intptr_t supertype_pos = TokenIndex(); |
interface = ParseType(ClassFinalizer::kTryResolve); |
interface_name = interface.Name(); |
for (int i = 0; i < interfaces.Length(); i++) { |
@@ -3415,7 +3438,7 @@ |
Field& field = Field::Handle(); |
Function& getter = Function::Handle(); |
while (true) { |
- const intptr_t name_pos = token_index_; |
+ const intptr_t name_pos = TokenIndex(); |
String& var_name = *ExpectIdentifier("variable name expected"); |
if (library_.LookupObject(var_name) != Object::null()) { |
@@ -3477,7 +3500,7 @@ |
result_type = ParseType(ClassFinalizer::kTryResolve); |
} |
} |
- const intptr_t name_pos = token_index_; |
+ const intptr_t name_pos = TokenIndex(); |
const String& func_name = *ExpectIdentifier("function name expected"); |
if (library_.LookupObject(func_name) != Object::null()) { |
@@ -3497,7 +3520,7 @@ |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg("'(' expected"); |
} |
- const intptr_t function_pos = token_index_; |
+ const intptr_t function_pos = TokenIndex(); |
ParamList params; |
const bool allow_explicit_default_values = true; |
ParseFormalParameterList(allow_explicit_default_values, ¶ms); |
@@ -3505,12 +3528,12 @@ |
intptr_t function_end_pos = function_pos; |
if (CurrentToken() == Token::kLBRACE) { |
SkipBlock(); |
- function_end_pos = token_index_; |
+ function_end_pos = TokenIndex(); |
} else if (CurrentToken() == Token::kARROW) { |
ConsumeToken(); |
SkipExpr(); |
ExpectSemicolon(); |
- function_end_pos = token_index_; |
+ function_end_pos = TokenIndex(); |
} else if (IsLiteral("native")) { |
ParseNativeDeclaration(); |
} else { |
@@ -3550,13 +3573,13 @@ |
UnexpectedToken(); |
} |
} |
- const intptr_t name_pos = token_index_; |
+ const intptr_t name_pos = TokenIndex(); |
const String* field_name = ExpectIdentifier("accessor name expected"); |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg("'(' expected"); |
} |
- const intptr_t accessor_pos = token_index_; |
+ const intptr_t accessor_pos = TokenIndex(); |
ParamList params; |
const bool allow_explicit_default_values = true; |
ParseFormalParameterList(allow_explicit_default_values, ¶ms); |
@@ -3653,7 +3676,7 @@ |
void Parser::ParseLibraryImport() { |
TRACE_PARSER("ParseLibraryImport"); |
while (CurrentToken() == Token::kIMPORT) { |
- const intptr_t import_pos = token_index_; |
+ const intptr_t import_pos = TokenIndex(); |
ConsumeToken(); |
ExpectToken(Token::kLPAREN); |
if (CurrentToken() != Token::kSTRING) { |
@@ -3717,7 +3740,7 @@ |
void Parser::ParseLibraryInclude() { |
TRACE_PARSER("ParseLibraryInclude"); |
while (CurrentToken() == Token::kSOURCE) { |
- const intptr_t source_pos = token_index_; |
+ const intptr_t source_pos = TokenIndex(); |
ConsumeToken(); |
ExpectToken(Token::kLPAREN); |
if (CurrentToken() != Token::kSTRING) { |
@@ -3782,7 +3805,7 @@ |
Class& toplevel_class = Class::Handle( |
Class::New(String::ZoneHandle(String::NewSymbol("::")), |
script_, |
- token_index_)); |
+ TokenIndex())); |
toplevel_class.set_library(library_); |
if (is_library_source()) { |
@@ -3835,7 +3858,7 @@ |
void Parser::ChainNewBlock(LocalScope* outer_scope) { |
Block* block = new Block(current_block_, |
outer_scope, |
- new SequenceNode(token_index_, outer_scope)); |
+ new SequenceNode(TokenIndex(), outer_scope)); |
current_block_ = block; |
} |
@@ -3889,7 +3912,7 @@ |
// Record the begin and end token index of the scope. |
ASSERT(statements != NULL); |
current_block_->scope->set_begin_token_index(statements->token_index()); |
- current_block_->scope->set_end_token_index(token_index_); |
+ current_block_->scope->set_end_token_index(TokenIndex()); |
} |
current_block_ = current_block_->parent; |
return statements; |
@@ -3970,7 +3993,7 @@ |
int num_params_for_resolution = num_parameters; |
// Parse the function name out. |
- const intptr_t native_pos = token_index_; |
+ const intptr_t native_pos = TokenIndex(); |
const String& native_name = ParseNativeDeclaration(); |
if (is_instance_closure) { |
@@ -3988,7 +4011,7 @@ |
// Now add the NativeBodyNode and return statement. |
current_block_->statements->Add( |
- new ReturnNode(token_index_, new NativeBodyNode(token_index_, |
+ new ReturnNode(TokenIndex(), new NativeBodyNode(TokenIndex(), |
native_name, |
native_function, |
num_parameters, |
@@ -4032,14 +4055,14 @@ |
if (receiver == NULL) { |
ErrorMsg(token_pos, "illegal implicit access to receiver 'this'"); |
} |
- return new LoadLocalNode(token_index_, *receiver); |
+ return new LoadLocalNode(TokenIndex(), *receiver); |
} |
AstNode* Parser::CallGetter(intptr_t token_index, |
AstNode* object, |
const String& name) { |
- return new InstanceGetterNode(token_index_, object, name); |
+ return new InstanceGetterNode(TokenIndex(), object, name); |
} |
@@ -4048,7 +4071,7 @@ |
const AbstractType& type, bool is_final) { |
TRACE_PARSER("ParseVariableDeclaration"); |
ASSERT(IsIdentifier()); |
- const intptr_t ident_pos = token_index_; |
+ const intptr_t ident_pos = TokenIndex(); |
LocalVariable* variable = |
new LocalVariable(ident_pos, *CurrentLiteral(), type); |
ASSERT(current_block_ != NULL); |
@@ -4057,7 +4080,7 @@ |
AstNode* initialization = NULL; |
if (CurrentToken() == Token::kASSIGN) { |
// Variable initialization. |
- const intptr_t assign_pos = token_index_; |
+ const intptr_t assign_pos = TokenIndex(); |
ConsumeToken(); |
AstNode* expr = ParseExpr(kAllowConst); |
initialization = new StoreLocalNode(assign_pos, *variable, expr); |
@@ -4165,7 +4188,7 @@ |
(LookaheadToken(1) != Token::kLPAREN)) { |
result_type = ParseType(ClassFinalizer::kFinalize); |
} |
- const intptr_t ident_pos = token_index_; |
+ const intptr_t ident_pos = TokenIndex(); |
if (IsIdentifier()) { |
variable_name = CurrentLiteral(); |
function_name = variable_name; |
@@ -4183,7 +4206,7 @@ |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg("'(' expected"); |
} |
- intptr_t function_pos = token_index_; |
+ intptr_t function_pos = TokenIndex(); |
// Check whether we have parsed this closure function before, in a previous |
// compilation. If so, reuse the function object, else create a new one |
@@ -4243,8 +4266,8 @@ |
Array& default_parameter_values = Array::Handle(); |
SequenceNode* statements = Parser::ParseFunc(function, |
default_parameter_values); |
- ASSERT(is_new_closure || (function.end_token_index() == token_index_)); |
- function.set_end_token_index(token_index_); |
+ ASSERT(is_new_closure || (function.end_token_index() == TokenIndex())); |
+ function.set_end_token_index(TokenIndex()); |
// 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 |
@@ -4423,7 +4446,7 @@ |
// Not a legal type identifier. |
return false; |
} |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
bool is_var_decl = false; |
if (TryParseOptionalType()) { |
if (IsIdentifier()) { |
@@ -4443,7 +4466,7 @@ |
// Look ahead to detect whether the next tokens should be parsed as |
// a function declaration. Token position remains unchanged. |
bool Parser::IsFunctionDeclaration() { |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
if (IsIdentifier() && (LookaheadToken(1) == Token::kLPAREN)) { |
// Possibly a function without explicit return type. |
ConsumeToken(); // Consume function identifier. |
@@ -4476,7 +4499,7 @@ |
if ((CurrentToken() == Token::kGET) || (CurrentToken() == Token::kSET)) { |
return true; |
} |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
if (TryParseReturnType()) { |
if ((CurrentToken() == Token::kGET) || (CurrentToken() == Token::kSET)) { |
if (Token::IsIdentifier(LookaheadToken(1))) { // Accessor name. |
@@ -4494,7 +4517,7 @@ |
if (!allow_function_literals_) { |
return false; |
} |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
bool is_function_literal = false; |
if (IsIdentifier() && (LookaheadToken(1) == Token::kLPAREN)) { |
ConsumeToken(); // Consume function identifier. |
@@ -4521,7 +4544,7 @@ |
// statement. Returns true if we recognize a for ( .. in expr) |
// statement. |
bool Parser::IsForInStatement() { |
- const intptr_t saved_pos = token_index_; |
+ const intptr_t saved_pos = TokenIndex(); |
bool result = false; |
if (CurrentToken() == Token::kVAR || CurrentToken() == Token::kFINAL) { |
ConsumeToken(); |
@@ -4567,7 +4590,7 @@ |
const bool dead_code_allowed = true; |
bool abrupt_completing_seen = false; |
while (CurrentToken() != Token::kRBRACE) { |
- const intptr_t statement_pos = token_index_; |
+ const intptr_t statement_pos = TokenIndex(); |
AstNode* statement = ParseStatement(); |
// Do not add statements with no effect (e.g., LoadLocalNode). |
if ((statement != NULL) && statement->IsLoadLocalNode()) { |
@@ -4617,7 +4640,7 @@ |
AstNode* Parser::ParseIfStatement(String* label_name) { |
TRACE_PARSER("ParseIfStatement"); |
ASSERT(CurrentToken() == Token::kIF); |
- const intptr_t if_pos = token_index_; |
+ const intptr_t if_pos = TokenIndex(); |
SourceLabel* label = NULL; |
if (label_name != NULL) { |
label = SourceLabel::New(if_pos, label_name, SourceLabel::kStatement); |
@@ -4650,7 +4673,7 @@ |
SourceLabel* case_label) { |
TRACE_PARSER("ParseCaseStatement"); |
bool default_seen = false; |
- const intptr_t case_pos = token_index_; |
+ const intptr_t case_pos = TokenIndex(); |
// The case expressions node sequence does not own the enclosing scope. |
SequenceNode* case_expressions = new SequenceNode(case_pos, NULL); |
while (CurrentToken() == Token::kCASE || CurrentToken() == Token::kDEFAULT) { |
@@ -4659,7 +4682,7 @@ |
ErrorMsg("default clause must be last case"); |
} |
ConsumeToken(); // Keyword case. |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
AstNode* expr = ParseExpr(kAllowConst); |
AstNode* switch_expr_load = new LoadLocalNode(case_pos, |
*switch_expr_value); |
@@ -4699,9 +4722,9 @@ |
// End of this case clause. If there is a possible fall-through to |
// the next case clause, throw an implicit FallThroughError. |
if (!abrupt_completing_seen) { |
- ArgumentListNode* arguments = new ArgumentListNode(token_index_); |
+ ArgumentListNode* arguments = new ArgumentListNode(TokenIndex()); |
arguments->Add(new LiteralNode( |
- token_index_, Integer::ZoneHandle(Integer::New(token_index_)))); |
+ TokenIndex(), Integer::ZoneHandle(Integer::New(TokenIndex())))); |
current_block_->statements->Add( |
MakeStaticCall(kFallThroughErrorName, kThrowNewName, arguments)); |
} |
@@ -4723,7 +4746,7 @@ |
AstNode* Parser::ParseSwitchStatement(String* label_name) { |
TRACE_PARSER("ParseSwitchStatement"); |
ASSERT(CurrentToken() == Token::kSWITCH); |
- const intptr_t switch_pos = token_index_; |
+ const intptr_t switch_pos = TokenIndex(); |
SourceLabel* label = |
SourceLabel::New(switch_pos, label_name, SourceLabel::kSwitch); |
ConsumeToken(); |
@@ -4735,7 +4758,7 @@ |
} else if (parens_are_mandatory) { |
ErrorMsg("'(' expected"); |
} |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
AstNode* switch_expr = ParseExpr(kAllowConst); |
if (paren_found) { |
ExpectToken(Token::kRPAREN); |
@@ -4762,7 +4785,7 @@ |
if (IsIdentifier() && LookaheadToken(1) == Token::kCOLON) { |
// Case statements start with a label. |
String* label_name = CurrentLiteral(); |
- const intptr_t label_pos = token_index_; |
+ const intptr_t label_pos = TokenIndex(); |
ConsumeToken(); // Consume label identifier. |
ConsumeToken(); // Consume colon. |
case_label = current_block_->scope->LocalLookupLabel(*label_name); |
@@ -4814,7 +4837,7 @@ |
AstNode* Parser::ParseWhileStatement(String* label_name) { |
TRACE_PARSER("ParseWhileStatement"); |
- const intptr_t while_pos = token_index_; |
+ const intptr_t while_pos = TokenIndex(); |
SourceLabel* label = |
SourceLabel::New(while_pos, label_name, SourceLabel::kWhile); |
ConsumeToken(); |
@@ -4829,7 +4852,7 @@ |
AstNode* Parser::ParseDoWhileStatement(String* label_name) { |
TRACE_PARSER("ParseDoWhileStatement"); |
- const intptr_t do_pos = token_index_; |
+ const intptr_t do_pos = TokenIndex(); |
SourceLabel* label = |
SourceLabel::New(do_pos, label_name, SourceLabel::kDoWhile); |
ConsumeToken(); |
@@ -4852,14 +4875,14 @@ |
LocalVariable* loop_var = NULL; |
intptr_t loop_var_pos = 0; |
if (LookaheadToken(1) == Token::kIN) { |
- loop_var_pos = token_index_; |
+ loop_var_pos = TokenIndex(); |
loop_var_name = ExpectIdentifier("variable name expected"); |
} else { |
// The case without a type is handled above, so require a type here. |
const AbstractType& type = AbstractType::ZoneHandle(ParseFinalVarOrType( |
FLAG_enable_type_checks ? ClassFinalizer::kFinalize : |
ClassFinalizer::kIgnore)); |
- loop_var_pos = token_index_; |
+ loop_var_pos = TokenIndex(); |
loop_var_name = ExpectIdentifier("variable name expected"); |
loop_var = new LocalVariable(loop_var_pos, *loop_var_name, type); |
if (is_final) { |
@@ -4867,7 +4890,7 @@ |
} |
} |
ExpectToken(Token::kIN); |
- const intptr_t collection_pos = token_index_; |
+ const intptr_t collection_pos = TokenIndex(); |
AstNode* collection_expr = ParseExpr(kAllowConst); |
ExpectToken(Token::kRPAREN); |
@@ -4959,7 +4982,7 @@ |
AstNode* Parser::ParseForStatement(String* label_name) { |
TRACE_PARSER("ParseForStatement"); |
- const intptr_t for_pos = token_index_; |
+ const intptr_t for_pos = TokenIndex(); |
ConsumeToken(); |
ExpectToken(Token::kLPAREN); |
SourceLabel* label = SourceLabel::New(for_pos, label_name, SourceLabel::kFor); |
@@ -4971,7 +4994,7 @@ |
// the loop variable declarations. |
current_block_->scope->AddLabel(label); |
AstNode* initializer = NULL; |
- const intptr_t init_pos = token_index_; |
+ const intptr_t init_pos = TokenIndex(); |
LocalScope* init_scope = current_block_->scope; |
if (CurrentToken() != Token::kSEMICOLON) { |
if (IsVariableDeclaration()) { |
@@ -4987,7 +5010,7 @@ |
} |
ExpectSemicolon(); |
AstNode* increment = NULL; |
- const intptr_t incr_pos = token_index_; |
+ const intptr_t incr_pos = TokenIndex(); |
LocalScope* incr_scope = current_block_->scope; |
if (CurrentToken() != Token::kRPAREN) { |
increment = ParseExprList(); |
@@ -5075,14 +5098,14 @@ |
TRACE_PARSER("ParseAssertStatement"); |
ConsumeToken(); // Consume assert keyword. |
ExpectToken(Token::kLPAREN); |
- const intptr_t condition_pos = token_index_; |
+ const intptr_t condition_pos = TokenIndex(); |
if (!FLAG_enable_asserts && !FLAG_enable_type_checks) { |
SkipExpr(); |
ExpectToken(Token::kRPAREN); |
return NULL; |
} |
AstNode* condition = ParseExpr(kAllowConst); |
- const intptr_t condition_end = token_index_; |
+ const intptr_t condition_end = TokenIndex(); |
ExpectToken(Token::kRPAREN); |
condition = InsertClosureCallNodes(condition); |
condition = new UnaryOpNode(condition_pos, Token::kNOT, condition); |
@@ -5113,7 +5136,7 @@ |
// mode. |
catch_param->type = &AbstractType::ZoneHandle( |
ParseFinalVarOrType(ClassFinalizer::kFinalizeWellFormed)); |
- catch_param->token_index = token_index_; |
+ catch_param->token_index = TokenIndex(); |
catch_param->var = ExpectIdentifier("identifier expected"); |
} |
@@ -5132,7 +5155,7 @@ |
bool added_to_scope = scope->AddVariable(var); |
ASSERT(added_to_scope); |
if (stack_trace_param.var != NULL) { |
- var = new LocalVariable(token_index_, |
+ var = new LocalVariable(TokenIndex(), |
*stack_trace_param.var, |
*stack_trace_param.type); |
if (stack_trace_param.is_final) { |
@@ -5231,7 +5254,7 @@ |
LocalVariable* context_var = |
current_block_->scope->LocalLookupVariable(context_var_name); |
if (context_var == NULL) { |
- context_var = new LocalVariable(token_index_, |
+ context_var = new LocalVariable(TokenIndex(), |
context_var_name, |
Type::ZoneHandle(Type::DynamicType())); |
current_block_->scope->AddVariable(context_var); |
@@ -5241,7 +5264,7 @@ |
LocalVariable* catch_excp_var = |
current_block_->scope->LocalLookupVariable(catch_excp_var_name); |
if (catch_excp_var == NULL) { |
- catch_excp_var = new LocalVariable(token_index_, |
+ catch_excp_var = new LocalVariable(TokenIndex(), |
catch_excp_var_name, |
Type::ZoneHandle(Type::DynamicType())); |
current_block_->scope->AddVariable(catch_excp_var); |
@@ -5251,13 +5274,13 @@ |
LocalVariable* catch_trace_var = |
current_block_->scope->LocalLookupVariable(catch_trace_var_name); |
if (catch_trace_var == NULL) { |
- catch_trace_var = new LocalVariable(token_index_, |
+ catch_trace_var = new LocalVariable(TokenIndex(), |
catch_trace_var_name, |
Type::ZoneHandle(Type::DynamicType())); |
current_block_->scope->AddVariable(catch_trace_var); |
} |
- const intptr_t try_pos = token_index_; |
+ const intptr_t try_pos = TokenIndex(); |
ConsumeToken(); // Consume the 'try'. |
SourceLabel* try_label = NULL; |
@@ -5279,7 +5302,7 @@ |
// Now create a label for the end of catch block processing so that we can |
// jump over the catch block code after executing the try block. |
SourceLabel* end_catch_label = |
- SourceLabel::New(token_index_, NULL, SourceLabel::kCatch); |
+ SourceLabel::New(TokenIndex(), NULL, SourceLabel::kCatch); |
// Now parse the 'catch' blocks if any and merge all of them into |
// an if-then sequence of the different types specified using the 'is' |
@@ -5287,12 +5310,12 @@ |
bool catch_seen = false; |
bool generic_catch_seen = false; |
SequenceNode* catch_handler_list = NULL; |
- const intptr_t handler_pos = token_index_; |
+ const intptr_t handler_pos = TokenIndex(); |
OpenBlock(); // Start the catch block sequence. |
current_block_->scope->AddLabel(end_catch_label); |
while (CurrentToken() == Token::kCATCH) { |
catch_seen = true; |
- const intptr_t catch_pos = token_index_; |
+ const intptr_t catch_pos = TokenIndex(); |
ConsumeToken(); // Consume the 'catch'. |
ExpectToken(Token::kLPAREN); |
CatchParamDesc exception_param; |
@@ -5387,7 +5410,7 @@ |
if (CurrentToken() == Token::kFINALLY) { |
current_function_.set_is_optimizable(false); |
ConsumeToken(); // Consume the 'finally'. |
- const intptr_t finally_pos = token_index_; |
+ const intptr_t finally_pos = TokenIndex(); |
// Add the finally block to the exit points recorded so far. |
intptr_t node_index = 0; |
AstNode* node_to_inline = |
@@ -5400,14 +5423,14 @@ |
AddFinallyBlockToNode(node_to_inline, node); |
node_index += 1; |
node_to_inline = inner_try_block->GetNodeToInlineFinally(node_index); |
- token_index_ = finally_pos; |
+ tokens_iterator_.SetCurrentIndex(finally_pos); |
} |
if (!generic_catch_seen) { |
// No generic catch handler exists so execute this finally block |
// before rethrowing the exception. |
finally_block = ParseFinallyBlock(); |
catch_handler_list->Add(finally_block); |
- token_index_ = finally_pos; |
+ tokens_iterator_.SetCurrentIndex(finally_pos); |
} |
finally_block = ParseFinallyBlock(); |
} else { |
@@ -5451,7 +5474,7 @@ |
TRACE_PARSER("ParseJump"); |
ASSERT(CurrentToken() == Token::kBREAK || CurrentToken() == Token::kCONTINUE); |
Token::Kind jump_kind = CurrentToken(); |
- const intptr_t jump_pos = token_index_; |
+ const intptr_t jump_pos = TokenIndex(); |
SourceLabel* target = NULL; |
ConsumeToken(); |
if (IsIdentifier()) { |
@@ -5477,7 +5500,7 @@ |
if (switch_scope != NULL) { |
// We found a switch scope. Enter a forward reference to the label. |
target = new SourceLabel( |
- token_index_, target_name, SourceLabel::kForward); |
+ TokenIndex(), target_name, SourceLabel::kForward); |
switch_scope->AddLabel(target); |
} |
} |
@@ -5511,7 +5534,7 @@ |
bool Parser::IsDefinedInLexicalScope(const String& ident) { |
- if (ResolveIdentInLocalScope(token_index_, ident, NULL)) { |
+ if (ResolveIdentInLocalScope(TokenIndex(), ident, NULL)) { |
return true; |
} |
Object& obj = Object::Handle(); |
@@ -5529,13 +5552,13 @@ |
if (LookaheadToken(1) == Token::kCOLON) { |
// Statement starts with a label. |
label_name = CurrentLiteral(); |
- label_pos = token_index_; |
+ label_pos = TokenIndex(); |
ASSERT(label_pos > 0); |
ConsumeToken(); // Consume identifier. |
ConsumeToken(); // Consume colon. |
} |
} |
- const intptr_t statement_pos = token_index_; |
+ const intptr_t statement_pos = TokenIndex(); |
if (CurrentToken() == Token::kWHILE) { |
statement = ParseWhileStatement(label_name); |
@@ -5548,7 +5571,7 @@ |
} else if (CurrentToken() == Token::kTRY) { |
statement = ParseTryStatement(label_name); |
} else if (CurrentToken() == Token::kRETURN) { |
- const intptr_t return_pos = token_index_; |
+ const intptr_t return_pos = TokenIndex(); |
ConsumeToken(); |
if (CurrentToken() != Token::kSEMICOLON) { |
if (current_function().IsConstructor() && |
@@ -5743,7 +5766,7 @@ |
va_list args; |
va_start(args, format); |
const Error& error = Error::Handle( |
- FormatError(script_, token_index_, "Error", format, args)); |
+ FormatError(script_, TokenIndex(), "Error", format, args)); |
va_end(args); |
Isolate::Current()->long_jump_base()->Jump(1, error); |
UNREACHABLE(); |
@@ -5789,7 +5812,7 @@ |
va_list args; |
va_start(args, format); |
const Error& error = Error::Handle( |
- FormatError(script_, token_index_, "Warning", format, args)); |
+ FormatError(script_, TokenIndex(), "Warning", format, args)); |
va_end(args); |
if (FLAG_warning_as_error) { |
Isolate::Current()->long_jump_base()->Jump(1, error); |
@@ -5801,7 +5824,7 @@ |
void Parser::Unimplemented(const char* msg) { |
- ErrorMsg(token_index_, msg); |
+ ErrorMsg(TokenIndex(), msg); |
} |
@@ -5915,7 +5938,7 @@ |
if (op_kind == Token::kTIGHTADD) { |
op_kind = Token::kADD; |
} |
- const intptr_t op_pos = token_index_; |
+ const intptr_t op_pos = TokenIndex(); |
ConsumeToken(); |
AstNode* right_operand = NULL; |
if (op_kind != Token::kIS) { |
@@ -5926,7 +5949,7 @@ |
ConsumeToken(); |
op_kind = Token::kISNOT; |
} |
- const intptr_t type_pos = token_index_; |
+ const intptr_t type_pos = TokenIndex(); |
const AbstractType& type = |
AbstractType::ZoneHandle(ParseType(ClassFinalizer::kFinalize)); |
if (!type.IsInstantiated() && |
@@ -5977,7 +6000,7 @@ |
AstNode* expressions = ParseExpr(kAllowConst); |
if (CurrentToken() == Token::kCOMMA) { |
// Collect comma-separated expressions in a non scope owning sequence node. |
- SequenceNode* list = new SequenceNode(token_index_, NULL); |
+ SequenceNode* list = new SequenceNode(TokenIndex(), NULL); |
list->Add(expressions); |
while (CurrentToken() == Token::kCOMMA) { |
ConsumeToken(); |
@@ -6178,7 +6201,7 @@ |
AstNode* Parser::ParseExpr(bool require_compiletime_const) { |
TRACE_PARSER("ParseExpr"); |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
AstNode* expr = ParseConditionalExpr(); |
if (!Token::IsAssignmentOperator(CurrentToken())) { |
if (require_compiletime_const) { |
@@ -6188,9 +6211,9 @@ |
} |
// Assignment expressions. |
Token::Kind assignment_op = CurrentToken(); |
- const intptr_t assignment_pos = token_index_; |
+ const intptr_t assignment_pos = TokenIndex(); |
ConsumeToken(); |
- const intptr_t right_expr_pos = token_index_; |
+ const intptr_t right_expr_pos = TokenIndex(); |
if (require_compiletime_const && (assignment_op != Token::kASSIGN)) { |
ErrorMsg(right_expr_pos, "expression must be a compile time constant"); |
} |
@@ -6222,7 +6245,7 @@ |
AstNode* Parser::ParseConditionalExpr() { |
TRACE_PARSER("ParseConditionalExpr"); |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
AstNode* expr = ParseBinaryExpr(Token::Precedence(Token::kOR)); |
if (CurrentToken() == Token::kCONDITIONAL) { |
EnsureExpressionTemp(); |
@@ -6239,7 +6262,7 @@ |
AstNode* Parser::ParseUnaryExpr() { |
TRACE_PARSER("ParseUnaryExpr"); |
AstNode* expr = NULL; |
- const intptr_t op_pos = token_index_; |
+ const intptr_t op_pos = TokenIndex(); |
if (IsPrefixOperator(CurrentToken())) { |
Token::Kind unary_op = CurrentToken(); |
ConsumeToken(); |
@@ -6286,7 +6309,7 @@ |
const bool saved_mode = SetAllowFunctionLiterals(true); |
ArgumentListNode* arguments; |
if (implicit_arguments == NULL) { |
- arguments = new ArgumentListNode(token_index_); |
+ arguments = new ArgumentListNode(TokenIndex()); |
} else { |
arguments = implicit_arguments; |
} |
@@ -6335,7 +6358,7 @@ |
const String& func_name, |
intptr_t ident_pos) { |
TRACE_PARSER("ParseStaticCall"); |
- const intptr_t call_pos = token_index_; |
+ const intptr_t call_pos = TokenIndex(); |
ASSERT(CurrentToken() == Token::kLPAREN); |
ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); |
const int num_arguments = arguments->length(); |
@@ -6385,7 +6408,7 @@ |
} else { |
ArgumentListNode* arguments = new ArgumentListNode(ident_pos); |
arguments->Add(new LiteralNode( |
- token_index_, Integer::ZoneHandle(Integer::New(ident_pos)))); |
+ TokenIndex(), Integer::ZoneHandle(Integer::New(ident_pos)))); |
return MakeStaticCall(kStaticResolutionExceptionName, |
kThrowNewName, |
arguments); |
@@ -6398,7 +6421,7 @@ |
AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { |
TRACE_PARSER("ParseInstanceCall"); |
- const intptr_t call_pos = token_index_; |
+ const intptr_t call_pos = TokenIndex(); |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg(call_pos, "left parenthesis expected"); |
} |
@@ -6409,7 +6432,7 @@ |
AstNode* Parser::ParseClosureCall(AstNode* closure) { |
TRACE_PARSER("ParseClosureCall"); |
- const intptr_t call_pos = token_index_; |
+ const intptr_t call_pos = TokenIndex(); |
ASSERT(CurrentToken() == Token::kLPAREN); |
EnsureExpressionTemp(); |
ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); |
@@ -6421,7 +6444,7 @@ |
const String& field_name) { |
TRACE_PARSER("ParseInstanceFieldAccess"); |
AstNode* access = NULL; |
- const intptr_t call_pos = token_index_; |
+ const intptr_t call_pos = TokenIndex(); |
if (Token::IsAssignmentOperator(CurrentToken())) { |
Token::Kind assignment_op = CurrentToken(); |
ConsumeToken(); |
@@ -6468,7 +6491,7 @@ |
intptr_t ident_pos) { |
TRACE_PARSER("ParseStaticFieldAccess"); |
AstNode* access = NULL; |
- const intptr_t call_pos = token_index_; |
+ const intptr_t call_pos = TokenIndex(); |
const Field& field = Field::ZoneHandle(cls.LookupStaticField(field_name)); |
Function& func = Function::ZoneHandle(); |
if (Token::IsAssignmentOperator(CurrentToken())) { |
@@ -6514,7 +6537,7 @@ |
field_name.ToCString()); |
return access; |
} |
- load_access = GenerateStaticFieldLookup(field, token_index_); |
+ load_access = GenerateStaticFieldLookup(field, TokenIndex()); |
} |
value = ExpandAssignableOp(call_pos, assignment_op, load_access, value); |
access = CreateAssignmentNode(load_access, value); |
@@ -6548,7 +6571,7 @@ |
field_name); |
} |
} else { |
- return GenerateStaticFieldLookup(field, token_index_); |
+ return GenerateStaticFieldLookup(field, TokenIndex()); |
} |
} |
return access; |
@@ -6605,7 +6628,7 @@ |
AstNode* Parser::ParsePostfixExpr() { |
TRACE_PARSER("ParsePostfixExpr"); |
- const intptr_t postfix_expr_pos = token_index_; |
+ const intptr_t postfix_expr_pos = TokenIndex(); |
AstNode* postfix_expr = ParsePrimary(); |
while (true) { |
AstNode* selector = NULL; |
@@ -6619,7 +6642,7 @@ |
left = LoadFieldIfUnresolved(left); |
} |
} |
- const intptr_t ident_pos = token_index_; |
+ const intptr_t ident_pos = TokenIndex(); |
String* ident = ExpectIdentifier("identifier expected"); |
if (CurrentToken() == Token::kLPAREN) { |
// Identifier followed by a opening paren: method call. |
@@ -6652,7 +6675,7 @@ |
} |
} |
} else if (CurrentToken() == Token::kLBRACK) { |
- const intptr_t bracket_pos = token_index_; |
+ const intptr_t bracket_pos = TokenIndex(); |
ConsumeToken(); |
left = LoadFieldIfUnresolved(left); |
const bool saved_mode = SetAllowFunctionLiterals(true); |
@@ -6920,7 +6943,7 @@ |
String::Handle(field.name()).ToCString()); |
} else { |
// The implicit static getter will throw the exception if necessary. |
- return new StaticGetterNode(token_index_, |
+ return new StaticGetterNode(TokenIndex(), |
Class::ZoneHandle(field.owner()), |
String::ZoneHandle(field.name())); |
} |
@@ -6954,7 +6977,7 @@ |
field.set_value(Instance::Handle()); |
// It is a compile-time error if evaluation of a compile-time constant |
// would raise an exception. |
- AppendErrorMsg(error, token_index_, |
+ AppendErrorMsg(error, TokenIndex(), |
"error initializing final field '%s'", |
String::Handle(field.name()).ToCString()); |
} else { |
@@ -6969,7 +6992,7 @@ |
} |
field.set_value(instance); |
} else { |
- return new StaticGetterNode(token_index_, |
+ return new StaticGetterNode(TokenIndex(), |
Class::ZoneHandle(field.owner()), |
String::ZoneHandle(field.name())); |
} |
@@ -7407,7 +7430,7 @@ |
TRACE_PARSER("ParseListLiteral"); |
ASSERT(type_pos >= 0); |
ASSERT(CurrentToken() == Token::kLBRACK || CurrentToken() == Token::kINDEX); |
- const intptr_t literal_pos = token_index_; |
+ const intptr_t literal_pos = TokenIndex(); |
bool is_empty_literal = CurrentToken() == Token::kINDEX; |
ConsumeToken(); |
@@ -7433,13 +7456,13 @@ |
// Parse the list elements. Note: there may be an optional extra |
// comma after the last element. |
- ArrayNode* list = new ArrayNode(token_index_, type_arguments); |
+ ArrayNode* list = new ArrayNode(TokenIndex(), type_arguments); |
if (!is_empty_literal) { |
const bool saved_mode = SetAllowFunctionLiterals(true); |
const String& dst_name = String::ZoneHandle( |
String::NewSymbol("list literal element")); |
while (CurrentToken() != Token::kRBRACK) { |
- const intptr_t element_pos = token_index_; |
+ const intptr_t element_pos = TokenIndex(); |
AstNode* element = ParseExpr(is_const); |
if (FLAG_enable_type_checks && |
!is_const && |
@@ -7571,7 +7594,7 @@ |
TRACE_PARSER("ParseMapLiteral"); |
ASSERT(type_pos >= 0); |
ASSERT(CurrentToken() == Token::kLBRACE); |
- const intptr_t literal_pos = token_index_; |
+ const intptr_t literal_pos = TokenIndex(); |
ConsumeToken(); |
AbstractType& value_type = Type::ZoneHandle(Type::DynamicType()); |
@@ -7619,7 +7642,7 @@ |
// The kv_pair array is temporary and of element type Dynamic. It is passed |
// to the factory to initialize a properly typed map. |
ArrayNode* kv_pairs = |
- new ArrayNode(token_index_, TypeArguments::ZoneHandle()); |
+ new ArrayNode(TokenIndex(), TypeArguments::ZoneHandle()); |
const String& dst_name = String::ZoneHandle( |
String::NewSymbol("list literal element")); |
while (CurrentToken() != Token::kRBRACE) { |
@@ -7634,7 +7657,7 @@ |
} |
ExpectToken(Token::kCOLON); |
const bool saved_mode = SetAllowFunctionLiterals(true); |
- const intptr_t value_pos = token_index_; |
+ const intptr_t value_pos = TokenIndex(); |
AstNode* value = ParseExpr(is_const); |
SetAllowFunctionLiterals(saved_mode); |
if (FLAG_enable_type_checks && |
@@ -7697,7 +7720,7 @@ |
const Class& immutable_map_class = |
Class::Handle(LookupImplClass(immutable_map_class_name)); |
ASSERT(!immutable_map_class.IsNull()); |
- ArgumentListNode* constr_args = new ArgumentListNode(token_index_); |
+ ArgumentListNode* constr_args = new ArgumentListNode(TokenIndex()); |
constr_args->Add(new LiteralNode(literal_pos, key_value_array)); |
const String& constr_name = |
String::Handle(String::NewSymbol(kImmutableMapConstructorName)); |
@@ -7751,7 +7774,7 @@ |
is_const = true; |
ConsumeToken(); |
} |
- const intptr_t type_pos = token_index_; |
+ const intptr_t type_pos = TokenIndex(); |
Error& malformed_error = Error::Handle(); |
AbstractTypeArguments& type_arguments = AbstractTypeArguments::ZoneHandle( |
ParseTypeArguments(&malformed_error, |
@@ -7792,14 +7815,14 @@ |
AstNode* Parser::ParseNewOperator() { |
TRACE_PARSER("ParseNewOperator"); |
- const intptr_t new_pos = token_index_; |
+ const intptr_t new_pos = TokenIndex(); |
ASSERT((CurrentToken() == Token::kNEW) || (CurrentToken() == Token::kCONST)); |
bool is_const = (CurrentToken() == Token::kCONST); |
ConsumeToken(); |
if (!IsIdentifier()) { |
ErrorMsg("type name expected"); |
} |
- intptr_t type_pos = token_index_; |
+ intptr_t type_pos = TokenIndex(); |
const AbstractType& type = AbstractType::Handle( |
ParseType(ClassFinalizer::kFinalizeWellFormed)); |
// Malformed bounds never result in a compile time error, therefore, the |
@@ -7839,7 +7862,7 @@ |
if (CurrentToken() != Token::kLPAREN) { |
ErrorMsg("'(' expected"); |
} |
- intptr_t call_pos = token_index_; |
+ intptr_t call_pos = TokenIndex(); |
ArgumentListNode* arguments = ParseActualParameters(NULL, is_const); |
// A constructor has an implicit 'this' parameter (instance to construct) |
@@ -8061,7 +8084,7 @@ |
AstNode* Parser::ParseStringLiteral() { |
TRACE_PARSER("ParseStringLiteral"); |
AstNode* primary = NULL; |
- const intptr_t literal_start = token_index_; |
+ const intptr_t literal_start = TokenIndex(); |
ASSERT(CurrentToken() == Token::kSTRING); |
Token::Kind l1_token = LookaheadToken(1); |
if ((l1_token != Token::kSTRING) && |
@@ -8074,16 +8097,16 @@ |
} |
// String interpolation needed. |
bool is_compiletime_const = true; |
- ArrayNode* values = new ArrayNode(token_index_, TypeArguments::ZoneHandle()); |
+ ArrayNode* values = new ArrayNode(TokenIndex(), TypeArguments::ZoneHandle()); |
while (CurrentToken() == Token::kSTRING) { |
- values->AddElement(new LiteralNode(token_index_, *CurrentLiteral())); |
+ values->AddElement(new LiteralNode(TokenIndex(), *CurrentLiteral())); |
ConsumeToken(); |
while ((CurrentToken() == Token::kINTERPOL_VAR) || |
(CurrentToken() == Token::kINTERPOL_START)) { |
AstNode* expr = NULL; |
- const intptr_t expr_pos = token_index_; |
+ const intptr_t expr_pos = TokenIndex(); |
if (CurrentToken() == Token::kINTERPOL_VAR) { |
- expr = ResolveVarOrField(token_index_, *CurrentLiteral()); |
+ expr = ResolveVarOrField(TokenIndex(), *CurrentLiteral()); |
ASSERT(!expr->IsPrimaryNode()); |
ConsumeToken(); |
} else { |
@@ -8153,7 +8176,7 @@ |
if (CurrentToken() == Token::kINTERPOL_START) { |
ConsumeToken(); |
if (IsIdentifier()) { |
- resolved_name = ResolveImportVar(token_index_, *CurrentLiteral()); |
+ resolved_name = ResolveImportVar(TokenIndex(), *CurrentLiteral()); |
result = String::Concat(result, resolved_name); |
ConsumeToken(); |
if (CurrentToken() != Token::kINTERPOL_END) { |
@@ -8165,7 +8188,7 @@ |
} |
} else { |
ASSERT(CurrentToken() == Token::kINTERPOL_VAR); |
- resolved_name = ResolveImportVar(token_index_, *CurrentLiteral()); |
+ resolved_name = ResolveImportVar(TokenIndex(), *CurrentLiteral()); |
result = String::Concat(result, resolved_name); |
ConsumeToken(); |
} |
@@ -8200,7 +8223,7 @@ |
if (!scope_class.IsNull()) { |
TypeParameter& type_param = TypeParameter::ZoneHandle( |
scope_class.LookupTypeParameter(*(qual_ident.ident), |
- token_index_)); |
+ TokenIndex())); |
if (!type_param.IsNull()) { |
String& type_param_name = String::Handle(type_param.Name()); |
ErrorMsg(qual_ident.ident_pos, |
@@ -8229,20 +8252,20 @@ |
if (local == NULL) { |
ErrorMsg("receiver 'this' is not in scope"); |
} |
- primary = new LoadLocalNode(token_index_, *local); |
+ primary = new LoadLocalNode(TokenIndex(), *local); |
ConsumeToken(); |
} else if (CurrentToken() == Token::kINTEGER) { |
const Integer& literal = Integer::ZoneHandle(CurrentIntegerLiteral()); |
- primary = new LiteralNode(token_index_, literal); |
+ primary = new LiteralNode(TokenIndex(), literal); |
ConsumeToken(); |
} else if (CurrentToken() == Token::kTRUE) { |
- primary = new LiteralNode(token_index_, Bool::ZoneHandle(Bool::True())); |
+ primary = new LiteralNode(TokenIndex(), Bool::ZoneHandle(Bool::True())); |
ConsumeToken(); |
} else if (CurrentToken() == Token::kFALSE) { |
- primary = new LiteralNode(token_index_, Bool::ZoneHandle(Bool::False())); |
+ primary = new LiteralNode(TokenIndex(), Bool::ZoneHandle(Bool::False())); |
ConsumeToken(); |
} else if (CurrentToken() == Token::kNULL) { |
- primary = new LiteralNode(token_index_, Instance::ZoneHandle()); |
+ primary = new LiteralNode(TokenIndex(), Instance::ZoneHandle()); |
ConsumeToken(); |
} else if (CurrentToken() == Token::kLPAREN) { |
ConsumeToken(); |
@@ -8255,7 +8278,7 @@ |
if (double_value.IsNull()) { |
ErrorMsg("invalid double literal"); |
} |
- primary = new LiteralNode(token_index_, double_value); |
+ primary = new LiteralNode(TokenIndex(), double_value); |
ConsumeToken(); |
} else if (CurrentToken() == Token::kSTRING) { |
primary = ParseStringLiteral(); |