-
Notifications
You must be signed in to change notification settings - Fork 0
/
astsame.cpp
49 lines (37 loc) · 904 Bytes
/
astsame.cpp
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
#include "astsame.h"
#include <set>
#include "stream.h"
void AstSame::apply_bind(AstBlock *scope)
{
op1->apply_bind(scope);
op2->apply_bind(scope);
}
void AstSame::set_stack_start(unsigned int stack_size)
{
op1->set_stack_start(stack_size);
op2->set_stack_start(stack_size);
}
Stream *AstSame::execute(Context *context)
{
Stream *res = new Stream();
Stream *op1_stream = op1->execute(context);
Stream *op2_stream = op2->execute(context);
std::set<Object*> set;
std::vector<Object*>::const_iterator i;
i = op1_stream->get_vector().cbegin();
while (i != op1_stream->get_vector().cend())
{
set.insert(*i);
i++;
}
i = op2_stream->get_vector().cbegin();
while (i != op2_stream->get_vector().cend())
{
if (set.count(*i))
{
res->flow_from(*i);
}
i++;
}
return res;
}