Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2016 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SKSL_VARIABLE | |
| 9 #define SKSL_VARIABLE | |
| 10 | |
| 11 #include "SkSLModifiers.h" | |
| 12 #include "SkSLPosition.h" | |
| 13 #include "SkSLSymbol.h" | |
| 14 #include "SkSLType.h" | |
| 15 | |
| 16 namespace SkSL { | |
| 17 | |
| 18 /** | |
| 19 * Represents a variable, whether local, global, or a function parameter. This r epresents the | |
| 20 * variable itself (the storage location), which is shared between all VariableR eferences which | |
| 21 * read or write that storage location. | |
| 22 */ | |
| 23 struct Variable : public Symbol { | |
| 24 enum Storage { | |
| 25 kGlobal_Storage, | |
| 26 kLocal_Storage, | |
| 27 kParameter_Storage | |
| 28 }; | |
| 29 | |
| 30 Variable(Position position, Modifiers modifiers, std::string name, std::shar ed_ptr<Type> type, | |
| 31 Storage storage) | |
| 32 : INHERITED(position, kVariable_Kind, std::move(name)) | |
| 33 , fModifiers(modifiers) | |
| 34 , fType(type) | |
|
dogben
2016/06/21 21:52:52
nit: std::move
| |
| 35 , fStorage(storage) | |
| 36 , fIsReadFrom(false) | |
| 37 , fIsWrittenTo(false) {} | |
| 38 | |
| 39 virtual std::string description() const override { | |
| 40 return fModifiers.description() + fType->fName + " " + fName; | |
| 41 } | |
| 42 | |
| 43 const Modifiers fModifiers; | |
| 44 const std::string fValue; | |
|
dogben
2016/06/21 21:52:52
unused?
| |
| 45 const std::shared_ptr<Type> fType; | |
| 46 const Storage fStorage; | |
| 47 | |
| 48 mutable bool fIsReadFrom; | |
| 49 mutable bool fIsWrittenTo; | |
| 50 | |
| 51 typedef Symbol INHERITED; | |
| 52 }; | |
| 53 | |
| 54 } // namespace SkSL | |
| 55 | |
| 56 namespace std { | |
| 57 template <> | |
| 58 struct hash<SkSL::Variable> { | |
| 59 public : | |
| 60 size_t operator()(const SkSL::Variable &var) const{ | |
| 61 return hash<std::string>()(var.fName) ^ hash<std::string>()(var.fTyp e->description()); | |
| 62 } | |
| 63 }; | |
| 64 } // namespace std | |
| 65 | |
| 66 #endif | |
| OLD | NEW |