nany
atom-map.hxx
1 #pragma once
2 #include "atom-map.h"
3 
4 
5 namespace ny {
6 
7 
8 inline Atom& AtomMap::createNamespace(Atom& parent, const AnyString& name) {
9  assert(not name.empty());
10  Atom* nmspc = parent.findNamespaceAtom(name);
11  return (nmspc != nullptr)
12  ? *nmspc : createNewAtom(Atom::Type::namespacedef, parent, name);
13 }
14 
15 
16 inline Atom& AtomMap::createFuncdef(Atom& parent, const AnyString& name) {
17  assert(not name.empty());
18  return createNewAtom(Atom::Type::funcdef, parent, name);
19 }
20 
21 
22 inline Atom& AtomMap::createClassdef(Atom& parent, const AnyString& name) {
23  assert(not name.empty());
24  return createNewAtom(Atom::Type::classdef, parent, name);
25 }
26 
27 
28 inline Atom& AtomMap::createTypealias(Atom& parent, const AnyString& name) {
29  assert(not name.empty());
30  return createNewAtom(Atom::Type::typealias, parent, name);
31 }
32 
33 
34 inline Atom& AtomMap::createUnit(Atom& parent, const AnyString& name) {
35  return createNewAtom(Atom::Type::unit, parent, name);
36 }
37 
38 
39 inline const ir::Sequence& AtomMap::ircode(uint32_t atomid, uint32_t index) const {
40  assert(atomid < m_byIndex.size());
41  return m_byIndex[atomid]->instances[index].ircode();
42 }
43 
44 
45 inline const ir::Sequence* AtomMap::ircodeIfExists(uint32_t atomid, uint32_t index) const {
46  return (atomid < m_byIndex.size())
47  ? m_byIndex[atomid]->instances[index].ircodeIfExists() : nullptr;
48 }
49 
50 
51 inline yuni::Ref<Atom> AtomMap::findAtom(uint32_t atomid) const {
52  return atomid < m_byIndex.size() ? m_byIndex[atomid] : nullptr;
53 }
54 
55 
56 inline yuni::Ref<Atom> AtomMap::findAtom(uint32_t atomid) {
57  return atomid < m_byIndex.size() ? m_byIndex[atomid] : nullptr;
58 }
59 
60 
61 } // namespace ny
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
Atom & createNamespace(Atom &parent, const AnyString &name)
Create a new atom related to a part of a namespace.
Definition: atom-map.hxx:8
define a part of a namespace
Definition of a single class or function.
Definition: atom.h:37
class definition
Atom & createClassdef(Atom &parent, const AnyString &name)
Create a new atom related to a class.
Definition: atom-map.hxx:22
Unit (source file)
function definition
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
Definition: sequence.h:22
Atom & createTypealias(Atom &parent, const AnyString &name)
Create a new atom related to a type alias.
Definition: atom-map.hxx:28