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

Unified Diff: runtime/vm/parser.h

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.h
diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h
index 9d9e50346ca2b5fac395f6ff8635c8f659cdc5fb..ebf38d3860419fa26b06797608636061ab54dcb9 100644
--- a/runtime/vm/parser.h
+++ b/runtime/vm/parser.h
@@ -233,8 +233,12 @@ class Parser : public ValueObject {
struct Block;
class TryStack;
- Parser(const Script& script, const Library& library, intptr_t token_pos);
- Parser(const Script& script, ParsedFunction* function, intptr_t token_pos);
+ Parser(const Script& script,
+ const Library& library,
+ TokenPosition token_pos);
+ Parser(const Script& script,
+ ParsedFunction* function,
+ TokenPosition token_pos);
~Parser();
// The function for which we will generate code.
@@ -274,7 +278,7 @@ class Parser : public ValueObject {
}
const Script& script() const { return script_; }
- void SetScript(const Script& script, intptr_t token_pos);
+ void SetScript(const Script& script, TokenPosition token_pos);
const Library& library() const { return library_; }
void set_library(const Library& value) const { library_ = value.raw(); }
@@ -294,8 +298,10 @@ class Parser : public ValueObject {
return script_.kind() == RawScript::kPatchTag;
}
- intptr_t TokenPos() const { return tokens_iterator_.CurrentPosition(); }
- intptr_t PrevTokenPos() const { return prev_token_pos_; }
+ TokenPosition TokenPos() const {
+ return tokens_iterator_.CurrentPosition();
+ }
+ TokenPosition PrevTokenPos() const { return prev_token_pos_; }
Token::Kind CurrentToken() {
if (token_kind_ == Token::kILLEGAL) {
@@ -314,7 +320,7 @@ class Parser : public ValueObject {
RawInteger* CurrentIntegerLiteral() const;
// Sets parser to given token position in the stream.
- void SetPosition(intptr_t position);
+ void SetPosition(TokenPosition position);
void ConsumeToken() {
// Reset cache and advance the token.
@@ -337,7 +343,7 @@ class Parser : public ValueObject {
void SkipToMatching();
void SkipToMatchingParenthesis();
void SkipBlock();
- intptr_t SkipMetadata();
+ TokenPosition SkipMetadata();
void SkipTypeArguments();
void SkipType(bool allow_void);
void SkipInitializers();
@@ -362,7 +368,7 @@ class Parser : public ValueObject {
AstNode* DartPrint(const char* str);
- void CheckConstructorCallTypeArguments(intptr_t pos,
+ void CheckConstructorCallTypeArguments(TokenPosition pos,
const Function& constructor,
const TypeArguments& type_arguments);
@@ -374,7 +380,7 @@ class Parser : public ValueObject {
// Concatenate and report an already formatted error and a new error message.
static void ReportErrors(const Error& prev_error,
- const Script& script, intptr_t token_pos,
+ const Script& script, TokenPosition token_pos,
const char* format, ...) PRINTF_ATTRIBUTE(4, 5);
// Report error message at location of current token in current script.
@@ -383,62 +389,62 @@ class Parser : public ValueObject {
void ReportErrorBefore(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
// Report error message at given location in current script.
- void ReportError(intptr_t token_pos,
+ void ReportError(TokenPosition token_pos,
const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4);
// Report warning message at location of current token in current script.
void ReportWarning(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3);
// Report warning message at given location in current script.
- void ReportWarning(intptr_t token_pos,
+ void ReportWarning(TokenPosition token_pos,
const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4);
void CheckRecursiveInvocation();
- const Instance& EvaluateConstExpr(intptr_t expr_pos, AstNode* expr);
+ const Instance& EvaluateConstExpr(TokenPosition expr_pos, AstNode* expr);
StaticGetterNode* RunStaticFieldInitializer(const Field& field,
- intptr_t field_ref_pos);
+ TokenPosition field_ref_pos);
RawObject* EvaluateConstConstructorCall(const Class& type_class,
const TypeArguments& type_arguments,
const Function& constructor,
ArgumentListNode* arguments);
- LiteralNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr);
+ LiteralNode* FoldConstExpr(TokenPosition expr_pos, AstNode* expr);
// Support for parsing of scripts.
void ParseTopLevel();
void ParseEnumDeclaration(const GrowableObjectArray& pending_classes,
const Object& tl_owner,
- intptr_t metadata_pos);
+ TokenPosition metadata_pos);
void ParseEnumDefinition(const Class& cls);
void ParseClassDeclaration(const GrowableObjectArray& pending_classes,
const Object& tl_owner,
- intptr_t metadata_pos);
+ TokenPosition metadata_pos);
void ParseClassDefinition(const Class& cls);
void ParseMixinAppAlias(const GrowableObjectArray& pending_classes,
const Object& tl_owner,
- intptr_t metadata_pos);
+ TokenPosition metadata_pos);
void ParseTypedef(const GrowableObjectArray& pending_classes,
const Object& tl_owner,
- intptr_t metadata_pos);
+ TokenPosition metadata_pos);
void ParseTopLevelVariable(TopLevel* top_level,
- const Object& owner, intptr_t metadata_pos);
+ const Object& owner, TokenPosition metadata_pos);
void ParseTopLevelFunction(TopLevel* top_level,
- const Object& owner, intptr_t metadata_pos);
+ const Object& owner, TokenPosition metadata_pos);
void ParseTopLevelAccessor(TopLevel* top_level,
- const Object& owner, intptr_t metadata_pos);
+ const Object& owner, TokenPosition metadata_pos);
RawArray* EvaluateMetadata();
RawFunction::AsyncModifier ParseFunctionModifier();
// Support for parsing libraries.
RawObject* CallLibraryTagHandler(Dart_LibraryTag tag,
- intptr_t token_pos,
+ TokenPosition token_pos,
const String& url);
void ParseIdentList(GrowableObjectArray* names);
void ParseLibraryDefinition(const Object& tl_owner);
void ParseLibraryName();
void ParseLibraryImportExport(const Object& tl_owner,
- intptr_t metadata_pos);
+ TokenPosition metadata_pos);
void ParseLibraryPart();
void ParsePartHeader();
void ParseLibraryNameObsoleteSyntax();
@@ -464,7 +470,7 @@ class Parser : public ValueObject {
void ParseFieldDefinition(ClassDesc* members, MemberDesc* field);
void CheckMemberNameConflict(ClassDesc* members, MemberDesc* member);
void ParseClassMemberDefinition(ClassDesc* members,
- intptr_t metadata_pos);
+ TokenPosition metadata_pos);
void ParseFormalParameter(bool allow_explicit_default_value,
bool evaluate_metadata,
ParamList* params);
@@ -483,14 +489,14 @@ class Parser : public ValueObject {
LocalVariable* receiver,
GrowableArray<Field*>* initialized_fields);
AstNode* CheckDuplicateFieldInit(
- intptr_t init_pos,
+ TokenPosition init_pos,
GrowableArray<Field*>* initialized_fields,
AstNode* instance,
Field* field,
AstNode* init_value);
StaticCallNode* GenerateSuperConstructorCall(
const Class& cls,
- intptr_t supercall_pos,
+ TokenPosition supercall_pos,
LocalVariable* receiver,
ArgumentListNode* forwarding_args);
StaticCallNode* ParseSuperInitializer(
@@ -507,7 +513,7 @@ class Parser : public ValueObject {
void ParseInterfaceList(const Class& cls);
RawAbstractType* ParseMixins(const AbstractType& super_type);
static StaticCallNode* BuildInvocationMirrorAllocation(
- intptr_t call_pos,
+ TokenPosition call_pos,
const String& function_name,
const ArgumentListNode& function_args,
const LocalVariable* temp,
@@ -515,18 +521,19 @@ class Parser : public ValueObject {
// Build arguments for a NoSuchMethodCall. If LocalVariable temp is not NULL,
// the last argument is stored in temp.
static ArgumentListNode* BuildNoSuchMethodArguments(
- intptr_t call_pos,
+ TokenPosition call_pos,
const String& function_name,
const ArgumentListNode& function_args,
const LocalVariable* temp,
bool is_super_invocation);
- RawFunction* GetSuperFunction(intptr_t token_pos,
+ RawFunction* GetSuperFunction(TokenPosition token_pos,
const String& name,
ArgumentListNode* arguments,
bool resolve_getter,
bool* is_no_such_method);
AstNode* ParseSuperCall(const String& function_name);
- AstNode* ParseSuperFieldAccess(const String& field_name, intptr_t field_pos);
+ AstNode* ParseSuperFieldAccess(const String& field_name,
+ TokenPosition field_pos);
AstNode* ParseSuperOperator();
AstNode* BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super);
@@ -534,7 +541,7 @@ class Parser : public ValueObject {
void SetupDefaultsForOptionalParams(const ParamList& params);
ClosureNode* CreateImplicitClosureNode(const Function& func,
- intptr_t token_pos,
+ TokenPosition token_pos,
AstNode* receiver);
static void AddFormalParamsToFunction(const ParamList* params,
const Function& func);
@@ -558,21 +565,21 @@ class Parser : public ValueObject {
void BuildDispatcherScope(const Function& func,
const ArgumentsDescriptor& desc);
- void EnsureHasReturnStatement(SequenceNode* seq, intptr_t return_pos);
+ void EnsureHasReturnStatement(SequenceNode* seq, TokenPosition return_pos);
void ChainNewBlock(LocalScope* outer_scope);
void OpenBlock();
void OpenLoopBlock();
void OpenFunctionBlock(const Function& func);
void OpenAsyncClosure();
- RawFunction* OpenAsyncFunction(intptr_t formal_param_pos);
- RawFunction* OpenSyncGeneratorFunction(intptr_t func_pos);
+ RawFunction* OpenAsyncFunction(TokenPosition formal_param_pos);
+ RawFunction* OpenSyncGeneratorFunction(TokenPosition func_pos);
SequenceNode* CloseSyncGenFunction(const Function& closure,
SequenceNode* closure_node);
void AddSyncGenClosureParameters(ParamList* params);
void AddAsyncGenClosureParameters(ParamList* params);
// Support for async* functions.
- RawFunction* OpenAsyncGeneratorFunction(intptr_t func_pos);
+ RawFunction* OpenAsyncGeneratorFunction(TokenPosition func_pos);
SequenceNode* CloseAsyncGeneratorFunction(const Function& closure,
SequenceNode* closure_node);
void OpenAsyncGeneratorClosure();
@@ -596,10 +603,10 @@ class Parser : public ValueObject {
LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope,
bool test_only);
void CaptureInstantiator();
- AstNode* LoadReceiver(intptr_t token_pos);
+ AstNode* LoadReceiver(TokenPosition token_pos);
AstNode* LoadFieldIfUnresolved(AstNode* node);
AstNode* LoadClosure(PrimaryNode* primary);
- InstanceGetterNode* CallGetter(intptr_t token_pos,
+ InstanceGetterNode* CallGetter(TokenPosition token_pos,
AstNode* object,
const String& name);
@@ -610,7 +617,7 @@ class Parser : public ValueObject {
AstNode* ParseDoWhileStatement(String* label_name);
AstNode* ParseForStatement(String* label_name);
AstNode* ParseAwaitForStatement(String* label_name);
- AstNode* ParseForInStatement(intptr_t forin_pos, SourceLabel* label);
+ AstNode* ParseForInStatement(TokenPosition forin_pos, SourceLabel* label);
RawClass* CheckCaseExpressions(const GrowableArray<LiteralNode*>& values);
CaseNode* ParseCaseClause(LocalVariable* switch_expr_value,
GrowableArray<LiteralNode*>* case_expr_values,
@@ -634,7 +641,7 @@ class Parser : public ValueObject {
LocalVariable* saved_exception_var,
LocalVariable* saved_stack_trace_var);
// Parse all the catch clause of a try.
- SequenceNode* ParseCatchClauses(intptr_t handler_pos,
+ SequenceNode* ParseCatchClauses(TokenPosition handler_pos,
bool is_async,
LocalVariable* exception_var,
LocalVariable* stack_trace_var,
@@ -717,15 +724,15 @@ class Parser : public ValueObject {
String* ParseImportStringLiteral();
AstNode* ParseCompoundLiteral();
AstNode* ParseSymbolLiteral();
- AstNode* ParseListLiteral(intptr_t type_pos,
+ AstNode* ParseListLiteral(TokenPosition type_pos,
bool is_const,
const TypeArguments& type_arguments);
- AstNode* ParseMapLiteral(intptr_t type_pos,
+ AstNode* ParseMapLiteral(TokenPosition type_pos,
bool is_const,
const TypeArguments& type_arguments);
RawFunction* BuildConstructorClosureFunction(const Function& ctr,
- intptr_t token_pos);
+ TokenPosition token_pos);
AstNode* ParseNewOperator(Token::Kind op_kind);
void ParseConstructorClosurization(Function* constructor,
TypeArguments* type_arguments);
@@ -735,24 +742,25 @@ class Parser : public ValueObject {
bool require_const);
AstNode* ParseStaticCall(const Class& cls,
const String& method_name,
- intptr_t ident_pos);
+ TokenPosition ident_pos);
AstNode* ParseInstanceCall(AstNode* receiver,
const String& method_name,
- intptr_t ident_pos,
+ TokenPosition ident_pos,
bool is_conditional);
AstNode* ParseClosureCall(AstNode* closure);
AstNode* GenerateStaticFieldLookup(const Field& field,
- intptr_t ident_pos);
+ TokenPosition ident_pos);
AstNode* GenerateStaticFieldAccess(const Class& cls,
const String& field_name,
- intptr_t ident_pos);
+ TokenPosition ident_pos);
LocalVariable* LookupLocalScope(const String& ident);
- void CheckInstanceFieldAccess(intptr_t field_pos, const String& field_name);
+ void CheckInstanceFieldAccess(TokenPosition field_pos,
+ const String& field_name);
bool ParsingStaticMember() const;
const AbstractType* ReceiverType(const Class& cls);
bool IsInstantiatorRequired() const;
- bool ResolveIdentInLocalScope(intptr_t ident_pos,
+ bool ResolveIdentInLocalScope(TokenPosition ident_pos,
const String &ident,
AstNode** node);
static const bool kResolveLocally = true;
@@ -760,28 +768,29 @@ class Parser : public ValueObject {
// Resolve a primary identifier in the library or prefix scope and
// generate the corresponding AstNode.
- AstNode* ResolveIdentInCurrentLibraryScope(intptr_t ident_pos,
+ AstNode* ResolveIdentInCurrentLibraryScope(TokenPosition ident_pos,
const String& ident);
- AstNode* ResolveIdentInPrefixScope(intptr_t ident_pos,
+ AstNode* ResolveIdentInPrefixScope(TokenPosition ident_pos,
const LibraryPrefix& prefix,
const String& ident);
- AstNode* ResolveIdent(intptr_t ident_pos,
+ AstNode* ResolveIdent(TokenPosition ident_pos,
const String& ident,
bool allow_closure_names);
- RawString* ResolveImportVar(intptr_t ident_pos, const String& ident);
- AstNode* OptimizeBinaryOpNode(intptr_t op_pos,
+ RawString* ResolveImportVar(TokenPosition ident_pos, const String& ident);
+ AstNode* OptimizeBinaryOpNode(TokenPosition op_pos,
Token::Kind binary_op,
AstNode* lhs,
AstNode* rhs);
- AstNode* ExpandAssignableOp(intptr_t op_pos,
+ AstNode* ExpandAssignableOp(TokenPosition op_pos,
Token::Kind assignment_op,
AstNode* lhs,
AstNode* rhs);
LetNode* PrepareCompoundAssignmentNodes(AstNode** expr);
- LocalVariable* CreateTempConstVariable(intptr_t token_pos, const char* s);
+ LocalVariable* CreateTempConstVariable(TokenPosition token_pos,
+ const char* s);
- static SequenceNode* NodeAsSequenceNode(intptr_t sequence_pos,
+ static SequenceNode* NodeAsSequenceNode(TokenPosition sequence_pos,
AstNode* node,
LocalScope* scope);
@@ -790,10 +799,11 @@ class Parser : public ValueObject {
const String& func_name,
ArgumentListNode* arguments);
String& Interpolate(const GrowableArray<AstNode*>& values);
- AstNode* MakeAssertCall(intptr_t begin, intptr_t end);
- AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type,
- LibraryPrefix* prefix = NULL);
- AstNode* ThrowNoSuchMethodError(intptr_t call_pos,
+ AstNode* MakeAssertCall(TokenPosition begin, TokenPosition end);
+ AstNode* ThrowTypeError(TokenPosition type_pos,
+ const AbstractType& type,
+ LibraryPrefix* prefix = NULL);
+ AstNode* ThrowNoSuchMethodError(TokenPosition call_pos,
const Class& cls,
const String& function_name,
ArgumentListNode* function_arguments,
@@ -807,29 +817,30 @@ class Parser : public ValueObject {
void CheckOperatorArity(const MemberDesc& member);
void EnsureExpressionTemp();
- bool IsLegalAssignableSyntax(AstNode* expr, intptr_t end_pos);
+ bool IsLegalAssignableSyntax(AstNode* expr, TokenPosition end_pos);
AstNode* CreateAssignmentNode(AstNode* original,
AstNode* rhs,
const String* left_ident,
- intptr_t left_pos,
+ TokenPosition left_pos,
bool is_compound = false);
AstNode* InsertClosureCallNodes(AstNode* condition);
ConstructorCallNode* CreateConstructorCallNode(
- intptr_t token_pos,
+ TokenPosition token_pos,
const TypeArguments& type_arguments,
const Function& constructor,
ArgumentListNode* arguments);
void AddEqualityNullCheck();
- AstNode* BuildClosureCall(intptr_t token_pos,
+ AstNode* BuildClosureCall(TokenPosition token_pos,
AstNode* closure,
ArgumentListNode* arguments);
- RawInstance* TryCanonicalize(const Instance& instance, intptr_t token_pos);
- void CacheConstantValue(intptr_t token_pos, const Instance& value);
- bool GetCachedConstant(intptr_t token_pos, Instance* value);
+ RawInstance* TryCanonicalize(const Instance& instance,
+ TokenPosition token_pos);
+ void CacheConstantValue(TokenPosition token_pos, const Instance& value);
+ bool GetCachedConstant(TokenPosition token_pos, Instance* value);
Thread* thread() const { return thread_; }
Isolate* isolate() const { return isolate_; }
@@ -841,7 +852,7 @@ class Parser : public ValueObject {
Script& script_;
TokenStream::Iterator tokens_iterator_;
Token::Kind token_kind_; // Cached token kind for current token.
- intptr_t prev_token_pos_;
+ TokenPosition prev_token_pos_;
Block* current_block_;
// is_top_level_ is true if parsing the "top level" of a compilation unit,
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698