1 /* C++ modules. Experimental! -*- c++ -*-
2 Copyright (C) 2017-2022 Free Software Foundation, Inc.
3 Written by Nathan Sidwell <nathan@acm.org> while at FaceBook
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GXX_RESOLVER_H
22 #define GXX_RESOLVER_H 1
24 // Mapper interface for client and server bits
32 // This is a GCC class, so GCC coding conventions on new bits.
33 class module_resolver
: public Cody::Resolver
36 using parent
= Cody::Resolver
;
37 using module_map
= std::map
<std::string
, std::string
>;
44 bool default_map
= true;
45 bool default_translate
= true;
48 module_resolver (bool map
= true, bool xlate
= false);
49 virtual ~module_resolver () override
;
52 void set_default_map (bool d
)
56 void set_default_translate (bool d
)
58 default_translate
= d
;
60 void set_ident (char const *i
)
64 bool set_repo (std::string
&&repo
, bool force
= false);
65 bool add_mapping (std::string
&&module
, std::string
&&file
,
68 // Return +ve line number of error, or -ve errno
69 int read_tuple_file (int fd
, char const *prefix
, bool force
= false);
70 int read_tuple_file (int fd
, std::string
const &prefix
,
73 return read_tuple_file (fd
, prefix
.empty () ? nullptr : prefix
.c_str (),
78 // Virtual overriders, names are controlled by Cody::Resolver
79 using parent::ConnectRequest
;
80 virtual module_resolver
*ConnectRequest (Cody::Server
*, unsigned version
,
84 using parent::ModuleRepoRequest
;
85 virtual int ModuleRepoRequest (Cody::Server
*) override
;
86 using parent::ModuleExportRequest
;
87 virtual int ModuleExportRequest (Cody::Server
*s
, Cody::Flags
,
90 using parent::ModuleImportRequest
;
91 virtual int ModuleImportRequest (Cody::Server
*s
, Cody::Flags
,
94 using parent::IncludeTranslateRequest
;
95 virtual int IncludeTranslateRequest (Cody::Server
*s
, Cody::Flags
,
99 using parent::ModuleCompiledRequest
;
100 virtual int ModuleCompiledRequest (Cody::Server
*s
, Cody::Flags Flags
,
101 std::string
&Module
) override
;
104 using parent::GetCMISuffix
;
105 virtual char const *GetCMISuffix () override
;
108 int cmi_response (Cody::Server
*s
, std::string
&module
);