forked from vmware-archive/differential-datalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinternment.dl
More file actions
99 lines (87 loc) · 2.75 KB
/
internment.dl
File metadata and controls
99 lines (87 loc) · 2.75 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* Object interning library based on the `internment` crate.
*
* This library is automatically imported by all DDlog programs.
*/
import ddlog_rt
import ddlog_std
/* Interned object of type `'A`.
* While this type is defined for any `'A`, interning is only supported for strings.
* There is simply no way to obtain an interned object of a different type.
*/
#[size=8]
#[shared_ref]
extern type Intern<'A>
/* Interned string
*/
typedef istring = Intern<string>
/* Intern a value.
*/
extern function intern(s: 'A): Intern<'A>
/* Extract an interned value.
*/
#[return_by_ref]
extern function ival(s: Intern<'A>): 'A
/* Returns unique integer identifier of an interned object.
*/
//extern function iord(s: Intern<'A>): u64
extern function istring_contains(s1: istring, s2: string): bool
extern function istring_join(strings: Vec<istring>, sep: string): string
extern function istring_len(s: istring): usize
extern function istring_replace(s: istring, from: string, to: string): string
extern function istring_split(s: istring, sep: string): Vec<string>
extern function istring_starts_with(s: istring, prefix: string): bool
extern function istring_ends_with(s: istring, suffix: string): bool
extern function istring_substr(s: istring, start: usize, end: usize): string
extern function istring_to_bytes(s: istring): Vec<u8>
extern function istring_trim(s: istring): string
extern function istring_to_lowercase(s: istring): string
extern function istring_to_uppercase(s: istring): string
extern function istring_reverse(s: istring): string
function parse_dec_u64(s: istring): Option<bit<64>> {
parse_dec_u64(s.ival())
}
function parse_dec_i64(s: istring): Option<signed<64>> {
parse_dec_i64(s.ival())
}
function contains(s1: istring, s2: string): bool {
istring_contains(s1, s2)
}
function join(strings: Vec<istring>, sep: string): string {
istring_join(strings, sep)
}
function len(s: istring): usize {
istring_len(s)
}
function replace(s: istring, from: string, to: string): string {
istring_replace(s, from, to)
}
function split(s: istring, sep: string): Vec<string> {
istring_split(s, sep)
}
function starts_with(s: istring, prefix: string): bool {
istring_starts_with(s, prefix)
}
function ends_with(s: istring, suffix: string): bool {
istring_ends_with(s, suffix)
}
function substr(s: istring, start: usize, end: usize): string {
istring_substr(s, start, end)
}
function to_bytes(s: istring): Vec<u8> {
istring_to_bytes(s)
}
function trim(s: istring): string {
istring_trim(s)
}
function to_lowercase(s: istring): string {
istring_to_lowercase(s)
}
function to_uppercase(s: istring): string {
istring_to_uppercase(s)
}
function reverse(s: istring): string {
istring_reverse(s)
}
function to_string(s: istring): string {
ival(s)
}