1 // Copyright 2017 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <fstream> 8 #include <functional> 9 #include <list> 10 #include <map> 11 #include <string> 12 #include <vector> 13 14 #include "generator.h" 15 #include "types.h" 16 17 const std::map<std::string, std::string>& get_type_to_default_suffix(); 18 const std::map<std::string, Generator&>& get_type_to_generator(); 19 20 class AbigenGenerator { 21 public: AbigenGenerator(bool verbose)22 AbigenGenerator(bool verbose) 23 : verbose_(verbose) {} 24 bool AddSyscall(Syscall&& syscall); 25 bool Generate(const std::map<std::string, std::string>& type_to_filename); 26 bool verbose() const; 27 void AppendRequirement(Requirement&& req); 28 void SetTopDescription(TopDescription&& td); 29 30 private: 31 bool generate_one(const std::string& output_file, 32 Generator& generator, const std::string& type); 33 void print_error(const char* what, const std::string& file); 34 35 std::list<Syscall> calls_; 36 std::vector<Requirement> pending_requirements_; 37 TopDescription pending_top_description_; 38 int next_index_ = 0; 39 const bool verbose_; 40 }; 41