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

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

Issue 63983005: Simplify the desugaring of catch clauses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Parse catch clauses with a loop instead of recursion. Created 7 years, 1 month 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 "platform/assert.h"
11 #include "platform/globals.h"
10 #include "lib/invocation_mirror.h" 12 #include "lib/invocation_mirror.h"
13 #include "vm/allocation.h"
11 #include "vm/ast.h" 14 #include "vm/ast.h"
12 #include "vm/class_finalizer.h" 15 #include "vm/class_finalizer.h"
13 #include "vm/compiler_stats.h" 16 #include "vm/compiler_stats.h"
14 #include "vm/scanner.h" 17 #include "vm/object.h"
18 #include "vm/raw_object.h"
19 #include "vm/token.h"
15 20
16 namespace dart { 21 namespace dart {
17 22
18 // Forward declarations. 23 // Forward declarations.
19 class ArgumentsDescriptor; 24 class ArgumentsDescriptor;
20 class Function;
21 class Isolate; 25 class Isolate;
22 class LiteralToken; 26 class LocalScope;
23 class Script; 27 class LocalVariable;
24 class TokenStream; 28 class SourceLabel;
29 template <typename T> class GrowableArray;
25 30
26 struct TopLevel; 31 struct TopLevel;
27 class ClassDesc; 32 class ClassDesc;
28 struct MemberDesc; 33 struct MemberDesc;
29 struct ParamList; 34 struct ParamList;
30 struct QualIdent; 35 struct QualIdent;
31 struct CatchParamDesc;
32 struct FieldInitExpression;
33 36
34 // The class ParsedFunction holds the result of parsing a function. 37 // The class ParsedFunction holds the result of parsing a function.
35 class ParsedFunction : public ZoneAllocated { 38 class ParsedFunction : public ZoneAllocated {
36 public: 39 public:
37 explicit ParsedFunction(const Function& function) 40 explicit ParsedFunction(const Function& function)
38 : function_(function), 41 : function_(function),
39 node_sequence_(NULL), 42 node_sequence_(NULL),
40 instantiator_(NULL), 43 instantiator_(NULL),
41 default_parameter_values_(Array::ZoneHandle()), 44 default_parameter_values_(Array::ZoneHandle()),
42 saved_current_context_var_(NULL), 45 saved_current_context_var_(NULL),
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 AstNode* ParseDoWhileStatement(String* label_name); 502 AstNode* ParseDoWhileStatement(String* label_name);
500 AstNode* ParseForStatement(String* label_name); 503 AstNode* ParseForStatement(String* label_name);
501 AstNode* ParseForInStatement(intptr_t forin_pos, SourceLabel* label); 504 AstNode* ParseForInStatement(intptr_t forin_pos, SourceLabel* label);
502 RawClass* CheckCaseExpressions(const GrowableArray<LiteralNode*>& values); 505 RawClass* CheckCaseExpressions(const GrowableArray<LiteralNode*>& values);
503 CaseNode* ParseCaseClause(LocalVariable* switch_expr_value, 506 CaseNode* ParseCaseClause(LocalVariable* switch_expr_value,
504 GrowableArray<LiteralNode*>* case_expr_values, 507 GrowableArray<LiteralNode*>* case_expr_values,
505 SourceLabel* case_label); 508 SourceLabel* case_label);
506 AstNode* ParseSwitchStatement(String* label_name); 509 AstNode* ParseSwitchStatement(String* label_name);
507 510
508 // try/catch/finally parsing. 511 // try/catch/finally parsing.
509 void AddCatchParamsToScope(const CatchParamDesc& exception_param, 512 // Parse all the catch clause of a try.
510 const CatchParamDesc& stack_trace_param, 513 SequenceNode* ParseCatchClauses(intptr_t handler_pos,
511 LocalScope* scope); 514 LocalVariable* exception_var,
515 LocalVariable* stack_trace_var,
516 const GrowableObjectArray& handler_types,
517 bool* needs_stack_trace);
512 // Parse finally block and create an AST for it. 518 // Parse finally block and create an AST for it.
513 SequenceNode* ParseFinallyBlock(); 519 SequenceNode* ParseFinallyBlock();
514 // Adds try block to the list of try blocks seen so far. 520 // Adds try block to the list of try blocks seen so far.
515 void PushTryBlock(Block* try_block); 521 void PushTryBlock(Block* try_block);
516 // Pops the inner most try block from the list. 522 // Pops the inner most try block from the list.
517 TryBlocks* PopTryBlock(); 523 TryBlocks* PopTryBlock();
518 // Add specified node to try block list so that it can be patched with 524 // Add specified node to try block list so that it can be patched with
519 // inlined finally code if needed. 525 // inlined finally code if needed.
520 void AddNodeForFinallyInlining(AstNode* node); 526 void AddNodeForFinallyInlining(AstNode* node);
521 // Add the inlined finally block to the specified node. 527 // Add the inlined finally block to the specified node.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 intptr_t last_used_try_index_; 727 intptr_t last_used_try_index_;
722 728
723 bool unregister_pending_function_; 729 bool unregister_pending_function_;
724 730
725 DISALLOW_COPY_AND_ASSIGN(Parser); 731 DISALLOW_COPY_AND_ASSIGN(Parser);
726 }; 732 };
727 733
728 } // namespace dart 734 } // namespace dart
729 735
730 #endif // VM_PARSER_H_ 736 #endif // VM_PARSER_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698