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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-value-factory.h" | 8 #include "src/ast-value-factory.h" |
9 #include "src/func-name-inferrer.h" | 9 #include "src/func-name-inferrer.h" |
10 #include "src/list-inl.h" | 10 #include "src/list-inl.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 void FuncNameInferrer::PushLiteralName(const AstRawString* name) { | 35 void FuncNameInferrer::PushLiteralName(const AstRawString* name) { |
36 if (IsOpen() && name != ast_value_factory_->prototype_string()) { | 36 if (IsOpen() && name != ast_value_factory_->prototype_string()) { |
37 names_stack_.Add(Name(name, kLiteralName), zone()); | 37 names_stack_.Add(Name(name, kLiteralName), zone()); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 void FuncNameInferrer::PushLiteralName(const AstValue* name) { | |
43 if (name->IsString()) { | |
44 PushLiteralName(name->AsString()); | |
45 } else if (name->IsNumber()) { | |
46 UNREACHABLE(); | |
arv (Not doing code reviews)
2014/12/10 23:38:13
removing
arv (Not doing code reviews)
2014/12/11 23:10:33
I removed all the changes to func-name-inferrer.
| |
47 double double_value = name->AsNumber(); | |
48 char array[100]; | |
49 const char* string = | |
50 DoubleToCString(double_value, Vector<char>(array, arraysize(array))); | |
51 PushLiteralName(ast_value_factory_->GetOneByteString(string)); | |
52 } else { | |
53 UNREACHABLE(); | |
54 } | |
55 } | |
56 | |
57 | |
58 void FuncNameInferrer::PushLiteralName(Expression* expression) { | |
59 if (expression->IsVariableProxy()) { | |
60 PushLiteralName(expression->AsVariableProxy()->raw_name()); | |
61 } else if (expression->IsLiteral()) { | |
62 PushLiteralName(expression->AsLiteral()->raw_value()); | |
63 } | |
64 } | |
65 | |
66 | |
42 void FuncNameInferrer::PushVariableName(const AstRawString* name) { | 67 void FuncNameInferrer::PushVariableName(const AstRawString* name) { |
43 if (IsOpen() && name != ast_value_factory_->dot_result_string()) { | 68 if (IsOpen() && name != ast_value_factory_->dot_result_string()) { |
44 names_stack_.Add(Name(name, kVariableName), zone()); | 69 names_stack_.Add(Name(name, kVariableName), zone()); |
45 } | 70 } |
46 } | 71 } |
47 | 72 |
48 | 73 |
49 const AstString* FuncNameInferrer::MakeNameFromStack() { | 74 const AstString* FuncNameInferrer::MakeNameFromStack() { |
50 return MakeNameFromStackHelper(0, ast_value_factory_->empty_string()); | 75 return MakeNameFromStackHelper(0, ast_value_factory_->empty_string()); |
51 } | 76 } |
(...skipping 24 matching lines...) Expand all Loading... | |
76 void FuncNameInferrer::InferFunctionsNames() { | 101 void FuncNameInferrer::InferFunctionsNames() { |
77 const AstString* func_name = MakeNameFromStack(); | 102 const AstString* func_name = MakeNameFromStack(); |
78 for (int i = 0; i < funcs_to_infer_.length(); ++i) { | 103 for (int i = 0; i < funcs_to_infer_.length(); ++i) { |
79 funcs_to_infer_[i]->set_raw_inferred_name(func_name); | 104 funcs_to_infer_[i]->set_raw_inferred_name(func_name); |
80 } | 105 } |
81 funcs_to_infer_.Rewind(0); | 106 funcs_to_infer_.Rewind(0); |
82 } | 107 } |
83 | 108 |
84 | 109 |
85 } } // namespace v8::internal | 110 } } // namespace v8::internal |
OLD | NEW |