-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfold_functor.cpp
66 lines (56 loc) · 2.07 KB
/
fold_functor.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "souffle/SouffleFunctor.h"
#include "souffle/utility/MiscUtil.h"
#include <cassert>
#include <string.h>
#include <list>
#if RAM_DOMAIN_SIZE == 64
using FF_int = int64_t;
using FF_uint = uint64_t;
using FF_float = double;
#else
using FF_int = int32_t;
using FF_uint = uint32_t;
using FF_float = float;
#endif
extern "C" {
souffle::RamDomain list_fold(
souffle::SymbolTable* symbolTable, souffle::RecordTable* recordTable, souffle::RamDomain list, souffle::RamDomain elem) {
assert(symbolTable && "NULL symbol table");
assert(recordTable && "NULL record table");
// if (list == 0) {
// souffle::RamDomain new_list[2] = {elem, 0};
// return recordTable->pack(new_list, 2);
// }
// else {
souffle::RamDomain new_list[2] = {elem, list};
return recordTable->pack(new_list, 2);
//}
}
// souffle::RamDomain list_fold(
// souffle::SymbolTable* symbolTable, souffle::RecordTable* recordTable, souffle::RamDomain list, souffle::RamDomain elem) {
// assert(symbolTable && "NULL symbol table");
// assert(recordTable && "NULL record table");
// if (list == 0) {
// souffle::RamDomain new_list[2] = {elem, 0};
// return recordTable->pack(new_list, 2);
// }
// else {
// souffle::RamDomain innerMost[2] = {elem, 0};
// const souffle::RamDomain* myTuple1 = recordTable->unpack(list, 2);
// std::list <souffle::RamDomain> l = {};
// while (1) {
// l.push_front(myTuple1[0]);
// if (myTuple1[1] == 0)
// break;
// myTuple1 = recordTable->unpack(myTuple1[1], 2);
// }
// souffle::RamDomain curr = recordTable->pack(innerMost, 2);
// while (l.size() > 0) {
// souffle::RamDomain temp[2] = {l.front(), curr};
// l.pop_front();
// curr = recordTable->pack(temp, 2);
// }
// return curr;
// }
// }
}