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

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

Issue 11411271: Remove support for interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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
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 #ifndef VM_PARSER_H_ 5 #ifndef VM_PARSER_H_
6 #define VM_PARSER_H_ 6 #define VM_PARSER_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "vm/ast.h" 10 #include "vm/ast.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); 111 DISALLOW_COPY_AND_ASSIGN(ParsedFunction);
112 }; 112 };
113 113
114 114
115 class Parser : public ValueObject { 115 class Parser : public ValueObject {
116 public: 116 public:
117 Parser(const Script& script, const Library& library); 117 Parser(const Script& script, const Library& library);
118 Parser(const Script& script, const Function& function, intptr_t token_pos); 118 Parser(const Script& script, const Function& function, intptr_t token_pos);
119 119
120 // Parse the top level of a whole script file and register declared classes 120 // Parse the top level of a whole script file and register declared classes
121 // and interfaces in the given library. 121 // in the given library.
122 static void ParseCompilationUnit(const Library& library, 122 static void ParseCompilationUnit(const Library& library,
123 const Script& script); 123 const Script& script);
124 124
125 static void ParseFunction(ParsedFunction* parsed_function); 125 static void ParseFunction(ParsedFunction* parsed_function);
126 126
127 // Format and print a message with source location. 127 // Format and print a message with source location.
128 // A null script means no source and a negative token_pos means no position. 128 // A null script means no source and a negative token_pos means no position.
129 static void PrintMessage(const Script& script, 129 static void PrintMessage(const Script& script,
130 intptr_t token_pos, 130 intptr_t token_pos,
131 const char* message_header, 131 const char* message_header,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Therefore, the statements being parsed may or may not belong to the body 176 // Therefore, the statements being parsed may or may not belong to the body
177 // of the current_function(); they may belong to nested functions. 177 // of the current_function(); they may belong to nested functions.
178 // innermost_function() is the function that is currently being parsed. 178 // innermost_function() is the function that is currently being parsed.
179 // It is either the same as current_function(), or a lexically nested 179 // It is either the same as current_function(), or a lexically nested
180 // function. 180 // function.
181 // The function level of the current parsing scope reflects the function 181 // The function level of the current parsing scope reflects the function
182 // nesting. The function level is zero while parsing the body of the 182 // nesting. The function level is zero while parsing the body of the
183 // current_function(), but is greater than zero while parsing the body of 183 // current_function(), but is greater than zero while parsing the body of
184 // local functions nested in current_function(). 184 // local functions nested in current_function().
185 185
186 // The class or interface being parsed. 186 // The class being parsed.
187 const Class& current_class() const; 187 const Class& current_class() const;
188 void set_current_class(const Class& value); 188 void set_current_class(const Class& value);
189 189
190 // Parsing a library or a regular source script. 190 // Parsing a library or a regular source script.
191 bool is_library_source() const { 191 bool is_library_source() const {
192 return (script_.kind() == RawScript::kScriptTag) || 192 return (script_.kind() == RawScript::kScriptTag) ||
193 (script_.kind() == RawScript::kLibraryTag); 193 (script_.kind() == RawScript::kLibraryTag);
194 } 194 }
195 195
196 bool is_part_source() const { 196 bool is_part_source() const {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 RawObject* EvaluateConstConstructorCall( 286 RawObject* EvaluateConstConstructorCall(
287 const Class& type_class, 287 const Class& type_class,
288 const AbstractTypeArguments& type_arguments, 288 const AbstractTypeArguments& type_arguments,
289 const Function& constructor, 289 const Function& constructor,
290 ArgumentListNode* arguments); 290 ArgumentListNode* arguments);
291 AstNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr); 291 AstNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr);
292 292
293 // Support for parsing of scripts. 293 // Support for parsing of scripts.
294 void ParseTopLevel(); 294 void ParseTopLevel();
295 void ParseClassDefinition(const GrowableObjectArray& pending_classes); 295 void ParseClassDefinition(const GrowableObjectArray& pending_classes);
296 void ParseInterfaceDefinition(const GrowableObjectArray& pending_classes);
297 void ParseFunctionTypeAlias(const GrowableObjectArray& pending_classes); 296 void ParseFunctionTypeAlias(const GrowableObjectArray& pending_classes);
298 void ParseTopLevelVariable(TopLevel* top_level); 297 void ParseTopLevelVariable(TopLevel* top_level);
299 void ParseTopLevelFunction(TopLevel* top_level); 298 void ParseTopLevelFunction(TopLevel* top_level);
300 void ParseTopLevelAccessor(TopLevel* top_level); 299 void ParseTopLevelAccessor(TopLevel* top_level);
301 300
302 // Support for parsing libraries. 301 // Support for parsing libraries.
303 Dart_Handle CallLibraryTagHandler(Dart_LibraryTag tag, 302 Dart_Handle CallLibraryTagHandler(Dart_LibraryTag tag,
304 intptr_t token_pos, 303 intptr_t token_pos,
305 const String& url); 304 const String& url);
306 void ParseIdentList(GrowableObjectArray* names); 305 void ParseIdentList(GrowableObjectArray* names);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 LocalVariable* receiver); 344 LocalVariable* receiver);
346 AstNode* ParseSuperInitializer(const Class& cls, LocalVariable* receiver); 345 AstNode* ParseSuperInitializer(const Class& cls, LocalVariable* receiver);
347 AstNode* ParseInitializer(const Class& cls, 346 AstNode* ParseInitializer(const Class& cls,
348 LocalVariable* receiver, 347 LocalVariable* receiver,
349 GrowableArray<Field*>* initialized_fields); 348 GrowableArray<Field*>* initialized_fields);
350 void ParseConstructorRedirection(const Class& cls, LocalVariable* receiver); 349 void ParseConstructorRedirection(const Class& cls, LocalVariable* receiver);
351 void ParseInitializers(const Class& cls, 350 void ParseInitializers(const Class& cls,
352 LocalVariable* receiver, 351 LocalVariable* receiver,
353 GrowableArray<Field*>* initialized_fields); 352 GrowableArray<Field*>* initialized_fields);
354 String& ParseNativeDeclaration(); 353 String& ParseNativeDeclaration();
355 // TODO(srdjan): Return TypeArguments instead of Array?
356 RawArray* ParseInterfaceList(); 354 RawArray* ParseInterfaceList();
357 void AddInterfaceIfUnique(intptr_t interfaces_pos, 355 void AddInterfaceIfUnique(intptr_t interfaces_pos,
358 const GrowableObjectArray& interface_list, 356 const GrowableObjectArray& interface_list,
359 const AbstractType& interface); 357 const AbstractType& interface);
360 void AddInterfaces(intptr_t interfaces_pos, 358 void AddInterfaces(intptr_t interfaces_pos,
361 const Class& cls, 359 const Class& cls,
362 const Array& interfaces); 360 const Array& interfaces);
363 StaticCallNode* BuildInvocationMirrorAllocation( 361 StaticCallNode* BuildInvocationMirrorAllocation(
364 intptr_t call_pos, 362 intptr_t call_pos,
365 const String& function_name, 363 const String& function_name,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 567
570 SequenceNode* MakeImplicitConstructor(const Function& func); 568 SequenceNode* MakeImplicitConstructor(const Function& func);
571 AstNode* MakeStaticCall(const String& cls_name, 569 AstNode* MakeStaticCall(const String& cls_name,
572 const String& func_name, 570 const String& func_name,
573 ArgumentListNode* arguments); 571 ArgumentListNode* arguments);
574 String& Interpolate(ArrayNode* values); 572 String& Interpolate(ArrayNode* values);
575 AstNode* MakeAssertCall(intptr_t begin, intptr_t end); 573 AstNode* MakeAssertCall(intptr_t begin, intptr_t end);
576 AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type); 574 AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type);
577 AstNode* ThrowNoSuchMethodError(intptr_t call_pos, const String& name); 575 AstNode* ThrowNoSuchMethodError(intptr_t call_pos, const String& name);
578 576
579 void CheckFunctionIsCallable(intptr_t token_pos, const Function& function);
580 void CheckOperatorArity(const MemberDesc& member); 577 void CheckOperatorArity(const MemberDesc& member);
581 578
582 const LocalVariable* GetIncrementTempLocal(); 579 const LocalVariable* GetIncrementTempLocal();
583 void EnsureExpressionTemp(); 580 void EnsureExpressionTemp();
584 AstNode* CreateAssignmentNode(AstNode* original, AstNode* rhs); 581 AstNode* CreateAssignmentNode(AstNode* original, AstNode* rhs);
585 AstNode* InsertClosureCallNodes(AstNode* condition); 582 AstNode* InsertClosureCallNodes(AstNode* condition);
586 583
587 ConstructorCallNode* CreateConstructorCallNode( 584 ConstructorCallNode* CreateConstructorCallNode(
588 intptr_t token_pos, 585 intptr_t token_pos,
589 const AbstractTypeArguments& type_arguments, 586 const AbstractTypeArguments& type_arguments,
590 const Function& constructor, 587 const Function& constructor,
591 ArgumentListNode* arguments); 588 ArgumentListNode* arguments);
592 589
593 590
594 const Script& script_; 591 const Script& script_;
595 TokenStream::Iterator tokens_iterator_; 592 TokenStream::Iterator tokens_iterator_;
596 Token::Kind token_kind_; // Cached token kind for current token. 593 Token::Kind token_kind_; // Cached token kind for current token.
597 Block* current_block_; 594 Block* current_block_;
598 595
599 // is_top_level_ is true if parsing the "top level" of a compilation unit, 596 // is_top_level_ is true if parsing the "top level" of a compilation unit,
600 // that is interface and class definitions. 597 // that is class definitions, function type aliases, global functions,
598 // global variables.
601 bool is_top_level_; 599 bool is_top_level_;
602 600
603 // The member currently being parsed during "top level" parsing. 601 // The member currently being parsed during "top level" parsing.
604 MemberDesc* current_member_; 602 MemberDesc* current_member_;
605 603
606 // Parser mode to allow/disallow function literals. This is used in 604 // Parser mode to allow/disallow function literals. This is used in
607 // constructor initializer expressions to handle ambiguous grammar. 605 // constructor initializer expressions to handle ambiguous grammar.
608 bool SetAllowFunctionLiterals(bool value); 606 bool SetAllowFunctionLiterals(bool value);
609 bool allow_function_literals_; 607 bool allow_function_literals_;
610 608
611 // The function currently being compiled. 609 // The function currently being compiled.
612 const Function& current_function_; 610 const Function& current_function_;
613 611
614 // The function currently being parsed. 612 // The function currently being parsed.
615 Function& innermost_function_; 613 Function& innermost_function_;
616 614
617 // The class or interface currently being parsed, or the owner class of the 615 // The class currently being parsed, or the owner class of the
618 // function currently being parsed. It is used for primary identifier lookups. 616 // function currently being parsed. It is used for primary identifier lookups.
619 Class& current_class_; 617 Class& current_class_;
620 618
621 // The current library (and thus class dictionary) used to resolve names. 619 // The current library (and thus class dictionary) used to resolve names.
622 const Library& library_; 620 const Library& library_;
623 621
624 // List of try blocks seen so far, this is used to generate inlined finally 622 // List of try blocks seen so far, this is used to generate inlined finally
625 // code at all points in the try block where an exit from the block is 623 // code at all points in the try block where an exit from the block is
626 // done using 'return', 'break' or 'continue' statements. 624 // done using 'return', 'break' or 'continue' statements.
627 TryBlocks* try_blocks_list_; 625 TryBlocks* try_blocks_list_;
628 626
629 // Allocate temporary only once per function. 627 // Allocate temporary only once per function.
630 LocalVariable* expression_temp_; 628 LocalVariable* expression_temp_;
631 629
632 DISALLOW_COPY_AND_ASSIGN(Parser); 630 DISALLOW_COPY_AND_ASSIGN(Parser);
633 }; 631 };
634 632
635 } // namespace dart 633 } // namespace dart
636 634
637 #endif // VM_PARSER_H_ 635 #endif // VM_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698