OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "func-name-inferrer.h" | 31 #include "func-name-inferrer.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 | 36 |
37 void FuncNameInferrer::PushEnclosingName(Handle<String> name) { | 37 void FuncNameInferrer::PushEnclosingName(Handle<String> name) { |
38 // Enclosing name is a name of a constructor function. To check | 38 // Enclosing name is a name of a constructor function. To check |
39 // that it is really a constructor, we check that it is not empty | 39 // that it is really a constructor, we check that it is not empty |
40 // and starts with a capital letter. | 40 // and starts with a capital letter. |
41 if (name->length() > 0 && Runtime::IsUpperCaseChar(name->Get(0))) { | 41 if (name->length() > 0 && Runtime::IsUpperCaseChar( |
| 42 Isolate::Current()->runtime_state(), name->Get(0))) { |
42 names_stack_.Add(name); | 43 names_stack_.Add(name); |
43 } | 44 } |
44 } | 45 } |
45 | 46 |
46 | 47 |
47 void FuncNameInferrer::PushLiteralName(Handle<String> name) { | 48 void FuncNameInferrer::PushLiteralName(Handle<String> name) { |
48 if (IsOpen() && !Heap::prototype_symbol()->Equals(*name)) { | 49 if (IsOpen() && !HEAP->prototype_symbol()->Equals(*name)) { |
49 names_stack_.Add(name); | 50 names_stack_.Add(name); |
50 } | 51 } |
51 } | 52 } |
52 | 53 |
53 | 54 |
54 void FuncNameInferrer::PushVariableName(Handle<String> name) { | 55 void FuncNameInferrer::PushVariableName(Handle<String> name) { |
55 if (IsOpen() && !Heap::result_symbol()->Equals(*name)) { | 56 if (IsOpen() && !HEAP->result_symbol()->Equals(*name)) { |
56 names_stack_.Add(name); | 57 names_stack_.Add(name); |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
60 | 61 |
61 Handle<String> FuncNameInferrer::MakeNameFromStack() { | 62 Handle<String> FuncNameInferrer::MakeNameFromStack() { |
62 if (names_stack_.is_empty()) { | 63 if (names_stack_.is_empty()) { |
63 return Factory::empty_string(); | 64 return FACTORY->empty_string(); |
64 } else { | 65 } else { |
65 return MakeNameFromStackHelper(1, names_stack_.at(0)); | 66 return MakeNameFromStackHelper(1, names_stack_.at(0)); |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 | 70 |
70 Handle<String> FuncNameInferrer::MakeNameFromStackHelper(int pos, | 71 Handle<String> FuncNameInferrer::MakeNameFromStackHelper(int pos, |
71 Handle<String> prev) { | 72 Handle<String> prev) { |
72 if (pos >= names_stack_.length()) { | 73 if (pos >= names_stack_.length()) { |
73 return prev; | 74 return prev; |
74 } else { | 75 } else { |
75 Handle<String> curr = Factory::NewConsString(dot_, names_stack_.at(pos)); | 76 Handle<String> curr = FACTORY->NewConsString(dot_, names_stack_.at(pos)); |
76 return MakeNameFromStackHelper(pos + 1, Factory::NewConsString(prev, curr)); | 77 return MakeNameFromStackHelper(pos + 1, FACTORY->NewConsString(prev, curr)); |
77 } | 78 } |
78 } | 79 } |
79 | 80 |
80 | 81 |
81 void FuncNameInferrer::InferFunctionsNames() { | 82 void FuncNameInferrer::InferFunctionsNames() { |
82 Handle<String> func_name = MakeNameFromStack(); | 83 Handle<String> func_name = MakeNameFromStack(); |
83 for (int i = 0; i < funcs_to_infer_.length(); ++i) { | 84 for (int i = 0; i < funcs_to_infer_.length(); ++i) { |
84 funcs_to_infer_[i]->set_inferred_name(func_name); | 85 funcs_to_infer_[i]->set_inferred_name(func_name); |
85 } | 86 } |
86 funcs_to_infer_.Rewind(0); | 87 funcs_to_infer_.Rewind(0); |
87 } | 88 } |
88 | 89 |
89 | 90 |
90 } } // namespace v8::internal | 91 } } // namespace v8::internal |
OLD | NEW |