| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 "tools/gn/builder_record.h" | 5 #include "tools/gn/builder_record.h" |
| 6 | 6 |
| 7 #include "tools/gn/item.h" | 7 #include "tools/gn/item.h" |
| 8 | 8 |
| 9 BuilderRecord::BuilderRecord(ItemType type, const Label& label) | 9 BuilderRecord::BuilderRecord(ItemType type, const Label& label) |
| 10 : type_(type), | 10 : type_(type), |
| 11 label_(label), | 11 label_(label), |
| 12 originally_referenced_from_(nullptr), | 12 originally_referenced_from_(nullptr), |
| 13 should_generate_(false), | 13 should_generate_(false), |
| 14 resolved_(false) { | 14 resolved_(false) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 BuilderRecord::~BuilderRecord() { | 17 BuilderRecord::~BuilderRecord() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 const char* BuilderRecord::GetNameForType(ItemType type) { | 21 const char* BuilderRecord::GetNameForType(ItemType type) { |
| 22 switch (type) { | 22 switch (type) { |
| 23 case ITEM_TARGET: | 23 case ITEM_TARGET: |
| 24 return "target"; | 24 return "target"; |
| 25 case ITEM_CONFIG: | 25 case ITEM_CONFIG: |
| 26 return "config"; | 26 return "config"; |
| 27 case ITEM_TOOLCHAIN: | 27 case ITEM_TOOLCHAIN: |
| 28 return "toolchain"; | 28 return "toolchain"; |
| 29 case ITEM_POOL: |
| 30 return "pool"; |
| 29 case ITEM_UNKNOWN: | 31 case ITEM_UNKNOWN: |
| 30 default: | 32 default: |
| 31 return "unknown"; | 33 return "unknown"; |
| 32 } | 34 } |
| 33 } | 35 } |
| 34 | 36 |
| 35 // static | 37 // static |
| 36 bool BuilderRecord::IsItemOfType(const Item* item, ItemType type) { | 38 bool BuilderRecord::IsItemOfType(const Item* item, ItemType type) { |
| 37 switch (type) { | 39 switch (type) { |
| 38 case ITEM_TARGET: | 40 case ITEM_TARGET: |
| 39 return !!item->AsTarget(); | 41 return !!item->AsTarget(); |
| 40 case ITEM_CONFIG: | 42 case ITEM_CONFIG: |
| 41 return !!item->AsConfig(); | 43 return !!item->AsConfig(); |
| 42 case ITEM_TOOLCHAIN: | 44 case ITEM_TOOLCHAIN: |
| 43 return !!item->AsToolchain(); | 45 return !!item->AsToolchain(); |
| 46 case ITEM_POOL: |
| 47 return !!item->AsPool(); |
| 44 case ITEM_UNKNOWN: | 48 case ITEM_UNKNOWN: |
| 45 default: | 49 default: |
| 46 return false; | 50 return false; |
| 47 } | 51 } |
| 48 } | 52 } |
| 49 | 53 |
| 50 // static | 54 // static |
| 51 BuilderRecord::ItemType BuilderRecord::TypeOfItem(const Item* item) { | 55 BuilderRecord::ItemType BuilderRecord::TypeOfItem(const Item* item) { |
| 52 if (item->AsTarget()) | 56 if (item->AsTarget()) |
| 53 return ITEM_TARGET; | 57 return ITEM_TARGET; |
| 54 if (item->AsConfig()) | 58 if (item->AsConfig()) |
| 55 return ITEM_CONFIG; | 59 return ITEM_CONFIG; |
| 56 if (item->AsToolchain()) | 60 if (item->AsToolchain()) |
| 57 return ITEM_TOOLCHAIN; | 61 return ITEM_TOOLCHAIN; |
| 62 if (item->AsPool()) |
| 63 return ITEM_POOL; |
| 58 | 64 |
| 59 NOTREACHED(); | 65 NOTREACHED(); |
| 60 return ITEM_UNKNOWN; | 66 return ITEM_UNKNOWN; |
| 61 } | 67 } |
| 62 | 68 |
| 63 void BuilderRecord::AddDep(BuilderRecord* record) { | 69 void BuilderRecord::AddDep(BuilderRecord* record) { |
| 64 all_deps_.insert(record); | 70 all_deps_.insert(record); |
| 65 if (!record->resolved()) { | 71 if (!record->resolved()) { |
| 66 unresolved_deps_.insert(record); | 72 unresolved_deps_.insert(record); |
| 67 record->waiting_on_resolution_.insert(this); | 73 record->waiting_on_resolution_.insert(this); |
| 68 } | 74 } |
| 69 } | 75 } |
| OLD | NEW |