Functional-lang
0.0
An example functional programming language
include
func
gc.hpp
Go to the documentation of this file.
1
#ifndef FUNC_GC_HPP
2
#define FUNC_GC_HPP
3
8
#include "
func/global.hpp
"
9
10
class
GCObj
;
11
class
GCMain
;
12
15
class
GCObj
{
16
bool
marked =
false
;
17
protected
:
19
virtual
void
markSelf
(
GCMain
&main);
20
public
:
22
GCObj
(
GCMain
&main) noexcept;
23
24
virtual
~
GCObj
() {}
25
27
virtual
bool
isMarked
(
GCMain
&main)
const
noexcept;
28
30
virtual
void
mark
(
GCMain
&main) noexcept;
31
};
32
35
class
GCMain
{
36
bool
markBit;
37
std::size_t countNewObjs;
38
40
std::vector<GCObj*> marks;
41
public
:
42
GCMain
() : markBit(
true
), marks() {}
43
virtual
~
GCMain
();
44
51
bool
getMarkBit
()
const
noexcept;
52
56
std::size_t
getCountNewObjects
()
const
noexcept;
57
61
void
add
(
GCObj
*obj);
62
68
void
collect
();
69
};
70
71
#endif
/* FUNC_GC_HPP */
GCObj::mark
virtual void mark(GCMain &main) noexcept
If not marked mark itself and children.
GCObj::GCObj
GCObj(GCMain &main) noexcept
Initialize as not marked.
GCMain::add
void add(GCObj *obj)
Adds obj to all objects available.
GCMain
Implements a tracing garbage collector.
Definition:
gc.hpp:35
GCMain::getCountNewObjects
std::size_t getCountNewObjects() const noexcept
GCMain::collect
void collect()
Collects garbage.
GCObj::markSelf
virtual void markSelf(GCMain &main)
Marks itself.
GCObj
Garbage collection object (objects to collect).
Definition:
gc.hpp:15
GCObj::isMarked
virtual bool isMarked(GCMain &main) const noexcept
global.hpp
File for managing external headers.
GCMain::getMarkBit
bool getMarkBit() const noexcept
Generated by
1.8.15