nany
atom-map.h
1 #pragma once
2 #include "atom.h"
3 #include "details/utils/stringrefs.h"
4 #include "details/ir/fwd.h"
5 
6 
7 namespace ny {
8 
9 
10 struct ClassdefTable;
11 
12 
17 struct AtomMap final {
19  Atom& createNamespace(Atom& parent, const AnyString& name);
20 
22  Atom& createFuncdef(Atom& parent, const AnyString& name);
23 
25  Atom& createClassdef(Atom& parent, const AnyString& name);
26 
28  Atom& createVardef(Atom& parent, const AnyString& name);
29 
31  Atom& createTypealias(Atom& parent, const AnyString& name);
32 
34  Atom& createUnit(Atom& parent, const AnyString& name);
35 
36 
38  const ir::Sequence* ircodeIfExists(uint32_t atomid, uint32_t index) const;
39 
41  const ir::Sequence& ircode(uint32_t atomid, uint32_t index) const;
42 
44  AnyString symbolname(uint32_t atomid, uint32_t index) const;
45 
47  yuni::Ref<Atom> findAtom(uint32_t atomid) const;
49  yuni::Ref<Atom> findAtom(uint32_t atomid);
50 
53 
54 
55 public:
60 
61  struct {
62  yuni::Ref<Atom> object[nyt_count];
63  }
64  core;
65 
66 private:
68  explicit AtomMap(StringRefs& stringrefs);
70  Atom& createNewAtom(Atom::Type type, Atom& root, const AnyString& name);
71 
72 private:
73  std::vector<yuni::Ref<Atom>> m_byIndex;
74  uint32_t m_atomGrpID = 0;
75  friend struct ClassdefTable;
76 
77 }; // struct AtomMap
78 
79 
80 } // namespace ny
81 
82 #include "atom-map.hxx"
Atom & createFuncdef(Atom &parent, const AnyString &name)
Create a new atom related to a function.
Definition: atom-map.hxx:16
Atom & createUnit(Atom &parent, const AnyString &name)
Create a new atom related to an unit (source file)
Definition: atom-map.hxx:34
const ir::Sequence * ircodeIfExists(uint32_t atomid, uint32_t index) const
Find the IR sequence for a given {atomid/instanceid} (null if not found)
Definition: atom-map.hxx:45
yuni::Ref< Atom > findAtom(uint32_t atomid) const
Retrive an Atom object from its unique id (const)
Definition: atom-map.hxx:51
Definition: ast.cpp:6
Definition: classdef-table.h:19
Atom & createVardef(Atom &parent, const AnyString &name)
Create a new atom related to a variable.
Definition: atom-map.cpp:77
Atom & createNamespace(Atom &parent, const AnyString &name)
Create a new atom related to a part of a namespace.
Definition: atom-map.hxx:8
StringRefs & stringrefs
String catalog.
Definition: atom-map.h:59
Atoms.
Definition: atom-map.h:17
Type
Definition: atom.h:41
Definition of a single class or function.
Definition: atom.h:37
Atom & createClassdef(Atom &parent, const AnyString &name)
Create a new atom related to a class.
Definition: atom-map.hxx:22
bool fetchAndIndexCoreObjects()
Try to retrieve the corresponding classes for core objects (bool, i32...)
Definition: atom-map.cpp:94
const ir::Sequence & ircode(uint32_t atomid, uint32_t index) const
Find the IR code for a given {atomid/instanceid}.
Definition: atom-map.hxx:39
Atom root
The root atom (global namespace)
Definition: atom-map.h:57
Definition: sequence.h:22
AnyString symbolname(uint32_t atomid, uint32_t index) const
Retrieve the human readable name of an atom (empty if not found)
Definition: atom-map.cpp:87
Atom & createTypealias(Atom &parent, const AnyString &name)
Create a new atom related to a type alias.
Definition: atom-map.hxx:28
Container for minimizing memory use of duplicate strings.
Definition: stringrefs.h:12