OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkSLSymbolTable.h" | 8 #include "SkSLSymbolTable.h" |
9 #include "SkSLUnresolvedFunction.h" | 9 #include "SkSLUnresolvedFunction.h" |
10 | 10 |
11 namespace SkSL { | 11 namespace SkSL { |
12 | 12 |
13 std::vector<const FunctionDeclaration*> SymbolTable::GetFunctions(const Symbol&
s) { | 13 std::vector<const FunctionDeclaration*> SymbolTable::GetFunctions(const Symbol&
s) { |
14 switch (s.fKind) { | 14 switch (s.fKind) { |
15 case Symbol::kFunctionDeclaration_Kind: | 15 case Symbol::kFunctionDeclaration_Kind: |
16 return { &((FunctionDeclaration&) s) }; | 16 return { &((FunctionDeclaration&) s) }; |
17 case Symbol::kUnresolvedFunction_Kind: | 17 case Symbol::kUnresolvedFunction_Kind: |
18 return ((UnresolvedFunction&) s).fFunctions; | 18 return ((UnresolvedFunction&) s).fFunctions; |
19 default: | 19 default: |
20 return { }; | 20 return std::vector<const FunctionDeclaration*>(); |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 const Symbol* SymbolTable::operator[](const std::string& name) { | 24 const Symbol* SymbolTable::operator[](const std::string& name) { |
25 const auto& entry = fSymbols.find(name); | 25 const auto& entry = fSymbols.find(name); |
26 if (entry == fSymbols.end()) { | 26 if (entry == fSymbols.end()) { |
27 if (fParent) { | 27 if (fParent) { |
28 return (*fParent)[name]; | 28 return (*fParent)[name]; |
29 } | 29 } |
30 return nullptr; | 30 return nullptr; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 UnresolvedFunction* u = new UnresolvedFunction(std::move(functions))
; | 91 UnresolvedFunction* u = new UnresolvedFunction(std::move(functions))
; |
92 fSymbols[name] = u; | 92 fSymbols[name] = u; |
93 this->takeOwnership(u); | 93 this->takeOwnership(u); |
94 } | 94 } |
95 } else { | 95 } else { |
96 fErrorReporter.error(symbol->fPosition, "symbol '" + name + "' was alrea
dy defined"); | 96 fErrorReporter.error(symbol->fPosition, "symbol '" + name + "' was alrea
dy defined"); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
OLD | NEW |