OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/func-name-inferrer.h" | 5 #include "src/parsing/func-name-inferrer.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/list-inl.h" | 9 #include "src/list-inl.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 void FuncNameInferrer::PushVariableName(const AstRawString* name) { | 41 void FuncNameInferrer::PushVariableName(const AstRawString* name) { |
42 if (IsOpen() && name != ast_value_factory_->dot_result_string()) { | 42 if (IsOpen() && name != ast_value_factory_->dot_result_string()) { |
43 names_stack_.Add(Name(name, kVariableName), zone()); | 43 names_stack_.Add(Name(name, kVariableName), zone()); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 void FuncNameInferrer::RemoveAsyncKeywordFromEnd() { | 47 void FuncNameInferrer::RemoveAsyncKeywordFromEnd() { |
48 DCHECK(names_stack_.length() > 0); | 48 if (IsOpen()) { |
caitp
2016/11/18 17:18:33
I like the straight forward fix, thanks. lgtm
| |
49 DCHECK(names_stack_.last().name->IsOneByteEqualTo("async")); | 49 DCHECK(names_stack_.length() > 0); |
50 names_stack_.RemoveLast(); | 50 DCHECK(names_stack_.last().name->IsOneByteEqualTo("async")); |
51 names_stack_.RemoveLast(); | |
52 } | |
51 } | 53 } |
52 | 54 |
53 const AstString* FuncNameInferrer::MakeNameFromStack() { | 55 const AstString* FuncNameInferrer::MakeNameFromStack() { |
54 return MakeNameFromStackHelper(0, ast_value_factory_->empty_string()); | 56 return MakeNameFromStackHelper(0, ast_value_factory_->empty_string()); |
55 } | 57 } |
56 | 58 |
57 const AstString* FuncNameInferrer::MakeNameFromStackHelper( | 59 const AstString* FuncNameInferrer::MakeNameFromStackHelper( |
58 int pos, const AstString* prev) { | 60 int pos, const AstString* prev) { |
59 if (pos >= names_stack_.length()) return prev; | 61 if (pos >= names_stack_.length()) return prev; |
60 if (pos < names_stack_.length() - 1 && | 62 if (pos < names_stack_.length() - 1 && |
(...skipping 20 matching lines...) Expand all Loading... | |
81 const AstString* func_name = MakeNameFromStack(); | 83 const AstString* func_name = MakeNameFromStack(); |
82 for (int i = 0; i < funcs_to_infer_.length(); ++i) { | 84 for (int i = 0; i < funcs_to_infer_.length(); ++i) { |
83 funcs_to_infer_[i]->set_raw_inferred_name(func_name); | 85 funcs_to_infer_[i]->set_raw_inferred_name(func_name); |
84 } | 86 } |
85 funcs_to_infer_.Rewind(0); | 87 funcs_to_infer_.Rewind(0); |
86 } | 88 } |
87 | 89 |
88 | 90 |
89 } // namespace internal | 91 } // namespace internal |
90 } // namespace v8 | 92 } // namespace v8 |
OLD | NEW |