-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathemitter.cpp
More file actions
62 lines (53 loc) · 1.54 KB
/
emitter.cpp
File metadata and controls
62 lines (53 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Copyright (c) 2024 Julian Benda
*
* This file is part of inkCPP which is released under MIT license.
* See file LICENSE.txt or go to
* https://github.com/JBenda/inkcpp for full license details.
*/
#include "emitter.h"
namespace ink::compiler::internal
{
void emitter::start(int ink_version, compilation_results* results)
{
// store
_ink_version = ink_version;
set_results(results);
// reset
_container_map.clear();
_max_container_index = 0;
// initialize
initialize();
}
void emitter::finish(container_t max_container_index)
{
// store max index
_max_container_index = max_container_index;
// finalize
finalize();
}
void emitter::add_start_to_container_map(uint32_t offset, container_t index)
{
if (_container_map.rbegin() != _container_map.rend())
{
if (_container_map.rbegin()->first > offset)
{
warn() << "Container map written out of order. Wrote container at offset "
<< offset << " after container with offset " << _container_map.rbegin()->first << std::flush;
}
}
_container_map.push_back(std::make_pair(offset, index));
setContainerIndex(index);
}
void emitter::add_end_to_container_map(uint32_t offset, container_t index)
{
if (_container_map.rbegin() != _container_map.rend())
{
if (_container_map.rbegin()->first > offset)
{
warn() << "Container map written out of order. Wrote container at offset "
<< offset << " after container with offset " << _container_map.rbegin()->first << std::flush;
}
}
_container_map.push_back(std::make_pair(offset, index));
}
}