27#ifndef IDLFE_AST_BUILDER_H_ 
   28#define IDLFE_AST_BUILDER_H_ 
   31#include "../IDL_FrontEnd.h" 
   39#include "../BE/MessageOut.h" 
   42#include <unordered_map> 
   43#include <unordered_set> 
   63    const std::filesystem::path* 
file () const noexcept
 
 
   77        return cur_file_ == &tree_->file ();
 
 
   98            type_id (name, 
id.as_string (), id_loc);
 
 
  109            rep_id->pragma_version (*
this, ver, loc);
 
 
  129        assert (!scope_stack_.empty ());
 
 
  237        return constr_type_end ();
 
 
  371    void see_prev_declaration (
const Location& loc);
 
  372    void see_declaration_of (
const Location& loc, 
const std::string& name);
 
  386    static const int FILE_FLAG_START = 0x1;
 
  387    static const int FILE_FLAG_SYSTEM = 0x2;
 
  388    void linemarker (
const std::string& name, 
const Location& loc, 
int flags);
 
  389    void line (
const std::string& filename);
 
  390    void pragma (
const char* s, 
const Location& loc);
 
  391    Ptr <Root> finalize ();
 
  395    Build::Eval& eval () 
const;
 
  399    Type fixed_pt_type (
unsigned digits, 
unsigned scale, 
const Location& loc)
 
  401        if (digits > 31 || scale > digits) {
 
  402            message (loc, 
MessageType::ERROR, std::string (
"fixed <") + std::to_string (digits) + 
", " + std::to_string (scale) + 
"> type specification is invalid.");
 
  405            return Type::make_fixed (digits, scale);
 
  409    friend class NamedItem;
 
  410    friend class Build::Eval;
 
  411    friend class Build::EvalEnum;
 
  413    const NamedItem* lookup (
const ScopedName& scoped_name);
 
  414    bool prefix_valid (
const std::string& pref, 
const Location& loc);
 
  415    void prefix (
const std::string& pref, 
const Location& loc);
 
  416    bool get_quoted_string (
const char*& s, std::string& qs, 
const Location& loc);
 
  417    static bool get_scoped_name (
const char*& s, ScopedName& name);
 
  418    ItemWithId* lookup_rep_id (
const ScopedName& name);
 
  419    void type_id (
const ScopedName& name, 
const std::string& 
id, 
const Location& id_loc);
 
  421    Symbols* cur_scope () 
const;
 
  422    Symbols* scope_begin ();
 
  423    void scope_push (IV_Base* scope);
 
  427    const NamedItem* constr_type_end ();
 
  431    std::pair <bool, const NamedItem*> lookup (
const ItemScope& scope, 
const Identifier& name, 
const Location& loc);
 
  432    std::pair <bool, const NamedItem*> lookup (
const IV_Bases& containers, 
const Identifier& name, 
const Location& loc);
 
  434    static const NamedItem* find (
const Symbols& symbols, 
const Identifier& name)
 
  436        return symbols.find (name);
 
  439    void error_name_collision (
const SimpleDeclarator& name, 
const Location& prev_loc);
 
  440    void error_interface_kind (
const SimpleDeclarator& name, InterfaceKind new_kind, InterfaceKind prev_kind, 
const Location& prev_loc);
 
  441    void error_valuetype_mod (
const SimpleDeclarator& name, 
bool is_abstract, 
const Location& prev_loc);
 
  443    void add_base_members (
const Location& loc, 
const IV_Bases& bases);
 
  444    bool check_member_name (
const NamedItem& item);
 
  446    bool check_complete (
const Type& type, 
const Location& loc);
 
  447    bool check_complete_or_ref (
const Type& type, 
const Location& loc);
 
  448    bool check_complete_or_seq (
const Type& type, 
const Location& loc);
 
  450    typedef std::unordered_map <std::string, const NamedItem&> RepIdMap;
 
  451    void check_rep_ids_unique (RepIdMap& ids, 
const Symbols& sym);
 
  452    void check_unique (RepIdMap& ids, 
const ItemWithId& rid);
 
  454    static bool is_base_of (
const Interface& base, 
const Interface& derived);
 
  455    static void collect_concrete_interfaces (
const ValueType& vt, std::unordered_map <const Interface*, const ValueType*>& interfaces);
 
  457    void check_complete (
const Symbols& symbols);
 
  459    static Type make_type (Type&& t, 
const Declarator& decl);
 
  468    typedef std::vector <ItemScope*> ScopeStack;
 
  469    ScopeStack scope_stack_;
 
  470    std::stack <Container*> container_stack_;
 
  471    std::stack <std::unique_ptr <Build::Eval> > eval_stack_;
 
  478        File (
const std::string& f) :
 
  483    std::vector <File> file_stack_;
 
  484    const std::filesystem::path* cur_file_;
 
  490        std::unordered_set <const Item*> all_bases;
 
  494            all_members.clear ();
 
  524        AttributeData () noexcept :
 
  528        void clear () noexcept
 
  538        const Ptr <NamedItem>* symbol;
 
  541        ConstrType () noexcept :
 
  545        void clear () noexcept
 
  551        NamedItem* obj () noexcept
 
  553            return symbol ? *symbol : 
nullptr;
 
  561        std::unordered_map <Variant::Key, Location> all_labels;
 
  563        Location default_loc;
 
  569        void clear () noexcept
 
  578            std::vector <Variant> labels;
 
 
void exception_begin(const SimpleDeclarator &name)
Begin of the exception definition.
 
void valuetype_factory_end()
End valuetype factory.
 
void attribute_begin(bool readonly, Type &&type, const SimpleDeclarator &name)
Begin attribute definition for the current interface or valuetype.
 
void union_label(const Variant &label, const Location &loc)
Create label for the current union.
 
void valuetype_supports(const ScopedNames &interfaces)
Set current valuetype supported interfaces.
 
void getraises(const ScopedNames &names)
Set getraises for the current attribute.
 
void interface_begin(const SimpleDeclarator &name, InterfaceKind ik=InterfaceKind())
Begin interface definition.
 
void struct_begin(const SimpleDeclarator &name)
Begin of the structure definition.
 
void interface_bases(const ScopedNames &bases)
Set current interface bases.
 
void struct_decl(const SimpleDeclarator &name)
Create structure forward declaration.
 
void module_begin(const SimpleDeclarator &name)
Begin module.
 
void type_id(const ScopedName &name, const Variant &id, const Location &id_loc)
Set repository id for item. See the typeid IDL keyword.
 
void exception_end()
End of the exception definition.
 
const std::filesystem::path * file() const noexcept
Currently parsed IDL file path.
 
void union_default(const Location &loc)
Create default label for the current union.
 
const std::string & prefix() const
 
void union_decl(const SimpleDeclarator &name)
Create union forward declaration.
 
void constant(Type &&t, const SimpleDeclarator &name)
Create interface constant definition (Nirvana extension).
 
void state_member(bool is_public, Type &&type, const Declarators &names)
Add members to the current valuetype.
 
void setraises(const ScopedNames &names)
Set setraises for the current attribute.
 
void operation_end()
End of the operation definition.
 
void parameter(Parameter::Attribute att, Type &&type, const SimpleDeclarator &name)
Add parameter to the current operation.
 
const NamedItem * enum_type(const SimpleDeclarator &name, const SimpleDeclarators &items)
Create enum type.
 
void type_def(Type &&type, const Declarators &declarators)
Create type alias.
 
Location location() const
 
const NamedItem * struct_end()
End of the structure definition.
 
void raises(const ScopedNames &names)
Set raises for the current operation.
 
void valuetype_bases(bool truncatable, const ScopedNames &bases)
Set current valuetype bases.
 
void valuetype_end()
End of the valuetype definition.
 
void member(Type &&type, const Declarators &names)
Add members to the current structure or exception.
 
void union_begin(const SimpleDeclarator &name, const Type &switch_type, const Location &type_loc)
Begin of the union definition.
 
void attribute_end()
End of the attribute definition.
 
void native(const SimpleDeclarator &name)
Create native type.
 
void module_end()
End module.
 
void valuetype_box(const SimpleDeclarator &name, Type &&type)
Create value box definition.
 
void valuetype_factory_begin(const SimpleDeclarator &name)
Begin valuetype factory.
 
bool is_main_file() const noexcept
Test if currently parsed file is main.
 
const NamedItem * union_end()
End of the union definition.
 
void valuetype_decl(const SimpleDeclarator &name, bool is_abstract=false)
Create valuetype forward declaration.
 
void pragma_version(const ScopedName &name, const Version &ver, const Location &loc)
Set repository id version for item. See #pragma version.
 
void operation_context(const Variants &strings)
Set context for the current operation.
 
void interface_decl(const SimpleDeclarator &name, InterfaceKind ik=InterfaceKind())
Create interface forward declaration.
 
void operation_begin(bool oneway, Type &&type, const SimpleDeclarator &name)
Begin operation definition for the current interface or valuetype.
 
Type lookup_type(const ScopedName &scoped_name)
Find type by name.
 
void type_prefix(const ScopedName &name, const Variant &s, const Location &id_loc)
Set repository id prefix for item. See the typeprefix IDL keyword.
 
void attribute(bool readonly, Type &&type, const SimpleDeclarators &declarators)
Add attributes to the current interface or valuetype.
 
void valuetype_begin(const SimpleDeclarator &name, ValueType::Modifier mod=ValueType::Modifier::NONE)
Begin valuetype definition.
 
void constant(Type &&t, const SimpleDeclarator &name, Variant &&val, const Location &loc)
Create constant definition.
 
void union_element(Type &&type, const Declarator &decl)
Create union element for the current label.
 
void interface_end()
End of the interface definition.
 
const Item * cur_parent() const
 
Kind
The kind of interface.
 
@ VALUE_TYPE
class ValueType
 
@ INTERFACE
class Interface
 
Items which have repository identifiers derive from this class.
 
Stores the location information.
 
Attribute
Parameter attribute: in, out, inout.
 
The IDL simple declarator.
 
Modifier
Value type modifier.
 
Stores the constant value.
 
Compiler messages output.
 
void message(const AST::Location &l, MessageType mt, const std::string &msg)
 
Abstract Syntax Tree namespace.
 
std::forward_list< SimpleDeclarator > SimpleDeclarators
The IDL simple declarators.
 
std::forward_list< Declarator > Declarators
The IDL declarators.
 
std::forward_list< ScopedName > ScopedNames
Sequence of scoped names.
 
std::vector< const ItemWithId * > Raises
 
A scoped name: sequence of identifiers.