field_list.cpp 817 B

1234567891011121314151617181920212223242526272829
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "executable_semantics/ast/field_list.h"
  5. namespace Carbon {
  6. auto MakeFieldList(std::list<std::pair<std::string, Expression*>>* fields)
  7. -> FieldList* {
  8. auto e = new FieldList();
  9. e->fields = fields;
  10. return e;
  11. }
  12. auto MakeConsField(FieldList* e1, FieldList* e2) -> FieldList* {
  13. auto fields = new std::list<std::pair<std::string, Expression*>>();
  14. for (auto& field : *e1->fields) {
  15. fields->push_back(field);
  16. }
  17. for (auto& field : *e2->fields) {
  18. fields->push_back(field);
  19. }
  20. auto result = MakeFieldList(fields);
  21. result->has_explicit_comma = true;
  22. return result;
  23. }
  24. } // namespace Carbon