rapydscript-ng 0.7.24 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +80 -26
- package/bin/build.ts +117 -0
- package/bin/package.json +1 -0
- package/bin/rapydscript +65 -62
- package/build_wheels.py +133 -0
- package/editor-plugins/README.md +80 -0
- package/editor-plugins/nvim.lua +321 -0
- package/local-agent.md +28 -0
- package/package.json +4 -5
- package/publish.py +27 -17
- package/release/baselib-plain-pretty.js +448 -326
- package/release/baselib-plain-ugly.js +3 -3
- package/release/compiler.js +9027 -8139
- package/release/signatures.json +27 -27
- package/release/stdlib_modules.json +1 -0
- package/src/ast.pyj +428 -280
- package/src/baselib-builtins.pyj +49 -28
- package/src/baselib-containers.pyj +241 -226
- package/src/baselib-errors.pyj +8 -1
- package/src/baselib-internal.pyj +38 -23
- package/src/baselib-itertools.pyj +13 -7
- package/src/baselib-str.pyj +59 -84
- package/src/compiler.pyj +4 -4
- package/src/errors.pyj +3 -4
- package/src/lib/aes.pyj +46 -32
- package/src/lib/elementmaker.pyj +11 -9
- package/src/lib/encodings.pyj +15 -5
- package/src/lib/gettext.pyj +9 -4
- package/src/lib/math.pyj +106 -45
- package/src/lib/operator.pyj +10 -10
- package/src/lib/pythonize.pyj +2 -1
- package/src/lib/random.pyj +28 -21
- package/src/lib/re.pyj +492 -19
- package/src/lib/traceback.pyj +171 -29
- package/src/lib/uuid.pyj +2 -2
- package/src/output/classes.pyj +28 -27
- package/src/output/codegen.pyj +87 -83
- package/src/output/comments.pyj +8 -8
- package/src/output/exceptions.pyj +20 -21
- package/src/output/functions.pyj +66 -64
- package/src/output/literals.pyj +24 -23
- package/src/output/loops.pyj +84 -142
- package/src/output/modules.pyj +55 -68
- package/src/output/operators.pyj +40 -29
- package/src/output/statements.pyj +21 -15
- package/src/output/stream.pyj +82 -56
- package/src/output/utils.pyj +12 -8
- package/src/parse.pyj +971 -620
- package/src/string_interpolation.pyj +5 -3
- package/src/tokenizer.pyj +188 -148
- package/src/utils.pyj +32 -15
- package/test/_treeshake_mod.pyj +30 -0
- package/test/_treeshake_side_effect.pyj +9 -0
- package/test/ast_serialization.pyj +392 -0
- package/test/async.pyj +95 -0
- package/test/baselib.pyj +1 -2
- package/test/embedded_compiler.pyj +57 -0
- package/test/fmt.pyj +291 -0
- package/test/generic.pyj +16 -3
- package/test/imports.pyj +8 -6
- package/test/internationalization.pyj +38 -37
- package/test/lint.pyj +120 -117
- package/test/lsp.pyj +257 -0
- package/test/repl.pyj +70 -65
- package/test/sourcemaps.pyj +315 -0
- package/test/starargs.pyj +46 -39
- package/test/str.pyj +8 -0
- package/test/traceback.pyj +263 -0
- package/test/treeshaking.pyj +181 -0
- package/test/web_repl_export.pyj +88 -0
- package/tools/ast_serialize.mjs +557 -0
- package/tools/cli.mjs +531 -0
- package/tools/compile.mjs +205 -0
- package/tools/compiler.mjs +159 -0
- package/tools/{completer.js → completer.mjs} +6 -6
- package/tools/{embedded_compiler.js → embedded_compiler.mjs} +17 -13
- package/tools/export.js +109 -56
- package/tools/fmt.mjs +975 -0
- package/tools/{gettext.js → gettext.mjs} +46 -53
- package/tools/ini.mjs +175 -0
- package/tools/{lint.js → lint.mjs} +78 -55
- package/tools/lsp.mjs +964 -0
- package/tools/lsp_protocol.mjs +259 -0
- package/tools/lsp_symbols.mjs +418 -0
- package/tools/{msgfmt.js → msgfmt.mjs} +18 -18
- package/tools/{repl.js → repl.mjs} +56 -42
- package/tools/{self.js → self.mjs} +71 -46
- package/tools/sourcemap.mjs +123 -0
- package/tools/test.mjs +252 -0
- package/tools/treeshake.mjs +400 -0
- package/tools/{utils.js → utils.mjs} +26 -23
- package/tools/{web_repl.js → web_repl.mjs} +15 -13
- package/tools/web_repl_export.mjs +97 -0
- package/tree-sitter/README.md +101 -0
- package/tree-sitter/grammar.js +992 -0
- package/tree-sitter/package.json +43 -0
- package/tree-sitter/queries/highlights.scm +232 -0
- package/tree-sitter/queries/indents.scm +64 -0
- package/tree-sitter/queries/injections.scm +14 -0
- package/tree-sitter/queries/locals.scm +108 -0
- package/tree-sitter/src/grammar.json +4976 -0
- package/tree-sitter/src/node-types.json +2901 -0
- package/tree-sitter/src/parser.c +196465 -0
- package/tree-sitter/src/scanner.c +294 -0
- package/tree-sitter/src/tree_sitter/alloc.h +54 -0
- package/tree-sitter/src/tree_sitter/array.h +330 -0
- package/tree-sitter/src/tree_sitter/parser.h +286 -0
- package/tree-sitter/test/corpus/chaining.txt +99 -0
- package/tree-sitter/test/corpus/classes.txt +147 -0
- package/tree-sitter/test/corpus/comprehensions.txt +155 -0
- package/tree-sitter/test/corpus/containers.txt +242 -0
- package/tree-sitter/test/corpus/control_flow.txt +361 -0
- package/tree-sitter/test/corpus/decorators.txt +64 -0
- package/tree-sitter/test/corpus/existential.txt +102 -0
- package/tree-sitter/test/corpus/functions.txt +293 -0
- package/tree-sitter/test/corpus/imports.txt +117 -0
- package/tree-sitter/test/corpus/literals.txt +135 -0
- package/tree-sitter/test/corpus/operators.txt +296 -0
- package/tree-sitter/test/corpus/statements.txt +189 -0
- package/tree-sitter/test/corpus/strings.txt +90 -0
- package/tree-sitter/test/corpus/subscripts.txt +227 -0
- package/tree-sitter/tree-sitter.json +36 -0
- package/web-repl/env.js +35 -23
- package/web-repl/main.js +8 -8
- package/bin/export +0 -75
- package/bin/web-repl-export +0 -102
- package/tools/cli.js +0 -523
- package/tools/compile.js +0 -184
- package/tools/compiler.js +0 -84
- package/tools/ini.js +0 -65
- package/tools/test.js +0 -110
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# globals:ρσ_iterator_symbol, ρσ_kwargs_symbol, ρσ_arraylike, ρσ_repr
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
def ρσ_equals(a, b):
|
|
8
9
|
if a is b:
|
|
9
10
|
return True
|
|
@@ -21,18 +22,19 @@ def ρσ_equals(a, b):
|
|
|
21
22
|
if jstype(a) is 'object' and jstype(b) is 'object' and a is not None and b is not None and (
|
|
22
23
|
(a.constructor is Object and b.constructor is Object) or (Object.getPrototypeOf(a) is None and Object.getPrototypeOf(b) is None)
|
|
23
24
|
):
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
# Do a dict like comparison as this is most likely either a JS has
|
|
26
|
+
# (Object.create(null) or a JS object used as a hash (v"{}"))
|
|
27
|
+
akeys, bkeys = Object.keys(a), Object.keys(b)
|
|
28
|
+
if akeys.length is not bkeys.length:
|
|
29
|
+
return False
|
|
30
|
+
for v'var j=0; j < akeys.length; j++':
|
|
31
|
+
key = akeys[j]
|
|
32
|
+
if not (a[key] == b[key]):
|
|
28
33
|
return False
|
|
29
|
-
|
|
30
|
-
key = akeys[j]
|
|
31
|
-
if not (a[key] == b[key]):
|
|
32
|
-
return False
|
|
33
|
-
return True
|
|
34
|
+
return True
|
|
34
35
|
return False
|
|
35
36
|
|
|
37
|
+
|
|
36
38
|
def ρσ_not_equals(a, b):
|
|
37
39
|
if a is b:
|
|
38
40
|
return False
|
|
@@ -46,168 +48,20 @@ v'var equals = ρσ_equals'
|
|
|
46
48
|
|
|
47
49
|
# list {{{
|
|
48
50
|
|
|
49
|
-
def ρσ_list_extend(iterable):
|
|
50
|
-
if Array.isArray(iterable) or jstype(iterable) is 'string':
|
|
51
|
-
# Allocate all new memory in one operation
|
|
52
|
-
start = this.length
|
|
53
|
-
this.length += iterable.length
|
|
54
|
-
for v'var i = 0; i < iterable.length; i++':
|
|
55
|
-
this[start + i] = iterable[i] # noqa:undef
|
|
56
|
-
else:
|
|
57
|
-
iterator = iterable.keys() if jstype(Map) is 'function' and v'iterable instanceof Map' else iterable[ρσ_iterator_symbol]()
|
|
58
|
-
result = iterator.next()
|
|
59
|
-
while not result.done:
|
|
60
|
-
this.push(result.value)
|
|
61
|
-
result = iterator.next()
|
|
62
|
-
|
|
63
|
-
def ρσ_list_index(val, start, stop):
|
|
64
|
-
start = start or 0
|
|
65
|
-
if start < 0:
|
|
66
|
-
start = this.length + start
|
|
67
|
-
if start < 0:
|
|
68
|
-
raise ValueError(val + ' is not in list')
|
|
69
|
-
if stop is undefined:
|
|
70
|
-
stop = this.length
|
|
71
|
-
if stop < 0:
|
|
72
|
-
stop = this.length + stop
|
|
73
|
-
for v'var i = start; i < stop; i++':
|
|
74
|
-
if this[i] == val:
|
|
75
|
-
return i # noqa:undef
|
|
76
|
-
raise ValueError(val + ' is not in list')
|
|
77
|
-
|
|
78
|
-
def ρσ_list_pop(index):
|
|
79
|
-
if this.length is 0:
|
|
80
|
-
raise IndexError('list is empty')
|
|
81
|
-
if index is undefined:
|
|
82
|
-
index = -1
|
|
83
|
-
ans = this.splice(index, 1)
|
|
84
|
-
if not ans.length:
|
|
85
|
-
raise IndexError('pop index out of range')
|
|
86
|
-
return ans[0]
|
|
87
|
-
|
|
88
|
-
def ρσ_list_remove(value):
|
|
89
|
-
for v'var i = 0; i < this.length; i++':
|
|
90
|
-
if this[i] == value:
|
|
91
|
-
this.splice(i, 1)
|
|
92
|
-
return
|
|
93
|
-
raise ValueError(value + ' not in list')
|
|
94
|
-
|
|
95
|
-
def ρσ_list_to_string():
|
|
96
|
-
return '[' + this.join(', ') + ']'
|
|
97
|
-
|
|
98
|
-
def ρσ_list_insert(index, val):
|
|
99
|
-
if index < 0:
|
|
100
|
-
index += this.length
|
|
101
|
-
index = min(this.length, max(index, 0))
|
|
102
|
-
if index is 0:
|
|
103
|
-
this.unshift(val)
|
|
104
|
-
return
|
|
105
|
-
for v'var i = this.length; i > index; i--':
|
|
106
|
-
this[i] = this[i - 1] # noqa:undef
|
|
107
|
-
this[index] = val
|
|
108
|
-
|
|
109
|
-
def ρσ_list_copy():
|
|
110
|
-
return ρσ_list_constructor(this)
|
|
111
|
-
|
|
112
|
-
def ρσ_list_clear():
|
|
113
|
-
this.length = 0
|
|
114
|
-
|
|
115
|
-
def ρσ_list_as_array():
|
|
116
|
-
return Array.prototype.slice.call(this)
|
|
117
|
-
|
|
118
|
-
def ρσ_list_count(value):
|
|
119
|
-
return this.reduce(def(n, val): return n + (val is value);, 0)
|
|
120
|
-
|
|
121
|
-
def ρσ_list_sort_key(value):
|
|
122
|
-
t = jstype(value)
|
|
123
|
-
if t is 'string' or t is 'number':
|
|
124
|
-
return value
|
|
125
|
-
return value.toString()
|
|
126
|
-
|
|
127
|
-
def ρσ_list_sort_cmp(a, b, ap, bp):
|
|
128
|
-
if a < b:
|
|
129
|
-
return -1
|
|
130
|
-
if a > b:
|
|
131
|
-
return 1
|
|
132
|
-
return ap - bp
|
|
133
|
-
|
|
134
|
-
def ρσ_list_sort(key=None, reverse=False):
|
|
135
|
-
key = key or ρσ_list_sort_key
|
|
136
|
-
mult = -1 if reverse else 1
|
|
137
|
-
keymap = dict()
|
|
138
|
-
posmap = dict()
|
|
139
|
-
for v'var i=0; i < this.length; i++':
|
|
140
|
-
k = this[i] # noqa:undef
|
|
141
|
-
keymap.set(k, key(k))
|
|
142
|
-
posmap.set(k, i)
|
|
143
|
-
this.sort(def (a, b): return mult * ρσ_list_sort_cmp(keymap.get(a), keymap.get(b), posmap.get(a), posmap.get(b));)
|
|
144
|
-
|
|
145
|
-
def ρσ_list_concat(): # ensure concat() returns an object of type list
|
|
146
|
-
ans = Array.prototype.concat.apply(this, arguments)
|
|
147
|
-
ρσ_list_decorate(ans)
|
|
148
|
-
return ans
|
|
149
|
-
|
|
150
|
-
def ρσ_list_slice(): # ensure slice() returns an object of type list
|
|
151
|
-
ans = Array.prototype.slice.apply(this, arguments)
|
|
152
|
-
ρσ_list_decorate(ans)
|
|
153
|
-
return ans
|
|
154
51
|
|
|
155
52
|
def ρσ_list_iterator(value):
|
|
156
53
|
self = this
|
|
157
54
|
return {
|
|
158
|
-
'_i'
|
|
159
|
-
'_list':self,
|
|
160
|
-
'next':def():
|
|
55
|
+
'_i': -1,
|
|
56
|
+
'_list': self,
|
|
57
|
+
'next': def ():
|
|
161
58
|
this._i += 1
|
|
162
59
|
if this._i >= this._list.length:
|
|
163
|
-
return {'done':True}
|
|
164
|
-
return {'done':False, 'value':this._list[this._i]}
|
|
60
|
+
return {'done': True}
|
|
61
|
+
return {'done': False, 'value': this._list[this._i]}
|
|
165
62
|
,
|
|
166
63
|
}
|
|
167
64
|
|
|
168
|
-
def ρσ_list_len():
|
|
169
|
-
return this.length
|
|
170
|
-
|
|
171
|
-
def ρσ_list_contains(val):
|
|
172
|
-
for v'var i = 0; i < this.length; i++':
|
|
173
|
-
if this[i] == val:
|
|
174
|
-
return True
|
|
175
|
-
return False
|
|
176
|
-
|
|
177
|
-
def ρσ_list_eq(other):
|
|
178
|
-
if not ρσ_arraylike(other):
|
|
179
|
-
return False
|
|
180
|
-
if this.length != other.length:
|
|
181
|
-
return False
|
|
182
|
-
for v'var i = 0; i < this.length; i++':
|
|
183
|
-
if not (this[i] == other[i]):
|
|
184
|
-
return False
|
|
185
|
-
return True
|
|
186
|
-
|
|
187
|
-
def ρσ_list_decorate(ans):
|
|
188
|
-
ans.append = Array.prototype.push
|
|
189
|
-
ans.toString = ρσ_list_to_string
|
|
190
|
-
ans.inspect = ρσ_list_to_string
|
|
191
|
-
ans.extend = ρσ_list_extend
|
|
192
|
-
ans.index = ρσ_list_index
|
|
193
|
-
ans.pypop = ρσ_list_pop
|
|
194
|
-
ans.remove = ρσ_list_remove
|
|
195
|
-
ans.insert = ρσ_list_insert
|
|
196
|
-
ans.copy = ρσ_list_copy
|
|
197
|
-
ans.clear = ρσ_list_clear
|
|
198
|
-
ans.count = ρσ_list_count
|
|
199
|
-
ans.concat = ρσ_list_concat
|
|
200
|
-
ans.pysort = ρσ_list_sort
|
|
201
|
-
ans.slice = ρσ_list_slice
|
|
202
|
-
ans.as_array = ρσ_list_as_array
|
|
203
|
-
ans.__len__ = ρσ_list_len
|
|
204
|
-
ans.__contains__ = ρσ_list_contains
|
|
205
|
-
ans.__eq__ = ρσ_list_eq
|
|
206
|
-
ans.constructor = ρσ_list_constructor
|
|
207
|
-
if jstype(ans[ρσ_iterator_symbol]) is not 'function':
|
|
208
|
-
# Happens on ES 5 runtimes
|
|
209
|
-
ans[ρσ_iterator_symbol] = ρσ_list_iterator
|
|
210
|
-
return ans
|
|
211
65
|
|
|
212
66
|
def ρσ_list_constructor(iterable):
|
|
213
67
|
if iterable is undefined:
|
|
@@ -228,11 +82,165 @@ def ρσ_list_constructor(iterable):
|
|
|
228
82
|
ans = new Array(iterable)
|
|
229
83
|
else:
|
|
230
84
|
ans = Object.keys(iterable)
|
|
231
|
-
return
|
|
85
|
+
return ans
|
|
232
86
|
ρσ_list_constructor.__name__ = 'list'
|
|
233
87
|
|
|
88
|
+
if v'typeof Array.prototype.append' is not 'function':
|
|
89
|
+
Object.defineProperty(Array.prototype, 'append', {
|
|
90
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
91
|
+
'value': Array.prototype.push,
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(Array.prototype, 'extend', {
|
|
94
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
95
|
+
'value': def (iterable):
|
|
96
|
+
if Array.isArray(iterable) or jstype(iterable) is 'string':
|
|
97
|
+
# Allocate all new memory in one operation
|
|
98
|
+
start = this.length
|
|
99
|
+
this.length += iterable.length
|
|
100
|
+
for v'var i = 0; i < iterable.length; i++':
|
|
101
|
+
this[start + i] = iterable[i] # noqa:undef
|
|
102
|
+
else:
|
|
103
|
+
iterator = iterable.keys() if jstype(Map) is 'function' and v'iterable instanceof Map' else iterable[ρσ_iterator_symbol]()
|
|
104
|
+
result = iterator.next()
|
|
105
|
+
while not result.done:
|
|
106
|
+
this.push(result.value)
|
|
107
|
+
result = iterator.next()
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(Array.prototype, 'index', {
|
|
110
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
111
|
+
'value': def (val, start, stop):
|
|
112
|
+
start = start or 0
|
|
113
|
+
if start < 0:
|
|
114
|
+
start = this.length + start
|
|
115
|
+
if start < 0:
|
|
116
|
+
raise ValueError(val + ' is not in list')
|
|
117
|
+
if stop is undefined:
|
|
118
|
+
stop = this.length
|
|
119
|
+
if stop < 0:
|
|
120
|
+
stop = this.length + stop
|
|
121
|
+
for v'var i = start; i < stop; i++':
|
|
122
|
+
if this[i] == val:
|
|
123
|
+
return i # noqa:undef
|
|
124
|
+
raise ValueError(val + ' is not in list')
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(Array.prototype, 'pypop', {
|
|
127
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
128
|
+
'value': def (index):
|
|
129
|
+
if this.length is 0:
|
|
130
|
+
raise IndexError('list is empty')
|
|
131
|
+
if index is undefined:
|
|
132
|
+
index = -1
|
|
133
|
+
ans = this.splice(index, 1)
|
|
134
|
+
if not ans.length:
|
|
135
|
+
raise IndexError('pop index out of range')
|
|
136
|
+
return ans[0]
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(Array.prototype, 'remove', {
|
|
139
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
140
|
+
'value': def (value):
|
|
141
|
+
for v'var i = 0; i < this.length; i++':
|
|
142
|
+
if this[i] == value:
|
|
143
|
+
this.splice(i, 1)
|
|
144
|
+
return
|
|
145
|
+
raise ValueError(value + ' not in list')
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(Array.prototype, 'toString', {
|
|
148
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
149
|
+
'value': def (): return '[' + this.join(', ') + ']'
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(Array.prototype, 'inspect', {
|
|
152
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
153
|
+
'value': def (): return '[' + this.join(', ') + ']'
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(Array.prototype, 'insert', {
|
|
156
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
157
|
+
'value': def (index, val):
|
|
158
|
+
if index < 0:
|
|
159
|
+
index += this.length
|
|
160
|
+
index = min(this.length, max(index, 0))
|
|
161
|
+
if index is 0:
|
|
162
|
+
this.unshift(val)
|
|
163
|
+
return
|
|
164
|
+
for v'var i = this.length; i > index; i--':
|
|
165
|
+
this[i] = this[i - 1] # noqa:undef
|
|
166
|
+
this[index] = val
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(Array.prototype, 'copy', {
|
|
169
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
170
|
+
'value': def (): return ρσ_list_constructor(this)
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(Array.prototype, 'clear', {
|
|
173
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
174
|
+
'value': def (): this.length = 0
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(Array.prototype, 'count', {
|
|
177
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
178
|
+
'value': def (value): return this.reduce(def (n, val): return n + (val is value);, 0)
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(Array.prototype, 'pysort', {
|
|
181
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
182
|
+
'value': def (key = None, reverse = False):
|
|
183
|
+
def _sort_key(value):
|
|
184
|
+
t = jstype(value)
|
|
185
|
+
if t is 'string' or t is 'number':
|
|
186
|
+
return value
|
|
187
|
+
return value.toString()
|
|
188
|
+
def _sort_cmp(a, b, ap, bp):
|
|
189
|
+
if a < b:
|
|
190
|
+
return -1
|
|
191
|
+
if a > b:
|
|
192
|
+
return 1
|
|
193
|
+
return ap - bp
|
|
194
|
+
key = key or _sort_key
|
|
195
|
+
mult = -1 if reverse else 1
|
|
196
|
+
keymap = dict()
|
|
197
|
+
posmap = dict()
|
|
198
|
+
for v'var i=0; i < this.length; i++':
|
|
199
|
+
k = this[i] # noqa:undef
|
|
200
|
+
keymap.set(k, key(k))
|
|
201
|
+
posmap.set(k, i)
|
|
202
|
+
this.sort(def (a, b): return mult * _sort_cmp(keymap.get(a), keymap.get(b), posmap.get(a), posmap.get(b));)
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(Array.prototype, 'as_array', {
|
|
205
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
206
|
+
'value': def (): return Array.from (this)
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(Array.prototype, '__len__', {
|
|
209
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
210
|
+
'value': def (): return this.length
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(Array.prototype, '__contains__', {
|
|
213
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
214
|
+
'value': def (val):
|
|
215
|
+
for v'var i = 0; i < this.length; i++':
|
|
216
|
+
if this[i] == val:
|
|
217
|
+
return True
|
|
218
|
+
return False
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(Array.prototype, '__eq__', {
|
|
221
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
222
|
+
'value': def (other):
|
|
223
|
+
if not ρσ_arraylike(other):
|
|
224
|
+
return False
|
|
225
|
+
if this.length != other.length:
|
|
226
|
+
return False
|
|
227
|
+
for v'var i = 0; i < this.length; i++':
|
|
228
|
+
if not (this[i] == other[i]):
|
|
229
|
+
return False
|
|
230
|
+
return True
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(Array.prototype, 'constructor', {
|
|
233
|
+
'writable': False, 'configurable': False, 'enumerable': False,
|
|
234
|
+
'value': ρσ_list_constructor,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def ρσ_list_decorate(ans):
|
|
239
|
+
return ans
|
|
240
|
+
|
|
234
241
|
v'var list = ρσ_list_constructor, list_wrap = ρσ_list_decorate'
|
|
235
242
|
|
|
243
|
+
|
|
236
244
|
def sorted(iterable, key=None, reverse=False):
|
|
237
245
|
ans = ρσ_list_constructor(iterable)
|
|
238
246
|
ans.pysort(key, reverse)
|
|
@@ -242,34 +250,36 @@ def sorted(iterable, key=None, reverse=False):
|
|
|
242
250
|
# set {{{
|
|
243
251
|
v'var ρσ_global_object_id = 0, ρσ_set_implementation'
|
|
244
252
|
|
|
253
|
+
|
|
245
254
|
def ρσ_set_keyfor(x):
|
|
246
255
|
t = jstype(x)
|
|
247
256
|
if t is 'string' or t is 'number' or t is 'boolean':
|
|
248
257
|
return '_' + t[0] + x
|
|
249
|
-
if v'x === null':
|
|
250
|
-
return
|
|
258
|
+
if v'x === null': # also matches undefined
|
|
259
|
+
return '__!@#$0'
|
|
251
260
|
ans = x.ρσ_hash_key_prop
|
|
252
261
|
if ans is undefined:
|
|
253
262
|
v'ans = "_!@#$" + (++ρσ_global_object_id)'
|
|
254
|
-
Object.defineProperty(x, 'ρσ_hash_key_prop', {
|
|
263
|
+
Object.defineProperty(x, 'ρσ_hash_key_prop', {'value': ans})
|
|
255
264
|
return ans
|
|
256
265
|
|
|
266
|
+
|
|
257
267
|
def ρσ_set_polyfill():
|
|
258
268
|
this._store = {}
|
|
259
269
|
this.size = 0
|
|
260
270
|
|
|
261
|
-
ρσ_set_polyfill.prototype.add = def(x):
|
|
271
|
+
ρσ_set_polyfill.prototype.add = def (x):
|
|
262
272
|
key = ρσ_set_keyfor(x)
|
|
263
273
|
if not Object.prototype.hasOwnProperty.call(this._store, key):
|
|
264
274
|
this.size += 1
|
|
265
275
|
this._store[key] = x
|
|
266
276
|
return this
|
|
267
277
|
|
|
268
|
-
ρσ_set_polyfill.prototype.clear = def(x):
|
|
278
|
+
ρσ_set_polyfill.prototype.clear = def (x):
|
|
269
279
|
this._store = {}
|
|
270
280
|
this.size = 0
|
|
271
281
|
|
|
272
|
-
ρσ_set_polyfill.prototype.delete = def(x):
|
|
282
|
+
ρσ_set_polyfill.prototype.delete = def (x):
|
|
273
283
|
key = ρσ_set_keyfor(x)
|
|
274
284
|
if Object.prototype.hasOwnProperty.call(this._store, key):
|
|
275
285
|
this.size -= 1
|
|
@@ -277,14 +287,14 @@ def ρσ_set_polyfill():
|
|
|
277
287
|
return True
|
|
278
288
|
return False
|
|
279
289
|
|
|
280
|
-
ρσ_set_polyfill.prototype.has = def(x):
|
|
290
|
+
ρσ_set_polyfill.prototype.has = def (x):
|
|
281
291
|
return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x))
|
|
282
292
|
|
|
283
|
-
ρσ_set_polyfill.prototype.values = def(x):
|
|
293
|
+
ρσ_set_polyfill.prototype.values = def (x):
|
|
284
294
|
ans = v"{'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}"
|
|
285
|
-
ans[ρσ_iterator_symbol] = def():
|
|
295
|
+
ans[ρσ_iterator_symbol] = def ():
|
|
286
296
|
return this
|
|
287
|
-
ans['next'] = def():
|
|
297
|
+
ans['next'] = def ():
|
|
288
298
|
this._i += 1
|
|
289
299
|
if this._i >= this._keys.length:
|
|
290
300
|
return v"{'done': true}"
|
|
@@ -296,6 +306,7 @@ if jstype(Set) is not 'function' or jstype(Set.prototype.delete) is not 'functio
|
|
|
296
306
|
else:
|
|
297
307
|
v'ρσ_set_implementation = Set'
|
|
298
308
|
|
|
309
|
+
|
|
299
310
|
def ρσ_set(iterable):
|
|
300
311
|
if v'this instanceof ρσ_set':
|
|
301
312
|
this.jsset = new ρσ_set_implementation() # noqa:undef
|
|
@@ -323,19 +334,19 @@ def ρσ_set(iterable):
|
|
|
323
334
|
|
|
324
335
|
# These are for JavaScript users' convenience
|
|
325
336
|
Object.defineProperties(ρσ_set.prototype, {
|
|
326
|
-
'length': {
|
|
327
|
-
'size': {
|
|
337
|
+
'length': {'get': def (): return this.jsset.size;},
|
|
338
|
+
'size': {'get': def (): return this.jsset.size;},
|
|
328
339
|
})
|
|
329
340
|
|
|
330
|
-
ρσ_set.prototype.__len__ = def(): return this.jsset.size
|
|
331
|
-
ρσ_set.prototype.has = ρσ_set.prototype.__contains__ = def(x): return this.jsset.has(x)
|
|
332
|
-
ρσ_set.prototype.add = def(x): this.jsset.add(x)
|
|
333
|
-
ρσ_set.prototype.clear = def(): this.jsset.clear()
|
|
334
|
-
ρσ_set.prototype.copy = def(): return ρσ_set(this)
|
|
335
|
-
ρσ_set.prototype.discard = def(x): this.jsset.delete(x)
|
|
336
|
-
ρσ_set.prototype[ρσ_iterator_symbol] = def(): return this.jsset.values()
|
|
341
|
+
ρσ_set.prototype.__len__ = def (): return this.jsset.size
|
|
342
|
+
ρσ_set.prototype.has = ρσ_set.prototype.__contains__ = def (x): return this.jsset.has(x)
|
|
343
|
+
ρσ_set.prototype.add = def (x): this.jsset.add(x)
|
|
344
|
+
ρσ_set.prototype.clear = def (): this.jsset.clear()
|
|
345
|
+
ρσ_set.prototype.copy = def (): return ρσ_set(this)
|
|
346
|
+
ρσ_set.prototype.discard = def (x): this.jsset.delete(x)
|
|
347
|
+
ρσ_set.prototype[ρσ_iterator_symbol] = def (): return this.jsset.values()
|
|
337
348
|
|
|
338
|
-
ρσ_set.prototype.difference = def():
|
|
349
|
+
ρσ_set.prototype.difference = def ():
|
|
339
350
|
ans = new ρσ_set()
|
|
340
351
|
s = ans.jsset
|
|
341
352
|
iterator = this.jsset.values()
|
|
@@ -352,7 +363,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
352
363
|
r = iterator.next()
|
|
353
364
|
return ans
|
|
354
365
|
|
|
355
|
-
ρσ_set.prototype.difference_update = def():
|
|
366
|
+
ρσ_set.prototype.difference_update = def ():
|
|
356
367
|
s = this.jsset
|
|
357
368
|
remove = v'[]'
|
|
358
369
|
iterator = s.values()
|
|
@@ -367,7 +378,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
367
378
|
for v'var j = 0; j < remove.length; j++':
|
|
368
379
|
s.delete(remove[j]) # noqa:undef
|
|
369
380
|
|
|
370
|
-
ρσ_set.prototype.intersection = def():
|
|
381
|
+
ρσ_set.prototype.intersection = def ():
|
|
371
382
|
ans = new ρσ_set()
|
|
372
383
|
s = ans.jsset
|
|
373
384
|
iterator = this.jsset.values()
|
|
@@ -384,7 +395,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
384
395
|
r = iterator.next()
|
|
385
396
|
return ans
|
|
386
397
|
|
|
387
|
-
ρσ_set.prototype.intersection_update = def():
|
|
398
|
+
ρσ_set.prototype.intersection_update = def ():
|
|
388
399
|
s = this.jsset
|
|
389
400
|
remove = v'[]'
|
|
390
401
|
iterator = s.values()
|
|
@@ -399,7 +410,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
399
410
|
for v'var j = 0; j < remove.length; j++':
|
|
400
411
|
s.delete(remove[j]) # noqa:undef
|
|
401
412
|
|
|
402
|
-
ρσ_set.prototype.isdisjoint = def(other):
|
|
413
|
+
ρσ_set.prototype.isdisjoint = def (other):
|
|
403
414
|
iterator = this.jsset.values()
|
|
404
415
|
r = iterator.next()
|
|
405
416
|
while not r.done:
|
|
@@ -409,7 +420,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
409
420
|
r = iterator.next()
|
|
410
421
|
return True
|
|
411
422
|
|
|
412
|
-
ρσ_set.prototype.issubset = def(other):
|
|
423
|
+
ρσ_set.prototype.issubset = def (other):
|
|
413
424
|
iterator = this.jsset.values()
|
|
414
425
|
r = iterator.next()
|
|
415
426
|
while not r.done:
|
|
@@ -419,7 +430,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
419
430
|
r = iterator.next()
|
|
420
431
|
return True
|
|
421
432
|
|
|
422
|
-
ρσ_set.prototype.issuperset = def(other):
|
|
433
|
+
ρσ_set.prototype.issuperset = def (other):
|
|
423
434
|
s = this.jsset
|
|
424
435
|
iterator = other.jsset.values()
|
|
425
436
|
r = iterator.next()
|
|
@@ -430,7 +441,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
430
441
|
r = iterator.next()
|
|
431
442
|
return True
|
|
432
443
|
|
|
433
|
-
ρσ_set.prototype.pop = def():
|
|
444
|
+
ρσ_set.prototype.pop = def ():
|
|
434
445
|
iterator = this.jsset.values()
|
|
435
446
|
r = iterator.next()
|
|
436
447
|
if r.done:
|
|
@@ -438,24 +449,24 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
438
449
|
this.jsset.delete(r.value)
|
|
439
450
|
return r.value
|
|
440
451
|
|
|
441
|
-
ρσ_set.prototype.remove = def(x):
|
|
452
|
+
ρσ_set.prototype.remove = def (x):
|
|
442
453
|
if not this.jsset.delete(x):
|
|
443
454
|
raise KeyError(x.toString())
|
|
444
455
|
|
|
445
|
-
ρσ_set.prototype.symmetric_difference = def(other):
|
|
456
|
+
ρσ_set.prototype.symmetric_difference = def (other):
|
|
446
457
|
return this.union(other).difference(this.intersection(other))
|
|
447
458
|
|
|
448
|
-
ρσ_set.prototype.symmetric_difference_update = def(other):
|
|
459
|
+
ρσ_set.prototype.symmetric_difference_update = def (other):
|
|
449
460
|
common = this.intersection(other)
|
|
450
461
|
this.update(other)
|
|
451
462
|
this.difference_update(common)
|
|
452
463
|
|
|
453
|
-
ρσ_set.prototype.union = def():
|
|
464
|
+
ρσ_set.prototype.union = def ():
|
|
454
465
|
ans = ρσ_set(this)
|
|
455
466
|
ans.update.apply(ans, arguments)
|
|
456
467
|
return ans
|
|
457
468
|
|
|
458
|
-
ρσ_set.prototype.update = def():
|
|
469
|
+
ρσ_set.prototype.update = def ():
|
|
459
470
|
s = this.jsset
|
|
460
471
|
for v'var i=0; i < arguments.length; i++':
|
|
461
472
|
iterator = arguments[i][ρσ_iterator_symbol]() # noqa:undef
|
|
@@ -464,10 +475,10 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
464
475
|
s.add(r.value)
|
|
465
476
|
r = iterator.next()
|
|
466
477
|
|
|
467
|
-
ρσ_set.prototype.toString = ρσ_set.prototype.__repr__ = ρσ_set.prototype.__str__ = ρσ_set.prototype.inspect = def():
|
|
478
|
+
ρσ_set.prototype.toString = ρσ_set.prototype.__repr__ = ρσ_set.prototype.__str__ = ρσ_set.prototype.inspect = def ():
|
|
468
479
|
return '{' + list(this).join(', ') + '}'
|
|
469
480
|
|
|
470
|
-
ρσ_set.prototype.__eq__ = def(other):
|
|
481
|
+
ρσ_set.prototype.__eq__ = def (other):
|
|
471
482
|
if not v'other instanceof this.constructor':
|
|
472
483
|
return False
|
|
473
484
|
if other.size is not this.size:
|
|
@@ -482,6 +493,7 @@ Object.defineProperties(ρσ_set.prototype, {
|
|
|
482
493
|
r = iterator.next()
|
|
483
494
|
return True
|
|
484
495
|
|
|
496
|
+
|
|
485
497
|
def ρσ_set_wrap(x):
|
|
486
498
|
ans = new ρσ_set()
|
|
487
499
|
ans.jsset = x
|
|
@@ -493,22 +505,23 @@ v'var set = ρσ_set, set_wrap = ρσ_set_wrap'
|
|
|
493
505
|
# dict {{{
|
|
494
506
|
v'var ρσ_dict_implementation'
|
|
495
507
|
|
|
508
|
+
|
|
496
509
|
def ρσ_dict_polyfill():
|
|
497
510
|
this._store = {}
|
|
498
511
|
this.size = 0
|
|
499
512
|
|
|
500
|
-
ρσ_dict_polyfill.prototype.set = def(x, value):
|
|
513
|
+
ρσ_dict_polyfill.prototype.set = def (x, value):
|
|
501
514
|
key = ρσ_set_keyfor(x)
|
|
502
515
|
if not Object.prototype.hasOwnProperty.call(this._store, key):
|
|
503
516
|
this.size += 1
|
|
504
517
|
this._store[key] = v'[x, value]'
|
|
505
518
|
return this
|
|
506
519
|
|
|
507
|
-
ρσ_dict_polyfill.prototype.clear = def(x):
|
|
520
|
+
ρσ_dict_polyfill.prototype.clear = def (x):
|
|
508
521
|
this._store = {}
|
|
509
522
|
this.size = 0
|
|
510
523
|
|
|
511
|
-
ρσ_dict_polyfill.prototype.delete = def(x):
|
|
524
|
+
ρσ_dict_polyfill.prototype.delete = def (x):
|
|
512
525
|
key = ρσ_set_keyfor(x)
|
|
513
526
|
if Object.prototype.hasOwnProperty.call(this._store, key):
|
|
514
527
|
this.size -= 1
|
|
@@ -516,42 +529,42 @@ def ρσ_dict_polyfill():
|
|
|
516
529
|
return True
|
|
517
530
|
return False
|
|
518
531
|
|
|
519
|
-
ρσ_dict_polyfill.prototype.has = def(x):
|
|
532
|
+
ρσ_dict_polyfill.prototype.has = def (x):
|
|
520
533
|
return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x))
|
|
521
534
|
|
|
522
|
-
ρσ_dict_polyfill.prototype.get = def(x):
|
|
535
|
+
ρσ_dict_polyfill.prototype.get = def (x):
|
|
523
536
|
try:
|
|
524
537
|
return this._store[ρσ_set_keyfor(x)][1]
|
|
525
538
|
except TypeError: # Key is not present
|
|
526
539
|
return undefined
|
|
527
540
|
|
|
528
|
-
ρσ_dict_polyfill.prototype.values = def(x):
|
|
541
|
+
ρσ_dict_polyfill.prototype.values = def (x):
|
|
529
542
|
ans = v"{'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}"
|
|
530
|
-
ans[ρσ_iterator_symbol] = def():
|
|
543
|
+
ans[ρσ_iterator_symbol] = def ():
|
|
531
544
|
return this
|
|
532
|
-
ans['next'] = def():
|
|
545
|
+
ans['next'] = def ():
|
|
533
546
|
this._i += 1
|
|
534
547
|
if this._i >= this._keys.length:
|
|
535
548
|
return v"{'done': true}"
|
|
536
549
|
return v"{'done':false, 'value':this._s[this._keys[this._i]][1]}"
|
|
537
550
|
return ans
|
|
538
551
|
|
|
539
|
-
ρσ_dict_polyfill.prototype.keys = def(x):
|
|
552
|
+
ρσ_dict_polyfill.prototype.keys = def (x):
|
|
540
553
|
ans = v"{'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}"
|
|
541
|
-
ans[ρσ_iterator_symbol] = def():
|
|
554
|
+
ans[ρσ_iterator_symbol] = def ():
|
|
542
555
|
return this
|
|
543
|
-
ans['next'] = def():
|
|
556
|
+
ans['next'] = def ():
|
|
544
557
|
this._i += 1
|
|
545
558
|
if this._i >= this._keys.length:
|
|
546
559
|
return v"{'done': true}"
|
|
547
560
|
return v"{'done':false, 'value':this._s[this._keys[this._i]][0]}"
|
|
548
561
|
return ans
|
|
549
562
|
|
|
550
|
-
ρσ_dict_polyfill.prototype.entries = def(x):
|
|
563
|
+
ρσ_dict_polyfill.prototype.entries = def (x):
|
|
551
564
|
ans = v"{'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}"
|
|
552
|
-
ans[ρσ_iterator_symbol] = def():
|
|
565
|
+
ans[ρσ_iterator_symbol] = def ():
|
|
553
566
|
return this
|
|
554
|
-
ans['next'] = def():
|
|
567
|
+
ans['next'] = def ():
|
|
555
568
|
this._i += 1
|
|
556
569
|
if this._i >= this._keys.length:
|
|
557
570
|
return v"{'done': true}"
|
|
@@ -563,6 +576,7 @@ if jstype(Map) is not 'function' or jstype(Map.prototype.delete) is not 'functio
|
|
|
563
576
|
else:
|
|
564
577
|
v'ρσ_dict_implementation = Map'
|
|
565
578
|
|
|
579
|
+
|
|
566
580
|
def ρσ_dict(iterable, **kw):
|
|
567
581
|
if v'this instanceof ρσ_dict':
|
|
568
582
|
this.jsmap = new ρσ_dict_implementation() # noqa:undef
|
|
@@ -577,20 +591,20 @@ def ρσ_dict(iterable, **kw):
|
|
|
577
591
|
|
|
578
592
|
# These are for JavaScript users' convenience
|
|
579
593
|
Object.defineProperties(ρσ_dict.prototype, {
|
|
580
|
-
'length': {
|
|
581
|
-
'size': {
|
|
594
|
+
'length': {'get': def (): return this.jsmap.size;},
|
|
595
|
+
'size': {'get': def (): return this.jsmap.size;},
|
|
582
596
|
})
|
|
583
597
|
|
|
584
|
-
ρσ_dict.prototype.__len__ = def(): return this.jsmap.size
|
|
585
|
-
ρσ_dict.prototype.has = ρσ_dict.prototype.__contains__ = def(x): return this.jsmap.has(x)
|
|
586
|
-
ρσ_dict.prototype.set = ρσ_dict.prototype.__setitem__ = def(key, value): this.jsmap.set(key, value)
|
|
598
|
+
ρσ_dict.prototype.__len__ = def (): return this.jsmap.size
|
|
599
|
+
ρσ_dict.prototype.has = ρσ_dict.prototype.__contains__ = def (x): return this.jsmap.has(x)
|
|
600
|
+
ρσ_dict.prototype.set = ρσ_dict.prototype.__setitem__ = def (key, value): this.jsmap.set(key, value)
|
|
587
601
|
ρσ_dict.prototype.__delitem__ = def (key): this.jsmap.delete(key)
|
|
588
|
-
ρσ_dict.prototype.clear = def(): this.jsmap.clear()
|
|
589
|
-
ρσ_dict.prototype.copy = def(): return ρσ_dict(this)
|
|
590
|
-
ρσ_dict.prototype.keys = def(): return this.jsmap.keys()
|
|
591
|
-
ρσ_dict.prototype.values = def(): return this.jsmap.values()
|
|
592
|
-
ρσ_dict.prototype.items = ρσ_dict.prototype.entries = def(): return this.jsmap.entries()
|
|
593
|
-
ρσ_dict.prototype[ρσ_iterator_symbol] = def(): return this.jsmap.keys()
|
|
602
|
+
ρσ_dict.prototype.clear = def (): this.jsmap.clear()
|
|
603
|
+
ρσ_dict.prototype.copy = def (): return ρσ_dict(this)
|
|
604
|
+
ρσ_dict.prototype.keys = def (): return this.jsmap.keys()
|
|
605
|
+
ρσ_dict.prototype.values = def (): return this.jsmap.values()
|
|
606
|
+
ρσ_dict.prototype.items = ρσ_dict.prototype.entries = def (): return this.jsmap.entries()
|
|
607
|
+
ρσ_dict.prototype[ρσ_iterator_symbol] = def (): return this.jsmap.keys()
|
|
594
608
|
|
|
595
609
|
ρσ_dict.prototype.__getitem__ = def (key):
|
|
596
610
|
ans = this.jsmap.get(key)
|
|
@@ -611,7 +625,7 @@ Object.defineProperties(ρσ_dict.prototype, {
|
|
|
611
625
|
return defval
|
|
612
626
|
return j.get(key)
|
|
613
627
|
|
|
614
|
-
ρσ_dict.fromkeys = ρσ_dict.prototype.fromkeys = def (iterable, value=None):
|
|
628
|
+
ρσ_dict.fromkeys = ρσ_dict.prototype.fromkeys = def (iterable, value = None):
|
|
615
629
|
ans = ρσ_dict()
|
|
616
630
|
iterator = iter(iterable)
|
|
617
631
|
r = iterator.next()
|
|
@@ -675,7 +689,7 @@ Object.defineProperties(ρσ_dict.prototype, {
|
|
|
675
689
|
if arguments.length > 1:
|
|
676
690
|
ρσ_dict.prototype.update.call(this, arguments[1])
|
|
677
691
|
|
|
678
|
-
ρσ_dict.prototype.toString = ρσ_dict.prototype.inspect = ρσ_dict.prototype.__str__ = ρσ_dict.prototype.__repr__ = def():
|
|
692
|
+
ρσ_dict.prototype.toString = ρσ_dict.prototype.inspect = ρσ_dict.prototype.__str__ = ρσ_dict.prototype.__repr__ = def ():
|
|
679
693
|
entries = v'[]'
|
|
680
694
|
iterator = this.jsmap.entries()
|
|
681
695
|
r = iterator.next()
|
|
@@ -684,7 +698,7 @@ Object.defineProperties(ρσ_dict.prototype, {
|
|
|
684
698
|
r = iterator.next()
|
|
685
699
|
return '{' + entries.join(', ') + '}'
|
|
686
700
|
|
|
687
|
-
ρσ_dict.prototype.__eq__ = def(other):
|
|
701
|
+
ρσ_dict.prototype.__eq__ = def (other):
|
|
688
702
|
if not v'(other instanceof this.constructor)':
|
|
689
703
|
return False
|
|
690
704
|
if other.size is not this.size:
|
|
@@ -700,7 +714,7 @@ Object.defineProperties(ρσ_dict.prototype, {
|
|
|
700
714
|
r = iterator.next()
|
|
701
715
|
return True
|
|
702
716
|
|
|
703
|
-
ρσ_dict.prototype.as_object = def(other):
|
|
717
|
+
ρσ_dict.prototype.as_object = def (other):
|
|
704
718
|
ans = {}
|
|
705
719
|
iterator = this.jsmap.entries()
|
|
706
720
|
r = iterator.next()
|
|
@@ -709,6 +723,7 @@ Object.defineProperties(ρσ_dict.prototype, {
|
|
|
709
723
|
r = iterator.next()
|
|
710
724
|
return ans
|
|
711
725
|
|
|
726
|
+
|
|
712
727
|
def ρσ_dict_wrap(x):
|
|
713
728
|
ans = new ρσ_dict()
|
|
714
729
|
ans.jsmap = x
|