-
Notifications
You must be signed in to change notification settings - Fork 122
/
internment.dl
122 lines (106 loc) · 3.83 KB
/
internment.dl
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright (c) 2021 VMware, Inc.
SPDX-License-Identifier: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* 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(#[by_val] 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)
}